How to save the last element of the NSOutlineView tree at the bottom of the sidebar?

I would like to have the same special element behavior as in the Things app. I mean the log and basket items at the bottom of the sidebar:

Magazine and cart items are at the very bottom http://tinyurl.com/lhctza

Please indicate any way to implement the same functionality in the sidebar tree.

I feel that the special spacer tree element should be used with the method outlineView:heightOfRowByItem:.

However, I cannot find how to calculate the total height of all visible elements (including the space between the groups).

+5
source share
2 answers

, 8 . , :

- (CGFloat)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item;
{
    if (![item isSpacer]) return [ov rowHeight];

    static const CGFloat ADDITIONAL_SPACE = 8.0f;
    NSUInteger numberOfRootGroups = 2;
    CGFloat heightOfRows = [ov rowHeight] * ([ov rowForItem:item] + 1) 
        + ADDITIONAL_SPACE * numberOfRootGroups;
    CGFloat heightOfSidebar = [[ov superview] frame].size.height;
    return MAX(0.0f, heightOfSidebar - heightOfRows);
}

!

+1

, : , , , . , .

, , . , NSView .

+3
source

All Articles