setting row colours and heights for NSOutlineView (view based and source listing options selected )

973 views Asked by At

I have customised NSOutlineView using delegate functions to adjust row heights and color for group items using the following:

- (void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
    LOG(@"didAddRowView called");
    if ([self outlineView:outlineView isGroupItem:[outlineView itemAtRow:row]])
        [rowView setBackgroundColor:[NSColor controlColor]];
}

- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item {
    if ([self outlineView:outlineView isGroupItem:item])
        return 24.0;
    else
        return 36.0;
}

This almost works, the outcome is shown below. There is a small gap between the last row in a section and the next sections header. Can anyone shed any light on what this might be and how to remove it. Could it be some kind of footer perhaps, and if so are there any API's for adjusting it ? The bottom picture is what I get if I remove outlineView:heightOfRowsByItem completely.

enter image description here

Outcome without using heightOfRowsByItem

Outcome without using heightOfRowsByItem

EDIT: I sort of solved this by setting the outlineView backgroundColor to the colour I want fo r the header rows and then setting the other rows colour to white. This fills the gap as can be seen below but still seems to be a bit of a workaround.

enter image description here

1

There are 1 answers

0
Aderstedt On

Another way to solve this is to set the height of the NSTableCellView used for the headers.