Revision: 16713
          http://sourceforge.net/p/skim-app/code/16713
Author:   hofman
Date:     2026-10-26 16:08:49 +0000 (Mon, 26 Oct 2026)
Log Message:
-----------
pass page instead of page index for snapshot

Modified Paths:
--------------
    trunk/SKMainWindowController.h
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_FullScreen.m
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m
    trunk/SKSnapshotWindowController.h
    trunk/SKSnapshotWindowController.m

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKMainWindowController.h      2026-10-26 16:08:49 UTC (rev 16713)
@@ -204,7 +204,7 @@
 
 - (SKTransitionController *)transitionControllerCreating:(BOOL)create;
 
-- (void)showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
+- (void)showSnapshotAtPage:(PDFPage *)page forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
 - (void)showSnapshotsWithSetups:(NSArray<NSDictionary<NSString *, id> *> 
*)setups;
 - (void)showNote:(PDFAnnotation *)annotation;
 

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKMainWindowController.m      2026-10-26 16:08:49 UTC (rev 16713)
@@ -2434,13 +2434,13 @@
 
 #pragma mark Subwindows
 
-- (void)showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits {
+- (void)showSnapshotAtPage:(PDFPage *)page forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits {
     SKSnapshotWindowController *swc = [[SKSnapshotWindowController alloc] 
init];
     
     [swc setDelegate:self];
     
     [swc setPdfDocument:[pdfView document]
-         goToPageNumber:pageNum
+               goToPage:page
                    rect:rect
             scaleFactor:scaleFactor
                autoFits:autoFits];

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2026-10-26 09:36:07 UTC (rev 
16712)
+++ trunk/SKMainWindowController_FullScreen.m   2026-10-26 16:08:49 UTC (rev 
16713)
@@ -185,8 +185,11 @@
     NSDocument *notesDocument = [self presentationNotesDocument];
     PDFDocument *pdfDoc = [notesDocument pdfDocument];
     NSInteger offset = [self presentationNotesOffset];
-    NSUInteger pageIndex = MAX(0, MIN((NSInteger)[pdfDoc pageCount] - 1, 
(NSInteger)[[pdfView currentPage] pageIndex] + offset));
+    PDFPage *page = [pdfView currentPage];
     
+    if (notesDocument != [self document] || offset != 0)
+        page = [pdfDoc pageAtIndex:MAX(0, MIN((NSInteger)[pdfDoc pageCount] - 
1, (NSInteger)[page pageIndex] + offset))];
+    
     if (presentationNotesAuxiliary == nil)
         presentationNotesAuxiliary = [[SKPresentationNotesAuxiliary alloc] 
init];
     
@@ -197,11 +200,11 @@
         
         [preview setDelegate:self];
         
-        [preview setPdfDocument:pdfDoc previewPageNumber:pageIndex 
displayOnScreen:screen];
+        [preview setPdfDocument:pdfDoc previewPage:page 
displayOnScreen:screen];
     
         [[self document] addWindowController:preview];
     } else {
-        [notesDocument setCurrentPage:[pdfDoc pageAtIndex:pageIndex]];
+        [notesDocument setCurrentPage:page];
     }
 }
 

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKMainWindowController_UI.m   2026-10-26 16:08:49 UTC (rev 16713)
@@ -573,7 +573,7 @@
         
         rect.origin.y = NSMidY(rect) - 0.5 * SNAPSHOT_HEIGHT;
         rect.size.height = SNAPSHOT_HEIGHT;
-        [self showSnapshotAtPageNumber:row forRect:rect scaleFactor:[pdfView 
scaleFactor] autoFits:NO];
+        [self showSnapshotAtPage:[[pdfView document] pageAtIndex:row] 
forRect:rect scaleFactor:[pdfView scaleFactor] autoFits:NO];
         return YES;
     }
     return NO;
@@ -1735,8 +1735,8 @@
     [self showNote:annotation];
 }
 
