Revision: 12746 http://sourceforge.net/p/skim-app/code/12746 Author: hofman Date: 2022-01-25 10:34:28 +0000 (Tue, 25 Jan 2022) Log Message: ----------- Include correction for indentation of outline columnin calculation of full width cell frame
Modified Paths: -------------- trunk/SKMainWindowController_UI.m trunk/SKNoteOutlineView.h trunk/SKNoteOutlineView.m trunk/SKNotesDocument.m Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2022-01-25 10:06:11 UTC (rev 12745) +++ trunk/SKMainWindowController_UI.m 2022-01-25 10:34:28 UTC (rev 12746) @@ -756,8 +756,6 @@ id item = [ov itemAtRow:row]; if ([(PDFAnnotation *)item type] == nil) { NSRect frame = [ov convertRect:[ov frameOfCellAtColumn:-1 row:row] toView:rowView]; - if ([(SKNoteOutlineView *)ov outlineColumnIsFirst]) - frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID owner:self]; [view setObjectValue:item]; [[view textField] setEditable:NO]; @@ -870,13 +868,10 @@ NSInteger newColumn = [[[notification userInfo] objectForKey:@"NSNewColumn"] integerValue]; if (oldColumn == 0 || newColumn == 0) { SKNoteOutlineView *ov = [notification object]; - BOOL outlineColumnIsFirst = [ov outlineColumnIsFirst]; [ov enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView *rowView, NSInteger row){ NSTableCellView *rowCellView = [rowView rowCellView]; if (rowCellView) { NSRect frame = [ov convertRect:[ov frameOfCellAtColumn:-1 row:row] toView:rowView]; - if (outlineColumnIsFirst) - frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); [rowCellView setFrame:frame]; } }]; @@ -896,14 +891,10 @@ id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; // don't use cellFrameAtRow:column: as this needs the row height which we are calculating - if ([(PDFAnnotation *)item type] == nil) { - width = [(SKNoteOutlineView *)ov visibleColumnsWidth]; - if ([(SKNoteOutlineView *)ov outlineColumnIsFirst]) - width -= [(SKNoteOutlineView *)ov outlineIndentation]; - width = fmax(10.0, width); - } else if ([tableColumn isHidden] == NO) { + if ([(PDFAnnotation *)item type] == nil) + width = fmax(10.0, [(SKNoteOutlineView *)ov fullWidthCellWidth]); + else if ([tableColumn isHidden] == NO) width = [tableColumn width] - [(SKNoteOutlineView *)ov outlineIndentation]; - } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; rowHeight = round(fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT); Modified: trunk/SKNoteOutlineView.h =================================================================== --- trunk/SKNoteOutlineView.h 2022-01-25 10:06:11 UTC (rev 12745) +++ trunk/SKNoteOutlineView.h 2022-01-25 10:34:28 UTC (rev 12746) @@ -48,8 +48,7 @@ - (id <SKNoteOutlineViewDelegate>)delegate; - (void)setDelegate:(id <SKNoteOutlineViewDelegate>)newDelegate; -@property (nonatomic, readonly) BOOL outlineColumnIsFirst; -@property (nonatomic, readonly) CGFloat visibleColumnsWidth; +@property (nonatomic, readonly) CGFloat fullWidthCellWidth; @property (nonatomic, readonly) CGFloat outlineIndentation; @end Modified: trunk/SKNoteOutlineView.m =================================================================== --- trunk/SKNoteOutlineView.m 2022-01-25 10:06:11 UTC (rev 12745) +++ trunk/SKNoteOutlineView.m 2022-01-25 10:34:28 UTC (rev 12746) @@ -61,7 +61,7 @@ @implementation SKNoteOutlineView -@dynamic outlineColumnIsFirst, visibleColumnsWidth, outlineIndentation; +@dynamic fullWidthCellWidth, outlineIndentation; static inline NSString *titleForTableColumnIdentifier(NSString *identifier) { if ([identifier isEqualToString:NOTE_COLUMNID]) @@ -160,6 +160,14 @@ return YES; } +- (BOOL)outlineColumnIsFirst { + for (NSTableColumn *tc in [self tableColumns]) { + if ([tc isHidden] == NO) + return tc == [self outlineTableColumn]; + } + return NO; +} + - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row { if (column == -1) { NSRect frame = NSZeroRect; @@ -169,26 +177,27 @@ if ([[tcs objectAtIndex:column] isHidden] == NO) frame = NSUnionRect(frame, [super frameOfCellAtColumn:column row:row]); } + NSInteger level = [self levelForRow:row]; + if (level > 0 && [self outlineColumnIsFirst]) + frame = SKShrinkRect(frame, -[self indentationPerLevel] * level, NSMinYEdge); return frame; } return [super frameOfCellAtColumn:column row:row]; } -- (BOOL)outlineColumnIsFirst { - for (NSTableColumn *tc in [self tableColumns]) { - if ([tc isHidden] == NO) - return tc == [self outlineTableColumn]; - } - return NO; -} - -- (CGFloat)visibleColumnsWidth { +- (CGFloat)fullWidthCellWidth { CGFloat spacing = [self intercellSpacing].width; CGFloat width = -spacing; + NSInteger outlineIsFirst = -1; for (NSTableColumn *tc in [self tableColumns]) { - if ([tc isHidden] == NO) + if ([tc isHidden] == NO) { + if (outlineIsFirst == -1) + outlineIsFirst = tc == [self outlineTableColumn]; width += [tc width] + spacing; + } } + if (outlineIsFirst == 1) + width -= [self outlineIndentation]; return width; } Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2022-01-25 10:06:11 UTC (rev 12745) +++ trunk/SKNotesDocument.m 2022-01-25 10:34:28 UTC (rev 12746) @@ -698,8 +698,6 @@ id item = [ov itemAtRow:row]; if ([(PDFAnnotation *)item type] == nil) { NSRect frame = [outlineView convertRect:[outlineView frameOfCellAtColumn:-1 row:row] toView:rowView]; - if ([outlineView outlineColumnIsFirst]) - frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID owner:self]; [view setObjectValue:item]; [view setFrame:frame]; @@ -768,13 +766,10 @@ NSInteger oldColumn = [[[notification userInfo] objectForKey:@"NSOldColumn"] integerValue]; NSInteger newColumn = [[[notification userInfo] objectForKey:@"NSNewColumn"] integerValue]; if (oldColumn == 0 || newColumn == 0) { - BOOL outlineColumnIsFirst = [outlineView outlineColumnIsFirst]; [outlineView enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView *rowView, NSInteger row){ NSTableCellView *rowCellView = [rowView rowCellView]; if (rowCellView) { NSRect frame = [outlineView convertRect:[outlineView frameOfCellAtColumn:-1 row:row] toView:rowView]; - if (outlineColumnIsFirst) - frame = SKShrinkRect(frame, -[outlineView indentationPerLevel], NSMinXEdge); [rowCellView setFrame:frame]; } }]; @@ -834,14 +829,10 @@ CGFloat width = 0.0; id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; - if ([(PDFAnnotation *)item type] == nil) { - width = [outlineView visibleColumnsWidth]; - if ([outlineView outlineColumnIsFirst]) - width -= [outlineView outlineIndentation]; - width = fmax(10.0, width); - } else if ([tableColumn isHidden] == NO) { + if ([(PDFAnnotation *)item type] == nil) + width = fmax(10.0, [outlineView fullWidthCellWidth]); + else if ([tableColumn isHidden] == NO) width = [tableColumn width] - [outlineView outlineIndentation]; - } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; rowHeight = round(fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit