objective c - NSSegmentedCell Subclass and Custom Geometry/Layout Impossible? -


a tale of 2 subclasses

by ben stock

prologue

i'm in process of making nice looking set of controls automatically change appearance depending on type of window they're used in (e.g. if drop button in normal window, looks other standard aqua button. if drop on nspanel window mask of nshudwindowmask, however, it'll automatically switch style on hud background. far, i've subclassed nsbutton, nstextfield, nsslider, , nssearchfield. last night started on nstabview, slammed down lack of customizability. it's real pain in ass, i'm developer, i'm used finding own way. first thing think add instance of nssegmentedcontrol in place of private tabs used nstabview. far, good. i've got buttons selectable, automatically update when new nstabviewitem's added, , work real thing.

and pain begins …

finally, start style segments, , … wtf have gotten myself into‽ should've gone acting or something. objective-c development taking years off life. no matter do, "tracking areas" used nssegmentedcell don't seem updating when segment widths change. when widths change, artwork does, too. however, actual tracking area doesn't update (even when override -updatetrackingareas. it's hard explain, decided draw my segment rectangles behind , in front of ones drawn super in -drawsegment:inframe:withview. here's screenshot art drawn on top of underlying tracking areas:

a hud panel in mac os x displaying debug rectangles.

and here's super's implementation above segment rects:

enter image description here

i've tried overriding can think of. here few of methods i've overridden (and un-overridden):

  • -cellsize (nssegmentedcell)
  • -cellsizeforbounds: (nssegmentedcell)
  • -sizetofit (nssegmentedcontrol)
  • -intrinsiccontentsize (nssegmentedcontrol)
  • -setwidth:forsegment: (nssegmentedcontrol/cell)
  • -starttrackingat:inview: (nssegmentedcell)
  • -continuetracking:at:inview: (nssegmentedcell)
  • -stoptracking:at:inview:mouseisup: (nssegmentedcell)

at point, of methods in above list still using overrides , aren't. i've mixed , matched, deleted, simplified, rewrote, , refactored, , no matter do, underlying rectangles don't change. love apple as next guy, view of customization needs change. can't stand not being able understand what's going on in implementation of these stupid controls. not mention fact still can't wrap head around auto layout (which un-"auto" thing i've ever dealt with), that's post day. anyway, if brotha out, i'd super grateful. sorry ranting , reading!

p.s. none of these things finished, please don't hard on few pixel imperfections. ;-)


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -