Revision: 14041
          http://sourceforge.net/p/skim-app/code/14041
Author:   hofman
Date:     2024-02-04 15:17:04 +0000 (Sun, 04 Feb 2024)
Log Message:
-----------
scroll again to correct location async to fix scrolling reset  by PDFView.

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

Modified: trunk/SKBasePDFView.h
===================================================================
--- trunk/SKBasePDFView.h       2024-02-03 23:33:46 UTC (rev 14040)
+++ trunk/SKBasePDFView.h       2024-02-04 15:17:04 UTC (rev 14041)
@@ -47,6 +47,8 @@
 
 - (void)drawPagesInRect:(NSRect)rect toContext:(CGContextRef)context;
 
+- (void)scrollToPageAtIndex:(NSUInteger)pageIndex point:(NSPoint)point;
+
 @end
 
 NS_ASSUME_NONNULL_END

Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m       2024-02-03 23:33:46 UTC (rev 14040)
+++ trunk/SKBasePDFView.m       2024-02-04 15:17:04 UTC (rev 14041)
@@ -286,6 +286,20 @@
    }
 }
 
+- (void)scrollToPageAtIndex:(NSUInteger)pageIndex point:(NSPoint)point {
+    PDFPage *page = [[self document] pageAtIndex:pageIndex];
+    if (NSEqualPoints(point, SKUnspecifiedPoint) == NO) {
+        NSScrollView *scrollView = [self scrollView];
+        NSClipView *clipView = [scrollView contentView];
+        point = [self convertPoint:[self convertPoint:point fromPage:page] 
toView:clipView];
+        if ([clipView isFlipped] == NO)
+            point.y -= NSHeight([clipView visibleRect]) - [self 
convertSize:NSMakeSize(0.0, [scrollView contentInsets].top) 
toView:clipView].height;
+        [clipView scrollToPoint:point];
+    } else if (hasVerticalLayout(self)) {
+        [self verticallyScrollToPage:page];
+    }
+}
+
 - (void)goToDestination:(PDFDestination *)destination {
     destination = [destination effectiveDestinationForView:self];
     if ([destination zoom] < kPDFDestinationUnspecifiedValue && [destination 
zoom] > 0.0)

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-02-03 23:33:46 UTC (rev 14040)
+++ trunk/SKMainWindowController.m      2024-02-04 15:17:04 UTC (rev 14041)
@@ -432,10 +432,18 @@
         if ([[pdfView document] isLocked]) {
             [savedNormalSetup setObject:[NSNumber 
numberWithUnsignedInteger:pageIndex] forKey:PAGEINDEX_KEY];
         } else if ([[pdfView currentPage] pageIndex] != pageIndex || 
pointString) {
-            [pdfView goToPageAtIndex:pageIndex point:pointString ? 
NSPointFromString(pointString) : SKUnspecifiedPoint];
+            NSPoint point = pointString ? NSPointFromString(pointString) : 
SKUnspecifiedPoint;
+            [pdfView goToPageAtIndex:pageIndex point:point];
             [lastViewedPages setCount:0];
             [lastViewedPages addPointer:(void *)pageIndex];
             [pdfView resetHistory];
+            if (@available(macOS 12.0, *)) {
+                if (([pdfView displayMode] & kPDFDisplaySinglePageContinuous)) 
{
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [pdfView scrollToPageAtIndex:pageIndex point:point];
+                    });
+                }
+            }
         }
     }
     

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