Revision: 12737 http://sourceforge.net/p/skim-app/code/12737 Author: hofman Date: 2022-01-23 23:05:35 +0000 (Sun, 23 Jan 2022) Log Message: ----------- Resize note row heights through convenience method. Only note height changes for rows that were reset.
Modified Paths: -------------- trunk/SKMainWindowController_Actions.m trunk/SKMainWindowController_UI.m trunk/SKNotesDocument.m Modified: trunk/SKMainWindowController_Actions.m =================================================================== --- trunk/SKMainWindowController_Actions.m 2022-01-22 14:34:25 UTC (rev 12736) +++ trunk/SKMainWindowController_Actions.m 2022-01-23 23:05:35 UTC (rev 12737) @@ -100,6 +100,7 @@ - (void)updateLineInspector; - (void)updateNoteFilterPredicate; - (void)updateSnapshotFilterPredicate; +- (void)autoResizeNoteRows; @end @implementation SKMainWindowController (Actions) @@ -1045,12 +1046,8 @@ lastRightSidePaneWidth = floor(0.5 * NSWidth([centerContentView frame])); position -= lastRightSidePaneWidth + [splitView dividerThickness]; [splitView setPosition:position ofDividerAtIndex:1 animate:sender != nil]; - if (mwcFlags.autoResizeNoteRows && [splitView isAnimating]) { - [splitView enqueueOperation:^{ - [rowHeights removeAllFloats]; - [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; - }]; - } + if (mwcFlags.autoResizeNoteRows && [splitView isAnimating]) + [splitView enqueueOperation:^{ [self autoResizeNoteRows]; }]; } } } Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2022-01-22 14:34:25 UTC (rev 12736) +++ trunk/SKMainWindowController_UI.m 2022-01-23 23:05:35 UTC (rev 12737) @@ -871,8 +871,7 @@ if ([tc isHidden] == NO) outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } - [rowHeights removeAllFloats]; - [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; + [self autoResizeNoteRows]; } } @@ -1209,12 +1208,18 @@ - (void)resetHeightOfNoteRows:(id)sender { NSArray *items = [sender representedObject]; if (items == nil) { - [rowHeights removeAllFloats]; + [self autoResizeNoteRows]; } else { - for (id item in items) + SKNoteOutlineView *ov = rightSideController.noteOutlineView; + NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; + for (id item in items) { [rowHeights removeFloatForKey:item]; + NSInteger row = [ov rowForItem:item]; + if (row != -1) + [indexes addIndex:row]; + } + [ov noteHeightOfRowsWithIndexesChanged:indexes]; } - [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; } - (void)toggleAutoResizeNoteRows:(id)sender { @@ -1227,12 +1232,10 @@ outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } mwcFlags.autoResizeNoteRows = (0 == mwcFlags.autoResizeNoteRows); - if (mwcFlags.autoResizeNoteRows) { - [rowHeights removeAllFloats]; - [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; - } else { + if (mwcFlags.autoResizeNoteRows) + [self autoResizeNoteRows]; + else [self autoSizeNoteRows:nil]; - } } - (void)menuNeedsUpdate:(NSMenu *)menu { Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2022-01-22 14:34:25 UTC (rev 12736) +++ trunk/SKNotesDocument.m 2022-01-23 23:05:35 UTC (rev 12737) @@ -575,15 +575,25 @@ [outlineView noteHeightOfRowsWithIndexesChanged:rowIndexes ?: [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [outlineView numberOfRows])]]; } +- (void)autoResizeNoteRows { + [rowHeights removeAllFloats]; + [outlineView noteHeightOfRowsChangedAnimating:YES]; +} + - (void)resetHeightOfNoteRows:(id)sender { NSArray *items = [sender representedObject]; if (items == nil) { - [rowHeights removeAllFloats]; + [self autoResizeNoteRows]; } else { - for (id item in items) + NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; + for (id item in items) { [rowHeights removeFloatForKey:item]; + NSInteger row = [outlineView rowForItem:item]; + if (row != -1) + [indexes addIndex:row]; + } + [outlineView noteHeightOfRowsWithIndexesChanged:indexes]; } - [outlineView noteHeightOfRowsChangedAnimating:YES]; } - (void)toggleAutoResizeNoteRows:(id)sender { @@ -593,12 +603,10 @@ outlineIndentation = [tc width] - NSWidth([outlineView frameOfCellAtColumn:[[outlineView tableColumns] indexOfObject:tc] row:0]); } ndFlags.autoResizeRows = (0 == ndFlags.autoResizeRows); - if (ndFlags.autoResizeRows) { - [rowHeights removeAllFloats]; - [outlineView noteHeightOfRowsChangedAnimating:YES]; - } else { + if (ndFlags.autoResizeRows) + [self autoResizeNoteRows]; + else [self autoSizeNoteRows:nil]; - } } - (IBAction)toggleCaseInsensitiveSearch:(id)sender { @@ -759,11 +767,6 @@ [ov reloadData]; } -- (void)autoResizeNoteRows { - [rowHeights removeAllFloats]; - [outlineView noteHeightOfRowsChangedAnimating:YES]; -} - - (void)outlineViewColumnDidResize:(NSNotification *)notification{ if (ndFlags.autoResizeRows && [(SKScrollView *)[[notification object] enclosingScrollView] isResizingSubviews] == NO) [self performSelectorOnce:@selector(autoResizeNoteRows) afterDelay:0.0]; @@ -795,8 +798,7 @@ if ([tc isHidden] == NO) outlineIndentation = [tc width] - NSWidth([ov frameOfCellAtColumn:[[ov tableColumns] indexOfObject:tc] row:0]); } - [rowHeights removeAllFloats]; - [outlineView noteHeightOfRowsChangedAnimating:YES]; + [self autoResizeNoteRows]; } } 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