Revision: 12736 http://sourceforge.net/p/skim-app/code/12736 Author: hofman Date: 2022-01-22 14:34:25 +0000 (Sat, 22 Jan 2022) Log Message: ----------- Renamevariable and macro. Get outlineTableColumn instead of a column by id.
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-21 16:05:13 UTC (rev 12735) +++ trunk/SKMainWindowController_UI.m 2022-01-22 14:34:25 UTC (rev 12736) @@ -120,9 +120,9 @@ #define DEFAULT_TEXT_ROW_HEIGHT 85.0 #define DEFAULT_MARKUP_ROW_HEIGHT 50.0 -static CGFloat noteColumnWidthOffset = 0.0; +static CGFloat outlineIndentation = 0.0; -#define NOTE_COLUMN_WIDTH_OFFSET (noteColumnWidthOffset > 0.0 ? noteColumnWidthOffset : RUNNING_AFTER(10_15) ? 9.0 : 16.0) +#define OUTLINE_INDENTATION (outlineIndentation > 0.0 ? outlineIndentation : RUNNING_AFTER(10_15) ? 9.0 : 16.0) @interface SKMainWindowController (SKPrivateMain) @@ -761,7 +761,7 @@ id item = [ov itemAtRow:row]; if ([(PDFAnnotation *)item type] == nil) { NSRect frame = [ov convertRect:[ov frameOfCellAtColumn:-1 row:row] toView:rowView]; - if ([[[(SKNoteOutlineView *)ov firstVisibleTableColumn] identifier] isEqualToString:NOTE_COLUMNID]) + if ([(SKNoteOutlineView *)ov outlineColumnIsFirst]) frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID owner:self]; [view setObjectValue:item]; @@ -866,10 +866,10 @@ - (void)outlineView:(NSOutlineView *)ov didChangeHiddenOfTableColumn:(NSTableColumn *)tableColumn { if (mwcFlags.autoResizeNoteRows && [ov isEqual:rightSideController.noteOutlineView]) { - if (noteColumnWidthOffset <= 0.0 && [ov numberOfRows] > 0) { - NSTableColumn *tc = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + if (outlineIndentation <= 0.0 && [ov numberOfRows] > 0) { + NSTableColumn *tc = [ov outlineTableColumn]; if ([tc isHidden] == NO) - noteColumnWidthOffset = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); + outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } [rowHeights removeAllFloats]; [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; @@ -882,12 +882,12 @@ NSInteger newColumn = [[[notification userInfo] objectForKey:@"NSNewColumn"] integerValue]; if (oldColumn == 0 || newColumn == 0) { SKNoteOutlineView *ov = [notification object]; - BOOL noteColumnIsFirst = [[[ov firstVisibleTableColumn] identifier] isEqualToString:NOTE_COLUMNID]; + 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 (noteColumnIsFirst) + if (outlineColumnIsFirst) frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); [rowCellView setFrame:frame]; } @@ -903,7 +903,7 @@ CGFloat rowHeight = [rowHeights floatForKey:item]; if (rowHeight <= 0.0) { if (mwcFlags.autoResizeNoteRows) { - NSTableColumn *tableColumn = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + NSTableColumn *tableColumn = [ov outlineTableColumn]; CGFloat width = 0.0; id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; @@ -910,11 +910,11 @@ // 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 (tableColumn == [(SKNoteOutlineView *)ov firstVisibleTableColumn]) - width -= NOTE_COLUMN_WIDTH_OFFSET; + if ([(SKNoteOutlineView *)ov outlineColumnIsFirst]) + width -= OUTLINE_INDENTATION; width = fmax(10.0, width); } else if ([tableColumn isHidden] == NO) { - width = [tableColumn width] - NOTE_COLUMN_WIDTH_OFFSET; + width = [tableColumn width] - OUTLINE_INDENTATION; } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; @@ -1167,7 +1167,7 @@ - (void)autoSizeNoteRows:(id)sender { NSOutlineView *ov = rightSideController.noteOutlineView; CGFloat height = 0.0, rowHeight = [ov rowHeight]; - NSTableColumn *tableColumn = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + NSTableColumn *tableColumn = [ov outlineTableColumn]; id cell = [tableColumn dataCell]; NSUInteger column = [[ov tableColumns] indexOfObject:tableColumn]; NSRect rect = NSMakeRect(0.0, 0.0, NSWidth([ov frameOfCellAtColumn:column row:0]), CGFLOAT_MAX); @@ -1218,13 +1218,13 @@ } - (void)toggleAutoResizeNoteRows:(id)sender { - if (noteColumnWidthOffset <= 0.0 && mwcFlags.autoResizeNoteRows == 0) { + if (outlineIndentation <= 0.0 && mwcFlags.autoResizeNoteRows == 0) { // calculate the difference between the cell width and the column width for the putline column // which depends on the style and the OS version NSOutlineView *ov = rightSideController.noteOutlineView; - NSTableColumn *tc = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + NSTableColumn *tc = [ov outlineTableColumn]; if ([tc isHidden] == NO && [ov numberOfRows] > 0) - noteColumnWidthOffset = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); + outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } mwcFlags.autoResizeNoteRows = (0 == mwcFlags.autoResizeNoteRows); if (mwcFlags.autoResizeNoteRows) { Modified: trunk/SKNoteOutlineView.h =================================================================== --- trunk/SKNoteOutlineView.h 2022-01-21 16:05:13 UTC (rev 12735) +++ trunk/SKNoteOutlineView.h 2022-01-22 14:34:25 UTC (rev 12736) @@ -48,8 +48,7 @@ - (id <SKNoteOutlineViewDelegate>)delegate; - (void)setDelegate:(id <SKNoteOutlineViewDelegate>)newDelegate; -@property (nonatomic, readonly) NSTableColumn *firstVisibleTableColumn; -@property (nonatomic, readonly) NSTableColumn *lastVisibleTableColumn; +@property (nonatomic, readonly) BOOL outlineColumnIsFirst; @property (nonatomic, readonly) CGFloat visibleColumnsWidth; @end Modified: trunk/SKNoteOutlineView.m =================================================================== --- trunk/SKNoteOutlineView.m 2022-01-21 16:05:13 UTC (rev 12735) +++ trunk/SKNoteOutlineView.m 2022-01-22 14:34:25 UTC (rev 12736) @@ -61,7 +61,7 @@ @implementation SKNoteOutlineView -@dynamic firstVisibleTableColumn, lastVisibleTableColumn, visibleColumnsWidth; +@dynamic outlineColumnIsFirst, visibleColumnsWidth; static inline NSString *titleForTableColumnIdentifier(NSString *identifier) { if ([identifier isEqualToString:NOTE_COLUMNID]) @@ -174,22 +174,14 @@ return [super frameOfCellAtColumn:column row:row]; } -- (NSTableColumn *)firstVisibleTableColumn { +- (BOOL)outlineColumnIsFirst { for (NSTableColumn *tc in [self tableColumns]) { if ([tc isHidden] == NO) - return tc; + return tc == [self outlineTableColumn]; } - return nil; + return NO; } -- (NSTableColumn *)lastVisibleTableColumn { - for (NSTableColumn *tc in [[self tableColumns] reverseObjectEnumerator]) { - if ([tc isHidden] == NO) - return tc; - } - return nil; -} - - (CGFloat)visibleColumnsWidth { CGFloat spacing = [self intercellSpacing].width; CGFloat width = -spacing; Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2022-01-21 16:05:13 UTC (rev 12735) +++ trunk/SKNotesDocument.m 2022-01-22 14:34:25 UTC (rev 12736) @@ -99,9 +99,9 @@ #define EXTRA_ROW_HEIGHT 2.0 #define DEFAULT_TEXT_ROW_HEIGHT 85.0 -static CGFloat noteColumnWidthOffset = 0.0; +static CGFloat outlineIndentation = 0.0; -#define NOTE_COLUMN_WIDTH_OFFSET (noteColumnWidthOffset > 0.0 ? noteColumnWidthOffset : RUNNING_AFTER(10_15) ? 9.0 : 16.0) +#define OUTLINE_INDENTATION (outlineIndentation > 0.0 ? outlineIndentation : RUNNING_AFTER(10_15) ? 9.0 : 16.0) @implementation SKNotesDocument @@ -536,7 +536,7 @@ - (void)autoSizeNoteRows:(id)sender { CGFloat height,rowHeight = [outlineView rowHeight]; - NSTableColumn *tableColumn = [outlineView tableColumnWithIdentifier:NOTE_COLUMNID]; + NSTableColumn *tableColumn = [outlineView outlineTableColumn]; NSUInteger column = [[outlineView tableColumns] indexOfObject:tableColumn]; id cell = [tableColumn dataCell]; NSRect rect = NSMakeRect(0.0, 0.0, NSWidth([outlineView frameOfCellAtColumn:column row:0]), CGFLOAT_MAX); @@ -587,10 +587,10 @@ } - (void)toggleAutoResizeNoteRows:(id)sender { - if (noteColumnWidthOffset <= 0.0 && ndFlags.autoResizeRows == 0 && [outlineView numberOfRows] > 0) { - NSTableColumn *tc = [outlineView tableColumnWithIdentifier:NOTE_COLUMNID]; + if (outlineIndentation <= 0.0 && ndFlags.autoResizeRows == 0 && [outlineView numberOfRows] > 0) { + NSTableColumn *tc = [outlineView outlineTableColumn]; if ([tc isHidden] == NO) - noteColumnWidthOffset = [tc width] - NSWidth([outlineView frameOfCellAtColumn:[[outlineView tableColumns] indexOfObject:tc] row:0]); + outlineIndentation = [tc width] - NSWidth([outlineView frameOfCellAtColumn:[[outlineView tableColumns] indexOfObject:tc] row:0]); } ndFlags.autoResizeRows = (0 == ndFlags.autoResizeRows); if (ndFlags.autoResizeRows) { @@ -698,7 +698,7 @@ id item = [ov itemAtRow:row]; if ([(PDFAnnotation *)item type] == nil) { NSRect frame = [outlineView convertRect:[outlineView frameOfCellAtColumn:-1 row:row] toView:rowView]; - if ([[[outlineView firstVisibleTableColumn] identifier] isEqualToString:NOTE_COLUMNID]) + if ([outlineView outlineColumnIsFirst]) frame = SKShrinkRect(frame, -[ov indentationPerLevel], NSMinXEdge); NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID owner:self]; [view setObjectValue:item]; @@ -773,12 +773,12 @@ NSInteger oldColumn = [[[notification userInfo] objectForKey:@"NSOldColumn"] integerValue]; NSInteger newColumn = [[[notification userInfo] objectForKey:@"NSNewColumn"] integerValue]; if (oldColumn == 0 || newColumn == 0) { - BOOL noteColumnIsFirst = [[[outlineView firstVisibleTableColumn] identifier] isEqualToString:NOTE_COLUMNID]; + 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 (noteColumnIsFirst) + if (outlineColumnIsFirst) frame = SKShrinkRect(frame, -[outlineView indentationPerLevel], NSMinXEdge); [rowCellView setFrame:frame]; } @@ -790,10 +790,10 @@ - (void)outlineView:(NSOutlineView *)ov didChangeHiddenOfTableColumn:(NSTableColumn *)tableColumn { if (ndFlags.autoResizeRows) { - if (noteColumnWidthOffset <= 0.0 && [outlineView numberOfRows] > 0) { - NSTableColumn *tc = [outlineView tableColumnWithIdentifier:NOTE_COLUMNID]; + if (outlineIndentation <= 0.0 && [outlineView numberOfRows] > 0) { + NSTableColumn *tc = [outlineView outlineTableColumn]; if ([tc isHidden] == NO) - noteColumnWidthOffset = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); + outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } [rowHeights removeAllFloats]; [outlineView noteHeightOfRowsChangedAnimating:YES]; @@ -842,17 +842,17 @@ CGFloat rowHeight = [rowHeights floatForKey:item]; if (rowHeight <= 0.0) { if (ndFlags.autoResizeRows) { - NSTableColumn *tableColumn = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + NSTableColumn *tableColumn = [ov outlineTableColumn]; CGFloat width = 0.0; id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; if ([(PDFAnnotation *)item type] == nil) { width = [outlineView visibleColumnsWidth]; - if (tableColumn == [outlineView firstVisibleTableColumn]) - width -= NOTE_COLUMN_WIDTH_OFFSET; + if ([outlineView outlineColumnIsFirst]) + width -= OUTLINE_INDENTATION; width = fmax(10.0, width); } else if ([tableColumn isHidden] == NO) { - width = [tableColumn width] - NOTE_COLUMN_WIDTH_OFFSET; + width = [tableColumn width] - OUTLINE_INDENTATION; } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].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