Revision: 16002
          http://sourceforge.net/p/skim-app/code/16002
Author:   hofman
Date:     2026-01-11 18:41:37 +0000 (Sun, 11 Jan 2026)
Log Message:
-----------
scroll horizontally in twoup mode if needed

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

Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m       2026-01-11 17:04:45 UTC (rev 16001)
+++ trunk/SKBasePDFView.m       2026-01-11 18:41:37 UTC (rev 16002)
@@ -275,6 +275,25 @@
     [clipView scrollPoint:bounds.origin];
 }
 
+static void horizontallyScrollToPage(PDFView *pdfView, PDFPage *page) {
+    NSScrollView *scrollView = [pdfView embeddedScrollView];
+    NSRect pageRect = [pdfView convertRect:[page boundsForBox:[pdfView 
displayBox]] fromPage:page];
+    CGFloat midX = NSMidX([pdfView bounds]);
+    if (NSMinX(pageRect) <= midX && NSMaxX(pageRect) >= midX)
+        return;
+    NSClipView *clipView = [scrollView contentView];
+    NSRect bounds = [clipView bounds];
+    NSRect docRect = [[scrollView documentView] frame];
+    if (NSWidth(bounds) >= NSWidth(docRect))
+        return;
+    CGFloat margin = 0.0;
+    if ([pdfView displaysPageBreaks])
+        margin = [pdfView pageBreakMargins].left;
+    pageRect = [pdfView convertRect:pageRect toView:clipView];
+    bounds.origin.x = fmin(NSMinX(pageRect) - margin, NSMaxX(docRect) - 
NSWidth(bounds));
+    [clipView scrollPoint:bounds.origin];
+}
+
 static void verticallyScrollToTop(PDFView *pdfView) {
     NSScrollView *scrollView = [pdfView embeddedScrollView];
     NSClipView *clipView = [scrollView contentView];
@@ -372,6 +391,8 @@
         [self goToPage:page];
         if (hasVerticalLayout(self))
             verticallyScrollToPage(self, page);
+        if (([self displayMode] & kPDFDisplayTwoUp) != 0)
+            horizontallyScrollToPage(self, page);
    }
 }
 

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