-- (void)PDFView:(PDFView *)aPDFView 
showSnapshotAtPageNumber:(NSInteger)pageNum forRect:(NSRect)rect 
scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits {
-    [self showSnapshotAtPageNumber:pageNum forRect:rect 
scaleFactor:scaleFactor autoFits:autoFits];
+- (void)PDFView:(PDFView *)aPDFView showSnapshotAtPage:(PDFPage *)page 
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits {
+    [self showSnapshotAtPage:page forRect:rect scaleFactor:scaleFactor 
autoFits:autoFits];
 }
 
 - (void)PDFView:(PDFView *)aPDFView didRotatePageAtIndex:(NSUInteger)idx 
by:(NSInteger)rotation {

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKPDFView.h   2026-10-26 16:08:49 UTC (rev 16713)
@@ -122,7 +122,7 @@
 - (void)PDFViewDidBeginEditing:(PDFView *)pdfView;
 - (void)PDFViewDidEndEditing:(PDFView *)pdfView;
 - (void)PDFView:(PDFView *)pdfView editAnnotation:(PDFAnnotation *)annotation;
-- (void)PDFView:(PDFView *)pdfView showSnapshotAtPageNumber:(NSInteger)pageNum 
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
+- (void)PDFView:(PDFView *)pdfView showSnapshotAtPage:(PDFPage *)page 
forRect:(NSRect)rect scaleFactor:(CGFloat)scaleFactor autoFits:(BOOL)autoFits;
 - (void)PDFViewPerformHideFind:(PDFView *)pdfView;
 - (BOOL)PDFView:(PDFView *)pdfView performAction:(PDFAction *)action;
 - (void)PDFView:(PDFView *)pdfView didRotatePageAtIndex:(NSUInteger)idx 
by:(NSInteger)rotation;

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKPDFView.m   2026-10-26 16:08:49 UTC (rev 16713)
@@ -3042,8 +3042,8 @@
         rect = [self convertRect:rect toPage:page];
     }
     
-    if ([[self delegate] 
respondsToSelector:@selector(PDFView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
-        [[self delegate] PDFView:self showSnapshotAtPageNumber:[page 
pageIndex] forRect:rect scaleFactor:[self scaleFactor] autoFits:autoFits];
+    if ([[self delegate] 
respondsToSelector:@selector(PDFView:showSnapshotAtPage:forRect:scaleFactor:autoFits:)])
+        [[self delegate] PDFView:self showSnapshotAtPage:page forRect:rect 
scaleFactor:[self scaleFactor] autoFits:autoFits];
 }
 
 #pragma mark Zooming
@@ -4828,8 +4828,8 @@
         
     }
     
-    if ([[self delegate] 
respondsToSelector:@selector(PDFView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
-        [[self delegate] PDFView:self showSnapshotAtPageNumber:[page 
pageIndex] forRect:rect scaleFactor:[self scaleFactor] * factor 
autoFits:autoFits];
+    if ([[self delegate] 
respondsToSelector:@selector(PDFView:showSnapshotAtPage:forRect:scaleFactor:autoFits:)])
+        [[self delegate] PDFView:self showSnapshotAtPage:page forRect:rect 
scaleFactor:[self scaleFactor] * factor autoFits:autoFits];
 }
 
 - (void)removeLoupeWindow {

Modified: trunk/SKSnapshotWindowController.h
===================================================================
--- trunk/SKSnapshotWindowController.h  2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKSnapshotWindowController.h  2026-10-26 16:08:49 UTC (rev 16713)
@@ -79,9 +79,9 @@
 
 @property (nonatomic, readonly) NSAttributedString *thumbnailAttachment, 
*thumbnail512Attachment, *thumbnail256Attachment, *thumbnail128Attachment, 
*thumbnail64Attachment, *thumbnail32Attachment;
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument 
goToPageNumber:(NSInteger)pageNum rect:(NSRect)rect scaleFactor:(CGFloat)factor 
autoFits:(BOOL)autoFits;
+- (void)setPdfDocument:(PDFDocument *)pdfDocument goToPage:(PDFPage *)page 
rect:(NSRect)rect scaleFactor:(CGFloat)factor autoFits:(BOOL)autoFits;
 - (void)setPdfDocument:(PDFDocument *)pdfDocument setup:(NSDictionary<NSString 
*, id> *)setup;
-- (void)setPdfDocument:(PDFDocument *)pdfDocument 
previewPageNumber:(NSInteger)pageNum displayOnScreen:(nullable NSScreen 
*)screen;
+- (void)setPdfDocument:(PDFDocument *)pdfDocument previewPage:(PDFPage *)page 
displayOnScreen:(nullable NSScreen *)screen;
 
 - (BOOL)isPageVisible:(PDFPage *)page;
 - (BOOL)isPageInIndexesVisible:(NSIndexSet *)pageIndexes;

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2026-10-26 09:36:07 UTC (rev 16712)
+++ trunk/SKSnapshotWindowController.m  2026-10-26 16:08:49 UTC (rev 16713)
@@ -283,7 +283,7 @@
     }
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument 
goToPageNumber:(NSInteger)pageNum rect:(NSRect)rect scaleFactor:(CGFloat)factor 
autoFits:(BOOL)autoFits screen:(NSScreen *)screen 
openType:(SKSnapshotOpenType)openType {
+- (void)setPdfDocument:(PDFDocument *)pdfDocument goToPage:(PDFPage *)page 
rect:(NSRect)rect scaleFactor:(CGFloat)factor autoFits:(BOOL)autoFits 
screen:(NSScreen *)screen openType:(SKSnapshotOpenType)openType {
     NSWindow *window = [self window];
     
     [pdfView setScaleFactor:factor];
@@ -294,7 +294,6 @@
     [pdfView setBackgroundColor:[NSColor whiteColor]];
     [pdfView setDocument:pdfDocument];
     
-    PDFPage *page = [pdfDocument pageAtIndex:pageNum];
     NSRect frame = [pdfView convertRect:rect fromPage:page];
     CGFloat scrollerWidth = [NSScroller effectiveScrollerWidth];
     if (scrollerWidth > 0.0) {
@@ -339,9 +338,9 @@
     }
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument 
goToPageNumber:(NSInteger)pageNum rect:(NSRect)rect scaleFactor:(CGFloat)factor 
autoFits:(BOOL)autoFits {
+- (void)setPdfDocument:(PDFDocument *)pdfDocument goToPage:(PDFPage *)page 
rect:(NSRect)rect scaleFactor:(CGFloat)factor autoFits:(BOOL)autoFits {
     [self setPdfDocument:pdfDocument
-          goToPageNumber:pageNum
+                goToPage:page
                     rect:rect
              scaleFactor:factor
                 autoFits:autoFits
@@ -349,10 +348,10 @@
                 openType:SKSnapshotOpenNormal];
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument 
previewPageNumber:(NSInteger)pageNum displayOnScreen:(NSScreen *)screen {
+- (void)setPdfDocument:(PDFDocument *)pdfDocument previewPage:(PDFPage *)page 
displayOnScreen:(NSScreen *)screen {
     [self setPdfDocument:pdfDocument
-          goToPageNumber:pageNum
-                    rect:[[pdfDocument pageAtIndex:pageNum] 
boundsForBox:kPDFDisplayBoxCropBox]
+                goToPage:page
+                    rect:[page boundsForBox:kPDFDisplayBoxCropBox]
              scaleFactor:1.0
                 autoFits:YES
                   screen:screen
@@ -361,7 +360,7 @@
 
 - (void)setPdfDocument:(PDFDocument *)pdfDocument setup:(NSDictionary *)setup {
     [self setPdfDocument:pdfDocument
-          goToPageNumber:[[setup objectForKey:PAGE_KEY] unsignedIntegerValue]
+                goToPage:[pdfDocument pageAtIndex:[[setup 
objectForKey:PAGE_KEY] unsignedIntegerValue]]
                     rect:NSRectFromString([setup objectForKey:RECT_KEY])
              scaleFactor:[[setup objectForKey:SCALEFACTOR_KEY] doubleValue]
                 autoFits:[[setup objectForKey:AUTOFITS_KEY] boolValue]

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

Reply via email to