Revision: 16715
          http://sourceforge.net/p/skim-app/code/16715
Author:   hofman
Date:     2026-10-26 17:29:06 +0000 (Mon, 26 Oct 2026)
Log Message:
-----------
separate loading pdfDocument and applying setup in snapshot

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

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-10-26 16:50:19 UTC (rev 16714)
+++ trunk/SKMainWindowController.m      2026-10-26 17:29:06 UTC (rev 16715)
@@ -2439,11 +2439,8 @@
     
     [swc setDelegate:self];
     
-    [swc setPdfDocument:[pdfView document]
-               goToPage:page
-                   rect:rect
-            scaleFactor:scaleFactor
-               autoFits:autoFits];
+    [swc setPdfDocument:[pdfView document]];
+    [swc goToPage:page rect:rect scaleFactor:scaleFactor autoFits:autoFits];
     
     [swc setForceOnTop:[self interactionMode] == SKFullScreenMode];
     
@@ -2456,8 +2453,9 @@
         
         [swc setDelegate:self];
         
-        [swc setPdfDocument:[pdfView document] setup:setup];
-        
+        [swc setPdfDocument:[pdfView document]];
+        [swc setCurrentSetup:setup];
+
         [swc setForceOnTop:[self interactionMode] == SKFullScreenMode];
         
         [[self document] addWindowController:swc];

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2026-10-26 16:50:19 UTC (rev 
16714)
+++ trunk/SKMainWindowController_FullScreen.m   2026-10-26 17:29:06 UTC (rev 
16715)
@@ -200,7 +200,8 @@
         
         [preview setDelegate:self];
         
