How to specify row placement in an NSOutlineView?
How to specify row placement in an NSOutlineView?
- Subject: How to specify row placement in an NSOutlineView?
- From: Seth Willits <email@hidden>
- Date: Tue, 12 Jun 2007 00:29:28 -0700
In lists such as the sources/playlists view in iTunes where there are
groups with gray labels, (10.5's Finder sidebar is a better example
if you have seen it), assuming this is an outline view, I'm wondering
how I can accomplish the space separation between groups.
iTunes doesn't have reveal triangles, but in my app (like 10.5
Finder) I need them, so assume they are there. If you make the group
label rows a little taller (by using the delegate method), you can
easily draw the text near the bottom of the cell to make space at the
top in between groups. The problem with this approach, however, is
that you have no control where the reveal triangle is drawn; it
always draws in the vertical center of the cell, which means it's not
aligned with the bottom-aligned text.
Another idea is simply to have a 6px row above any group label row
(except the first), but that's an annoying bit of management,
especially when you have drag and drop & a varying number of groups.
What would make this really easy is if I could push rows down a
certain amount. If I can have rows 1-10 all use the normal position,
but then 11-20 get shoved down 6px, 21-40 gets shoved down 12px etc.
I tried overriding rectOfRow:, such as...
- (NSRect)rectOfRow:(int)rowIndex;
{
NSRect rect = [super rectOfRow:rowIndex];
if ([self levelForRow:rowIndex] == 0 && rowIndex > 0) {
rect.origin.y += 6.0 * [[self dataSource] outlineView:self
indexOfGroupLabelItem:[self itemAtRow:rowIndex]];
}
return rect;
}
...and that worked beautifully for initial drawing, but breaks on
mouse clicks and everything else.
I'd really like to use an outline view because I need a lot of what
it offers me for free. Any ideas?
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden