Re: How to specify row placement in an NSOutlineView?
Re: How to specify row placement in an NSOutlineView?
- Subject: Re: How to specify row placement in an NSOutlineView?
- From: Seth Willits <email@hidden>
- Date: Tue, 12 Jun 2007 17:26:11 -0700
Well, I sorta found a work around for this. I can set private
variables in NSOutlineView using the objc runtime. It works, but I
really don't like it. I can make my own custom outline cell (the
triangle) and replace the standard one, and then go ahead and make
extra tall rows to make the spacing around the top-level rows. Since
I have my own outline cell class, I can draw that properly to align
to the row rather than simply being centered. It's super ugly but I
have no other choice other than writing my own *ENTIRE* outline view,
which is a gigantic undertaking (with drag and drop and all that),
JUST so I can put some padding at the top of specific rows, line up
the reveal triangle, and draw it a slightly different color.
Insane.
object_setInstanceVariable(outlineView, "_outlineCell", myOutlineCell);
object_setInstanceVariable(outlineView, "_trackingOutlineCell",
myOutlineCell);
There has to be a better way to do this.
--
Seth Willits
On Jun 12, 2007, at 12:29 AM, Seth Willits wrote:
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