Question

I'd like to have the same behavior of special items as it's done in the Things application. I mean Logbook and Trash items in the bottom part of the Sidebar:

Logbook and Trash items are in the most bottom http://tinyurl.com/lhctza

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

I feel that special ‘spacer’ tree item should be used together with outlineView:heightOfRowByItem: method.

However, I can't find how to calculate the total height of all visible items (incl. space between groups).

Was it helpful?

Solution 2

I've decided to hardcode the solution by adding 8 pixels of height for every root item in group style. So, the code looks like this:

- (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);
}

Thanks to everybody for support!

OTHER TIPS

You might try simply having two outline views: One of fixed height, pinned to the bottom of their superview, and the other of variable height, with its bottom immediately above the top of the first. The fixed-height outline view would contain those Logbook and Trash items, and the variable-height outline view would contain all the others.

The tricky part would be making this play nice with a scroll view, but I think you could do it. I imagine you'd put them both in a fully-resizable NSView and make that the scroll view's document view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top