-        [preview setPdfDocument:pdfDoc previewPage:page 
displayOnScreen:screen];
+        [preview setPdfDocument:pdfDoc];
+        [preview previewPage:page displayOnScreen:screen];
     
         [[self document] addWindowController:preview];
     } else {

Modified: trunk/SKSnapshotWindowController.h
===================================================================
--- trunk/SKSnapshotWindowController.h  2026-10-26 16:50:19 UTC (rev 16714)
+++ trunk/SKSnapshotWindowController.h  2026-10-26 17:29:06 UTC (rev 16715)
@@ -73,15 +73,15 @@
 @property (nonatomic, nullable, readonly) NSString *pageLabel;
 @property (nonatomic, nullable, readonly) NSString *string;
 @property (nonatomic, readonly) BOOL hasWindow;
-@property (nonatomic, readonly) NSDictionary<NSString *, id> *currentSetup;
+@property (nonatomic, nullable, strong) PDFDocument *pdfDocument;
+@property (nonatomic, copy) NSDictionary<NSString *, id> *currentSetup;
 @property (nonatomic) BOOL forceOnTop;
 @property (nonatomic, readonly) SKSnapshotConfiguration *currentConfiguration;
 
 @property (nonatomic, readonly) NSAttributedString *thumbnailAttachment, 
*thumbnail512Attachment, *thumbnail256Attachment, *thumbnail128Attachment, 
*thumbnail64Attachment, *thumbnail32Attachment;
 
-- (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 previewPage:(PDFPage *)page 
displayOnScreen:(nullable NSScreen *)screen;
+- (void)goToPage:(PDFPage *)page rect:(NSRect)rect scaleFactor:(CGFloat)factor 
autoFits:(BOOL)autoFits;
+- (void)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 16:50:19 UTC (rev 16714)
+++ trunk/SKSnapshotWindowController.m  2026-10-26 17:29:06 UTC (rev 16715)
@@ -92,7 +92,7 @@
 @implementation SKSnapshotWindowController
 
 @synthesize pdfView, delegate, thumbnail, updateDate, pageLabel, string, 
hasWindow, forceOnTop;
-@dynamic bounds, pageIndex, currentSetup, currentConfiguration, 
thumbnailAttachment, thumbnail512Attachment, thumbnail256Attachment, 
thumbnail128Attachment, thumbnail64Attachment, thumbnail32Attachment;
+@dynamic bounds, pageIndex, pdfDocument, currentSetup, currentConfiguration, 
thumbnailAttachment, thumbnail512Attachment, thumbnail256Attachment, 
thumbnail128Attachment, thumbnail64Attachment, thumbnail32Attachment;
 
 - (NSString *)windowNibName {
     return @"SnapshotWindow";
@@ -112,6 +112,12 @@
     [sud addObserver:self forKeyPath:SKInterpolationQualityKey options:0 
context:&SKSnaphotWindowDefaultsObservationContext];
     // the window is initialially exposed. The windowDidExpose notification is 
useless, it has nothing to do with showing the window
     [self setHasWindow:YES];
+    [pdfView setScaleFactor:1.0];
+    [pdfView setAutoScales:NO];
+    [pdfView setDisplaysPageBreaks:NO];
+    [pdfView setDisplayBox:kPDFDisplayBoxCropBox];
+    [pdfView setInterpolationQuality:[[NSUserDefaults standardUserDefaults] 
integerForKey:SKInterpolationQualityKey]];
+    [pdfView setBackgroundColor:[NSColor whiteColor]];
 }
 
 // these should never be reached, but just to be sure
@@ -283,16 +289,10 @@
     }
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument goToPage:(PDFPage *)page 
rect:(NSRect)rect scaleFactor:(CGFloat)factor autoFits:(BOOL)autoFits 
screen:(NSScreen *)screen openType:(SKSnapshotOpenType)openType {
+- (void)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];
-    [pdfView setAutoScales:NO];
-    [pdfView setDisplaysPageBreaks:NO];
-    [pdfView setDisplayBox:kPDFDisplayBoxCropBox];
-    [pdfView setInterpolationQuality:[[NSUserDefaults standardUserDefaults] 
integerForKey:SKInterpolationQualityKey]];
-    [pdfView setBackgroundColor:[NSColor whiteColor]];
-    [pdfView setDocument:pdfDocument];
     
     NSRect frame = [pdfView convertRect:rect fromPage:page];
     CGFloat scrollerWidth = [NSScroller effectiveScrollerWidth];
@@ -338,34 +338,31 @@
     }
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument goToPage:(PDFPage *)page 
rect:(NSRect)rect scaleFactor:(CGFloat)factor autoFits:(BOOL)autoFits {
-    [self setPdfDocument:pdfDocument
-                goToPage:page
-                    rect:rect
-             scaleFactor:factor
-                autoFits:autoFits
-                  screen:nil
-                openType:SKSnapshotOpenNormal];
+- (void)goToPage:(PDFPage *)page rect:(NSRect)rect scaleFactor:(CGFloat)factor 
autoFits:(BOOL)autoFits {
+    [self goToPage:page
+              rect:rect
+       scaleFactor:factor
+          autoFits:autoFits
+            screen:nil
+          openType:SKSnapshotOpenNormal];
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument previewPage:(PDFPage *)page 
displayOnScreen:(NSScreen *)screen {
-    [self setPdfDocument:pdfDocument
-                goToPage:page
-                    rect:[page boundsForBox:kPDFDisplayBoxCropBox]
-             scaleFactor:1.0
-                autoFits:YES
-                  screen:screen
-                openType:SKSnapshotOpenPreview];
+- (void)previewPage:(PDFPage *)page displayOnScreen:(NSScreen *)screen {
+    [self goToPage:page
+              rect:[page boundsForBox:kPDFDisplayBoxCropBox]
+       scaleFactor:1.0
+          autoFits:YES
+            screen:screen
+          openType:SKSnapshotOpenPreview];
 }
 
-- (void)setPdfDocument:(PDFDocument *)pdfDocument setup:(NSDictionary *)setup {
-    [self setPdfDocument:pdfDocument
-                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]
-                  screen:nil
-                openType:SKSnapshotOpenFromSetup];
+- (void)setCurrentSetup:(NSDictionary *)setup {
+    [self goToPage:[[pdfView document] pageAtIndex:[[setup 
objectForKey:PAGE_KEY] unsignedIntegerValue]]
+              rect:NSRectFromString([setup objectForKey:RECT_KEY])
+       scaleFactor:[[setup objectForKey:SCALEFACTOR_KEY] doubleValue]
+          autoFits:[[setup objectForKey:AUTOFITS_KEY] boolValue]
+            screen:nil
+          openType:SKSnapshotOpenFromSetup];
     
     [self setHasWindow:[[setup objectForKey:HASWINDOW_KEY] boolValue]];
     if ([setup objectForKey:WINDOWFRAME_KEY])
@@ -403,6 +400,15 @@
         [self updateWindowLevel];
 }
 
+- (PDFDocument *)pdfDocument {
+    return [pdfView document];
+}
+
+- (void)setPdfDocument:(PDFDocument *)pdfDocument {
+    [self window];
+    [pdfView setDocument:pdfDocument];
+}
+
 - (NSDictionary *)currentSetup {
     return @{PAGE_KEY:[NSNumber numberWithUnsignedInteger:[self pageIndex]], 
RECT_KEY:NSStringFromRect([self bounds]), SCALEFACTOR_KEY:[NSNumber 
numberWithDouble:[pdfView scaleFactor]], AUTOFITS_KEY:[NSNumber 
numberWithBool:[pdfView autoFits]], HASWINDOW_KEY:[NSNumber 
numberWithBool:[[self window] isVisible]], 
WINDOWFRAME_KEY:NSStringFromRect([[self window] frame])};
 }

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