Revision: 12721 http://sourceforge.net/p/skim-app/code/12721 Author: hofman Date: 2022-01-19 17:03:11 +0000 (Wed, 19 Jan 2022) Log Message: ----------- Don't use frameOfCellAtColumn:row: from delegate method to get row height, as this may lead to a loop. Instead calculate the width from the column width(s) and a setting and OS version dependent offset we calculate once when turning on auto resizing.
Modified Paths: -------------- trunk/SKMainWindowController_UI.m trunk/SKNotesDocument.m Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2022-01-15 16:00:28 UTC (rev 12720) +++ trunk/SKMainWindowController_UI.m 2022-01-19 17:03:11 UTC (rev 12721) @@ -119,6 +119,8 @@ #define DEFAULT_TEXT_ROW_HEIGHT 85.0 #define DEFAULT_MARKUP_ROW_HEIGHT 50.0 +static CGFloat noteColumnWidthOffset = 0.0; + @interface SKMainWindowController (SKPrivateMain) - (void)cleanup; @@ -869,13 +871,21 @@ if (rowHeight <= 0.0) { if (mwcFlags.autoResizeNoteRows) { NSTableColumn *tableColumn = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; - CGFloat width; + CGFloat width = 0.0; id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; - if ([(PDFAnnotation *)item type] == nil) - width = fmax(10.0, NSWidth([ov frameOfCellAtColumn:-1 row:0]) - [ov indentationPerLevel]); - else - width = NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tableColumn] row:0]); + if ([(PDFAnnotation *)item type] == nil) { + for (NSTableColumn *tc in [ov tableColumns]) { + if ([tc isHidden] == NO) + width += [tc width] + [ov intercellSpacing].width; + } + width -= [ov intercellSpacing].width + [ov indentationPerLevel]; + if ([tableColumn isHidden] == NO) + width -= noteColumnWidthOffset; + width = fmax(10.0, width); + } else { + width = [tableColumn width] - noteColumnWidthOffset; + } rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; rowHeight = fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT; [rowHeights setFloat:rowHeight forKey:item]; @@ -1177,6 +1187,12 @@ } - (void)toggleAutoResizeNoteRows:(id)sender { + if (noteColumnWidthOffset <= 0.0 && mwcFlags.autoResizeNoteRows == 0) { + NSOutlineView *ov = rightSideController.noteOutlineView; + NSTableColumn *tc = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; + if ([tc isHidden] == NO) + noteColumnWidthOffset = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); + } mwcFlags.autoResizeNoteRows = (0 == mwcFlags.autoResizeNoteRows); if (mwcFlags.autoResizeNoteRows) { [rowHeights removeAllFloats]; Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2022-01-15 16:00:28 UTC (rev 12720) +++ trunk/SKNotesDocument.m 2022-01-19 17:03:11 UTC (rev 12721) @@ -98,6 +98,8 @@ #define EXTRA_ROW_HEIGHT 2.0 #define DEFAULT_TEXT_ROW_HEIGHT 85.0 +static CGFloat noteColumnWidthOffset = 0.0; + @implementation SKNotesDocument @synthesize outlineView, statusBar, arrayController, searchField, notes, pdfDocument, sourceFileURL; @@ -582,6 +584,11 @@ } - (void)toggleAutoResizeNoteRows:(id)sender { + if (noteColumnWidthOffset <= 0.0 && ndFlags.autoResizeRows == 0) { + NSTableColumn *tc = [outlineView tableColumnWithIdentifier:NOTE_COLUMNID]; + if ([tc isHidden] == NO) + noteColumnWidthOffset = [tc width] - NSWidth([outlineView frameOfCellAtColumn:[[outlineView tableColumns] indexOfObject:tc] row:0]); + } ndFlags.autoResizeRows = (0 == ndFlags.autoResizeRows); if (ndFlags.autoResizeRows) { [rowHeights removeAllFloats]; @@ -805,13 +812,21 @@ if (rowHeight <= 0.0) { if (ndFlags.autoResizeRows) { NSTableColumn *tableColumn = [ov tableColumnWithIdentifier:NOTE_COLUMNID]; - CGFloat width; + CGFloat width = 0.0; id cell = [tableColumn dataCell]; [cell setObjectValue:[item objectValue]]; - if ([(PDFAnnotation *)item type] == nil) - width = fmax(10.0, NSWidth([outlineView frameOfCellAtColumn:-1 row:0]) - [ov indentationPerLevel]); - else + if ([(PDFAnnotation *)item type] == nil) { + for (NSTableColumn *tc in [outlineView tableColumns]) { + if ([tc isHidden] == NO) + width += [tc width] + [outlineView intercellSpacing].width; + } + width -= [outlineView intercellSpacing].width + [outlineView indentationPerLevel]; + if ([tableColumn isHidden] == NO) + width -= noteColumnWidthOffset; + width = fmax(10.0, width); + } else { width = NSWidth([ov frameOfCellAtColumn:[[outlineView tableColumns] indexOfObject:tableColumn] row:0]); + } rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; rowHeight = fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT; [rowHeights setFloat:rowHeight forKey:item]; 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