Matt Legend Gemmell Modesty is Lying

Mac OS X Cocoa and iPhone Development Services available at Instinctive Code.
Favorites icon
Favorites for iPhone
Speed-dial with style.
Mac OS X Cocoa and iPhone Developer for hire

Other Pages

Categories

Posted
8 October 2006 @ 5pm

Categories
Development, Source

Tags
, , , , , ,

RoundedBox source code updated

Just a quick note that I’ve updated my RoundedBox code, which you can get from my Cocoa Source code page.

Change list:

  • Now uses Core Graphics to draw the gradient backgrounds instead of Core Image (thanks to Chad Weider for his nifty CTGradient class). This means that the code is now compatible with Panther and Tiger, not just Tiger.
  • We now return YES for preservesContentDuringLiveResize if we’re drawing solid-color (i.e. not gradient) backgrounds; we only needed to return NO if we were drawing gradients.
  • Fix: Thick borders now no longer occlude the box’s title.
  • Fix: The title background area now grows proportionally to the border width.
  • Fix: Borders are now sharper at odd (i.e. not even-numbered) border thicknesses.

You should be able to drop the new version right into projects using RoundedBox without any changes.


2 Comments

Jussi
9 October 2006 @ 7am

I tried the latest version but your optimization with preservesContentDuringLiveResize seems to be a bit buggy, if solid background (preservesContent == YES) is selected with the long title resizing the window trashes the title. I guess this can be fixed by defining a proper - (void) setFrameSize:(NSSize)newSize .

I glanced thru the code and wonder why you in several places explicitely draw the box instead of just setting that the view needs to be displayed. I dunno if it has that big impact but having read quartz optimizing guide I’ve left with the impression that it’s better to just set areas dirty instead of explicit redraw.

I’ll study the code better later and try to learn me something, thanks.


Matt
9 October 2006 @ 8pm

Yeah I noticed that one pretty much immediately but was busy with other stuff. A less crapped-up version is up now. Regarding the -display thing, I vividly remember having a reason for that very early-on, before it was even an NSBox subclass I think, but it’s become lost in the mists of time. I replaced those -display messages with -setNeedsDisplay: in the archive.


Leave a Comment

Django More RoundedBox updates