Revision: 14294
          http://sourceforge.net/p/skim-app/code/14294
Author:   hofman
Date:     2024-06-03 14:33:56 +0000 (Mon, 03 Jun 2024)
Log Message:
-----------
Reuse variable, use only size of page

Modified Paths:
--------------
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-06-03 14:25:02 UTC (rev 14293)
+++ trunk/SKMainWindowController.m      2024-06-03 14:33:56 UTC (rev 14294)
@@ -2849,18 +2849,13 @@
 - (void)resetThumbnails {
     NSMutableArray *newThumbnails = [NSMutableArray array];
     if ([pageLabels count] > 0) {
-        PDFPage *firstPage = [[pdfView document] pageAtIndex:0];
-        NSRect bounds = [firstPage boundsForBox:[pdfView displayBox]];
-        if (([firstPage rotation] % 180) == 0)
-            bounds.origin = NSZeroPoint;
-        else
-            bounds = NSMakeRect(0.0, 0.0, NSHeight(bounds), NSWidth(bounds));
-        PDFPage *emptyPage = [[PDFPage alloc] init];
-        [emptyPage setBounds:bounds forBox:kPDFDisplayBoxMediaBox];
-        CGFloat width = ceil(0.8 * fmin(NSWidth(bounds), NSHeight(bounds)));
-        NSRect rect = NSInsetRect(bounds, 0.5 * (NSWidth(bounds) - width), 0.5 
* (NSHeight(bounds) - width));
+        PDFPage *page = [[pdfView document] pageAtIndex:0];
+        NSSize size = [page boundsForBox:[pdfView displayBox]].size;
+        if (([page rotation] % 180) == 90)
+            size = NSMakeSize(size.height, size.width);
+        CGFloat width = ceil(0.8 * fmin(size.width, size.height));
+        NSRect rect = NSMakeRect(0.5 * (size.width - width), 0.5 * 
(size.height - width), width, width);
         NSMutableArray *stamps = [NSMutableArray array];
-        
         NSString *type = [[self document] fileType];
         if ([type isEqualToString:SKPostScriptDocumentType])
             type = @"PS";
@@ -2873,11 +2868,14 @@
         else
             type = @"PDF";
 
+        page = [[PDFPage alloc] init];
+        [page setBounds:(NSRect){NSZeroPoint, size} 
forBox:kPDFDisplayBoxMediaBox];
+        
         [stamps addObject:[[SKThumbnailStamp alloc] initWithImage:[NSImage 
stampForType:type] rect:rect fraction:1.0]];
         if ([[pdfView document] isLocked])
             [stamps addObject:[[SKThumbnailStamp alloc] 
initWithImage:[[NSWorkspace sharedWorkspace] 
iconForFileType:NSFileTypeForHFSTypeCode(kLockedBadgeIcon)] rect:rect 
fraction:0.5]];
         
-        NSImage *pageImage = [emptyPage thumbnailWithSize:thumbnailCacheSize 
forBox:kPDFDisplayBoxMediaBox hasShadow:YES highlights:stamps];
+        NSImage *pageImage = [page thumbnailWithSize:thumbnailCacheSize 
forBox:kPDFDisplayBoxMediaBox hasShadow:YES highlights:stamps];
         
         [pageLabels enumerateObjectsUsingBlock:^(NSString *label, NSUInteger 
i, BOOL *stop) {
             SKThumbnail *thumbnail = [[SKThumbnail alloc] 
initWithImage:pageImage label:label pageIndex:i];

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