On Mon, Feb 9, 2009 at 3:57 PM, Jerry Krinock <je...@ieee.org> wrote:
> I need a "collection of views" to display subviews of nonequal heights, like > this: Take a number. :-) An Apple-designed, all-encompassing, animated, subclass-able collection view which manages arbitrarily-sized subviews would be *awesome*. Sadly, it doesn't exist. > It seems that NSCollectionView does not support variable item frame sizes > like this, because it is hard-wired to arrange items in a 2-dimensional > grid. Could someone please confirm that? Confirmed. > Is there any basic documentation like a "Collection View Programming Guide", > covering NSCollectionView and friends? I've not been able to find any. I don't believe so because NSCollectionView and friends aren't particularly subclass-able (all of the layout beyond row/column count is private API). It's ridiculously efficient compared to an arbitrarily-sized counterpart precisely because coordinates / sizes are a very simple math operation away, whereas the 'space' for arbitrarily-sized objects (especially with multiple columns) can be quite tricky to locate efficiently (while drawing - especially in live-resize, determining selection, determining the container's size, etc). > I believe NSTableView has the same restriction of equal row heights. Is > that correct? No. As of 10.4, the delegate method -tableView:heightOfRow: lets you control this. > So I was thinking I'd write my own "collection view class" which would > basically be an NSView containing an array of subviews. Does anyone have a > better approach? Depends. Do you want to support multiple columns or just one? Do you want to fly things around as layout is performed? Are the subviews homogenous (despite their different sizes, they're the same view with different data) or can different items be represented by different classes of subviews? Does the container view need to do its own custom drawing behind / around objects (selection indication, other UI decorations)? These are all things to consider - things which directly affect how you'll need to approach the design of such a component. There may be more; I can't think of everything. ;-) If all you want is a basic NSCollectionView-like widget that manages a single column with homogenous subviews of arbitrary height, however, the approach isn't trivial but it's not overly-difficult either. Optimizing, however, can produce a lot of gotcha's, depending on what you want your view to do. -- I.S. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com