Revision: 16235
http://sourceforge.net/p/skim-app/code/16235
Author: hofman
Date: 2026-05-06 16:49:08 +0000 (Wed, 06 May 2026)
Log Message:
-----------
combine selection and page history highlight updating as they are always
updated together. Move selection updating to UI category. Update highlights
only once when setting expansion state.
Modified Paths:
--------------
trunk/LeftSideView.xib
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.h
trunk/SKMainWindowController_UI.m
Modified: trunk/LeftSideView.xib
===================================================================
--- trunk/LeftSideView.xib 2026-05-06 15:42:59 UTC (rev 16234)
+++ trunk/LeftSideView.xib 2026-05-06 16:49:08 UTC (rev 16235)
@@ -635,9 +635,15 @@
</scroller>
<point key="canvasLocation" x="267" y="154"/>
</scrollView>
- <menu id="89"/>
- <menu id="198"/>
- <menu id="197"/>
+ <menu id="89">
+ <point key="canvasLocation" x="-210" y="-145"/>
+ </menu>
+ <menu id="198">
+ <point key="canvasLocation" x="-310" y="-245"/>
+ </menu>
+ <menu id="197">
+ <point key="canvasLocation" x="-469" y="-245"/>
+ </menu>
<objectController id="90" userLabel="OwnerController">
<declaredKeys>
<string>leftSidePaneState</string>
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2026-05-06 15:42:59 UTC (rev 16234)
+++ trunk/SKMainWindowController.h 2026-05-06 16:49:08 UTC (rev 16235)
@@ -275,14 +275,9 @@
- (void)selectFindResultHighlight:(NSSelectionDirection)direction;
-- (void)updateOutlineSelection;
-
-- (void)updateNoteSelection;
-
- (BOOL)isOutlineExpanded:(PDFOutline *)outline;
- (void)setExpanded:(BOOL)flag forOutline:(PDFOutline *)outline;
-- (void)updateThumbnailSelection;
- (void)resetThumbnails;
- (void)resetThumbnailSizeIfNeeded;
- (void)updateThumbnailAtPageIndex:(NSUInteger)index;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2026-05-06 15:42:59 UTC (rev 16234)
+++ trunk/SKMainWindowController.m 2026-05-06 16:49:08 UTC (rev 16235)
@@ -883,7 +883,7 @@
[self expandOutline:outlineRoot forExpansionState:info level:level];
}
mwcFlags.updatingOutlineSelection = 0;
- [self updateOutlineSelection];
+ [self updateTocSelectionHighlights];
// handle the case as above where the outline has disappeared in a reload
situation
if (nil == outlineRoot)
@@ -2882,42 +2882,6 @@
#pragma mark Outline
-- (void)updateOutlineSelection{
-
- // Skip out if this PDF has no outline.
- if ([[pdfView document] outlineRoot] == nil ||
mwcFlags.updatingOutlineSelection)
- return;
-
- // Get index of current page.
- NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
-
- // Test that the current selection is still valid.
- NSInteger row = [leftSideController.tocOutlineView selectedRow];
- if (row == -1 || [[[leftSideController.tocOutlineView itemAtRow:row] page]
pageIndex] != pageIndex) {
- // Get the outline row that contains the current page
- NSInteger numRows = [leftSideController.tocOutlineView numberOfRows];
- for (row = 0; row < numRows; row++) {
- // Get the page for the given row....
- PDFPage *page = [[leftSideController.tocOutlineView itemAtRow:row]
page];
- if (page == nil) {
- continue;
- } else if ([page pageIndex] == pageIndex) {
- break;
- } else if ([page pageIndex] > pageIndex) {
- if (row > 0) --row;
- break;
- }
- }
- if (row == numRows)
- row--;
- if (row != -1) {
- mwcFlags.updatingOutlineSelection = 1;
- [leftSideController.tocOutlineView selectRowIndexes:[NSIndexSet
indexSetWithIndex:row] byExtendingSelection:NO];
- mwcFlags.updatingOutlineSelection = 0;
- }
- }
-}
-
- (BOOL)isOutlineExpanded:(PDFOutline *)outline {
if (-1 == [leftSideController.tocOutlineView rowForItem:outline])
return NO;
@@ -3001,15 +2965,6 @@
return YES;
}
-- (void)updateThumbnailSelection {
- // Get index of current page.
- NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
- mwcFlags.updatingThumbnailSelection = 1;
- [leftSideController.thumbnailTableView selectRowIndexes:[NSIndexSet
indexSetWithIndex:pageIndex] byExtendingSelection:NO];
- [leftSideController.thumbnailTableView scrollRowToVisible:pageIndex];
- mwcFlags.updatingThumbnailSelection = 0;
-}
-
- (NSImage *)placeholderThumbnailImage {
PDFPage *page = [[pdfView document] pageAtIndex:0];
NSSize size = [page boundsForBox:[pdfView displayBox]].size;
@@ -3094,48 +3049,6 @@
#pragma mark Notes
-- (void)updateNoteSelection {
- NSSortDescriptor *sortDesc = [[rightSideController.noteArrayController
sortDescriptors] firstObject];
-
- if ([[sortDesc key] isEqualToString:SKNPDFAnnotationPageIndexKey] == NO)
- return;
-
- NSArray *orderedNotes = [rightSideController.noteArrayController
arrangedObjects];
- __block PDFAnnotation *selAnnotation = nil;
- NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
- NSMutableIndexSet *selPageIndexes = [NSMutableIndexSet indexSet];
- NSEnumerationOptions options = [sortDesc ascending] ? 0 :
NSEnumerationReverse;
-
- for (PDFAnnotation *annotation in [self selectedNotes]) {
- if ([annotation pageIndex] != NSNotFound)
- [selPageIndexes addIndex:[annotation pageIndex]];
- }
-
- if ([orderedNotes count] == 0 || [selPageIndexes containsIndex:pageIndex])
- return;
-
- // Walk outline view looking for best firstpage number match.
- [orderedNotes enumerateObjectsWithOptions:options
usingBlock:^(PDFAnnotation *annotation, NSUInteger i, BOOL *stop) {
- if ([annotation pageIndex] == pageIndex) {
- selAnnotation = annotation;
- *stop = YES;
- } else if ([annotation pageIndex] > pageIndex) {
- if (i == 0)
- selAnnotation = [orderedNotes objectAtIndex:0];
- else if ([selPageIndexes containsIndex:[[orderedNotes
objectAtIndex:i - 1] pageIndex]])
- selAnnotation = [orderedNotes objectAtIndex:i - 1];
- *stop = YES;
- }
- }];
- if (selAnnotation) {
- mwcFlags.updatingNoteSelection = 1;
- NSInteger row = [rightSideController.noteOutlineView
rowForItem:selAnnotation];
- [rightSideController.noteOutlineView selectRowIndexes:[NSIndexSet
indexSetWithIndex:row] byExtendingSelection:NO];
- [rightSideController.noteOutlineView scrollRowToVisible:row];
- mwcFlags.updatingNoteSelection = 0;
- }
-}
-
- (void)updateNoteFilterPredicate {
[rightSideController.noteArrayController
setFilterPredicate:[noteTypeSheetController
filterPredicateForSearchString:[rightSideController.searchField stringValue]
caseInsensitive:mwcFlags.caseInsensitiveFilter]];
[rightSideController.noteOutlineView reloadData];
Modified: trunk/SKMainWindowController_UI.h
===================================================================
--- trunk/SKMainWindowController_UI.h 2026-05-06 15:42:59 UTC (rev 16234)
+++ trunk/SKMainWindowController_UI.h 2026-05-06 16:49:08 UTC (rev 16235)
@@ -54,6 +54,8 @@
- (NSInteger)thumbnailHighlightLevelForRow:(NSInteger)row;
+- (void)updateTocSelectionHighlights;
+
@end
NS_ASSUME_NONNULL_END
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2026-05-06 15:42:59 UTC (rev 16234)
+++ trunk/SKMainWindowController_UI.m 2026-05-06 16:49:08 UTC (rev 16235)
@@ -338,7 +338,7 @@
}
}
-#pragma mark Page history highlights
+#pragma mark Selection and Page and history highlights
#define MAX_HIGHLIGHTS 5
@@ -369,10 +369,18 @@
return 0;
}
-- (void)updateThumbnailHighlights {
+- (void)updateThumbnailSelectionHighlights {
+ // Get index of current page.
+ NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
+ mwcFlags.updatingThumbnailSelection = 1;
+ [leftSideController.thumbnailTableView selectRowIndexes:[NSIndexSet
indexSetWithIndex:pageIndex] byExtendingSelection:NO];
+ [leftSideController.thumbnailTableView scrollRowToVisible:pageIndex];
+ mwcFlags.updatingThumbnailSelection = 0;
+
[leftSideController.thumbnailTableView
enumerateAvailableRowViewsUsingBlock:^(SKHighlightingTableRowView *rowView,
NSInteger row){
[rowView setHighlightLevel:[self thumbnailHighlightLevelForRow:row]];
}];
+
if (overviewView) {
for (NSIndexPath *indexPath in [overviewView
indexPathsForVisibleItems])
[(SKThumbnailItem *)[overviewView itemAtIndexPath:indexPath]
setHighlightLevel:[self thumbnailHighlightLevelForRow:[indexPath item]]];
@@ -379,7 +387,42 @@
}
}
-- (void)updateTocHighlights {
+- (void)updateTocSelectionHighlights {
+ // Skip out if this PDF has no outline.
+ if ([[pdfView document] outlineRoot] == nil)
+ return;
+
+ if (mwcFlags.updatingOutlineSelection) {
+ // Get index of current page.
+ NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
+
+ // Test that the current selection is still valid.
+ NSInteger row = [leftSideController.tocOutlineView selectedRow];
+ if (row == -1 || [[[leftSideController.tocOutlineView itemAtRow:row]
page] pageIndex] != pageIndex) {
+ // Get the outline row that contains the current page
+ NSInteger numRows = [leftSideController.tocOutlineView
numberOfRows];
+ for (row = 0; row < numRows; row++) {
+ // Get the page for the given row....
+ PDFPage *page = [[leftSideController.tocOutlineView
itemAtRow:row] page];
+ if (page == nil) {
+ continue;
+ } else if ([page pageIndex] == pageIndex) {
+ break;
+ } else if ([page pageIndex] > pageIndex) {
+ if (row > 0) --row;
+ break;
+ }
+ }
+ if (row == numRows)
+ row--;
+ if (row != -1) {
+ mwcFlags.updatingOutlineSelection = 1;
+ [leftSideController.tocOutlineView
selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
+ mwcFlags.updatingOutlineSelection = 0;
+ }
+ }
+ }
+
if (@available(macOS 11.0, *)) {
[leftSideController.tocOutlineView
enumerateAvailableRowViewsUsingBlock:^(SKHighlightingTableRowView *rowView,
NSInteger row){
[rowView setHighlightLevel:[self tocHighlightLevelForRow:row]];
@@ -387,6 +430,48 @@
}
}
+- (void)updateNoteSelection {
+ NSSortDescriptor *sortDesc = [[rightSideController.noteArrayController
sortDescriptors] firstObject];
+
+ if ([[sortDesc key] isEqualToString:SKNPDFAnnotationPageIndexKey] == NO)
+ return;
+
+ NSArray *orderedNotes = [rightSideController.noteArrayController
arrangedObjects];
+ __block PDFAnnotation *selAnnotation = nil;
+ NSUInteger pageIndex = [[pdfView currentPage] pageIndex];
+ NSMutableIndexSet *selPageIndexes = [NSMutableIndexSet indexSet];
+ NSEnumerationOptions options = [sortDesc ascending] ? 0 :
NSEnumerationReverse;
+
+ for (PDFAnnotation *annotation in [self selectedNotes]) {
+ if ([annotation pageIndex] != NSNotFound)
+ [selPageIndexes addIndex:[annotation pageIndex]];
+ }
+
+ if ([orderedNotes count] == 0 || [selPageIndexes containsIndex:pageIndex])
+ return;
+
+ // Walk outline view looking for best firstpage number match.
+ [orderedNotes enumerateObjectsWithOptions:options
usingBlock:^(PDFAnnotation *annotation, NSUInteger i, BOOL *stop) {
+ if ([annotation pageIndex] == pageIndex) {
+ selAnnotation = annotation;
+ *stop = YES;
+ } else if ([annotation pageIndex] > pageIndex) {
+ if (i == 0)
+ selAnnotation = [orderedNotes objectAtIndex:0];
+ else if ([selPageIndexes containsIndex:[[orderedNotes
objectAtIndex:i - 1] pageIndex]])
+ selAnnotation = [orderedNotes objectAtIndex:i - 1];
+ *stop = YES;
+ }
+ }];
+ if (selAnnotation) {
+ mwcFlags.updatingNoteSelection = 1;
+ NSInteger row = [rightSideController.noteOutlineView
rowForItem:selAnnotation];
+ [rightSideController.noteOutlineView selectRowIndexes:[NSIndexSet
indexSetWithIndex:row] byExtendingSelection:NO];
+ [rightSideController.noteOutlineView scrollRowToVisible:row];
+ mwcFlags.updatingNoteSelection = 0;
+ }
+}
+
#pragma mark NSTableView datasource protocol
// AppKit bug: need a dummy NSTableDataSource implementation, otherwise some
NSTableView delegate methods are ignored
@@ -900,16 +985,14 @@
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification{
- if ([[notification object] isEqual:leftSideController.tocOutlineView]) {
- [self updateTocHighlights];
- [self updateOutlineSelection];
+ if ([[notification object] isEqual:leftSideController.tocOutlineView] &&
mwcFlags.updatingOutlineSelection == 0) {
+ [self updateTocSelectionHighlights];
}
}
- (void)outlineViewItemDidCollapse:(NSNotification *)notification{
- if ([[notification object] isEqual:leftSideController.tocOutlineView]) {
- [self updateTocHighlights];
- [self updateOutlineSelection];
+ if ([[notification object] isEqual:leftSideController.tocOutlineView] &&
mwcFlags.updatingOutlineSelection == 0) {
+ [self updateTocSelectionHighlights];
}
}
@@ -1955,14 +2038,11 @@
if ([lastViewedPages count] > MAX_HIGHLIGHTS)
[lastViewedPages setCount:MAX_HIGHLIGHTS];
}
- [self updateThumbnailHighlights];
- [self updateTocHighlights];
-
[self updatePageLabel];
- [self updateOutlineSelection];
+ [self updateThumbnailSelectionHighlights];
+ [self updateTocSelectionHighlights];
[self updateNoteSelection];
- [self updateThumbnailSelection];
[overviewView setSelectionIndexes:[NSIndexSet
indexSetWithIndex:pageIndex]];
if ([self hasOverview])
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit