LockFocus

Another Way to Mimic the Artwork Column in Cocoa

Jesper’s recent post about mimicking the iTunes Artwork Column in Cocoa piqued my interest. It seemed like it should be possible to do this just within the confines of an NSTableView.

After some thought, the solution I came up with was just drawing the contents that you wanted to appear in slices the height of the rows in the proper column. If the cells are totally opaque (as they are in iTunes), then the cell’s normal contents (including row selection) won’t show through. I put together a basic example of this:

Download ArtworkColumn code

ArtworkColumn

ArtworkColumn is a simple proof of concept to show how such a thing could be done. Things would get complicated if your content was more than just an image on a background, but in that case you could probably cache the content as an image and draw that cached images in slices in a similar way.

Update: Paul Kim has a much improved generalized version of this approach on his blog.