github/twui — pull request #149 by galaxas0 (2012-12-15 20:24:18+00:00)
Title: TUIButton Revamped!

The current `TUIButton` has several flaws, aside from not even being "API-complete":

- The button style does not have OS X version consistency: 10.6, 10.7, and 10.8+ all have different button drawing.
- The button style does not have User-wide consistency: the user will notice quirky buttons easily.
- The button style does not have proper HiDPI capable drawing (`NSShadow` can go die in a ditch :cry: ).

After some investigation, I've determined that AppKit's demon-child `NSCell` is actually quite useful for us: We can use these little drawing blocks on top of our amazing `CALayer` backed `TUIView`s easily and keep OS and User consistency.

`NSButtonCell` uses the `CoreUI.framework` introduced in 10.5 to draw all its controls perfectly, and can do everything for us: so why do it ourselves? Now `TUIButton` has a shared button renderer (an `NSButtonCell`) whose bezel style is swapped out and is redrawn for each button.

Now the `TUIButton` is indiscernible from a standard `NSButton`! I've yet to figure out how to pulse the button though: my idea is to use a `CAAnimation` to swap button colors, but there's no way to find the "darker" button color in the AppKit pulse. AppKit also uses a special `NSUIHeartBeat` thread for these animations.