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 November 2005 @ 3pm

Categories
Development, Interface, Source

Tags
, , , ,

RoundedBox source code

Just a quick note that I’m releasing the source code for my RoundedBox NSBox subclass, which I talked about previously. You’re free to use/redistribute original or modified versions, as long as you credit me. See the included Read Me file for more details.

That said, go ahead and download the source code. Requires Tiger and Xcode 2.1; sample app included.


9 Comments

Jesper
8 November 2005 @ 3pm

I believe this has been asked before (in the original RoundedBox entry) but never answered: why the new look? It doesn’t look like anything in Apple’s apps, so it’s not something that makes people more comfortable with the app, and besides looking different, it doesn’t seem to do a lot more than an ordinary NSBox.

I guess I wouldn’t react this strongly if you hadn’t previously taken Apple to task for creating custom controls that mostly just look different.


Matt
8 November 2005 @ 3pm

Fair question there. I like the rounded box aesthetic, and I needed a box style for a graphical app (an icon application I’ve mentioned a couple of times recently) which didn’t let the visual “noise” of the standard pinstriped background show through. It begins to melt my eyes after any length of time, particularly if I’m looking closely at colors and pixel-positioning.

I find that image adjustment needs a muted background for controls surrounding the canvas, and I thought that something light-grey would do that. Regarding the gradients, I honestly just wanted to try it out as a backdrop after seeing Comic Life.


Jesper
8 November 2005 @ 4pm

That sounds reasonable. (I’m assuming that a regular NSBox inside of a custom NSView drawing a white (or light grey) background, which would also be rounded and “stripe-less” and a lot less labor, didn’t look as good.)


Jonathan Wight
8 November 2005 @ 4pm

Hey Matt,

I liked the concept so much I actually implemented my own version last night. Imitation is the sincerest form of flattery etc. Of course you go and release the code today thus ruining my plans for cornering the Mac OS X rounded box market. Anyway - thanks for the code - I was having trouble with resizing until I found preservesContentDuringLiveResize in your code.

A couple of notes:

You’re not using the titleCell for drawing the title but rather just using the title string itself. This means someone can’t use a custom cell for the title.

Part of the performance problems a commenter on a previous thread made might be because you’re recreating the CIFilter every time you draw. I’ve found creating CIFilters to be pretty slow - might be an idea to make it an instance variable and just create it once. (I’m using CG gradients instead of CI filters but whatever works).

Anyway - it’s a really nice NSBox keep up the good work. And thanks for the source code release. Now what happened to your pie menu work?

Also - its good to see you posting again and about geek stuff too. Cheers!


Jonathan Wight
8 November 2005 @ 5pm

Oh and a quick screenshot of my box code. Not quite pixel perfect with yours:

http://toxicsoftware.com/_public/RoundedBoxClone.png

(The pie chart thing is an attempt at a NSProgressIndicator subclass that looks like the one you see occasionally in Mail.app)


Matt
8 November 2005 @ 5pm

Hi Jonathan,

That looks familiar! Sorry I didn’t release a day sooner, but we both know it’s fun to do the implementation. Good catch on making the CIFilter an ivar, and just passing in new positional parameters at drawing time; I’ll get that fixed.

I have a todo list here which includes respecting the title cell, returning sensible values for -titleRect, -titlePosition and so on; I’ll post those modifications once I’ve made them. I created a new “Source” category here on the blog for all posts which mention newly released or updated source code, to make it easier to keep track of my stuff in feed aggregators. I’ll hopefully eventually get around to setting up a nifty online subversion repository like some folk. ;)

I like the progress indicator; reminds me of a chapter in (I think) Hillegass’ book, where you make an angular position control which looks much the same. And indeed of my old PieChartCell class, which I really _have_ to get around to releasing soon.

http://mattgemmell.com/images/piechart.png


Matt
8 November 2005 @ 5pm

Hi again Jesper,

Yep, I didn’t much like the three-dimensional nature of the rounded version of NSBox (it’s slightly sunken), and I willingly confess that I wanted to try out the titlebar shape in my subclass. Maybe I’m becoming more custom-control-tolerant these days?

Hopefully this NSBox isn’t quite in the HIG-busting category of the address bar/progress indicator thing in Safari, or the bright yellow Supplies pushbutton in the Print dialog if you’re running low on toner. :) But yes, I guess it’s a slippery slope.

I rather asked for all this when I posted my iTunes 5 window style code previously!

http://mattgemmell.com/archives/2005/09/12/updated-itunes-5-window-code


Dan Waylonis
17 May 2006 @ 6am

Hi Matt,

Inside the source, you ask if there’s an easier way to go from NSColor CIColor. On Tiger, at the bottom of NSColor.h, there is + (NSColor *)colorWithCIColor:(CIColor *)color and for CIColor, initWithColor:(NSColor *)color.

Dan


Matt
17 May 2006 @ 3pm

Hey Dan,

How weird that I didn’t notice that. Cheers!

-M


Leave a Comment

Hit test algorithm Customer Service