Revision: 12828
          http://sourceforge.net/p/skim-app/code/12828
Author:   hofman
Date:     2022-04-07 15:32:27 +0000 (Thu, 07 Apr 2022)
Log Message:
-----------
use separate method to go to a page in horizontal layout mode

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

Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m       2022-04-07 09:26:43 UTC (rev 12827)
+++ trunk/SKBasePDFView.m       2022-04-07 15:32:27 UTC (rev 12828)
@@ -256,13 +256,27 @@
     return RUNNING_AFTER(10_12) && [pdfView displayDirection] == 
kPDFDisplayDirectionHorizontal && [pdfView displayMode] == 
kPDFDisplaySinglePageContinuous;
 }
 
+- (void)horizontallyGoToPage:(PDFPage *)page {
+    NSClipView *clipView = [[self scrollView] contentView];
+    NSRect bounds = [page boundsForBox:[self displayBox]];
+    if ([self displaysPageBreaks]) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+        NSEdgeInsets margins = [self pageBreakMargins];
 #pragma clang diagnostic pop
+        bounds = NSInsetRect(bounds, -margins.left, ([page rotation] % 180) == 
0 ? -margins.bottom : -margins.left);
+    }
+    bounds = [self convertRect:[self convertRect:bounds fromPage:page] 
toView:clipView];
+    [clipView scrollToPoint:NSMakePoint(NSMinX(bounds), NSMinY([clipView 
bounds]))];
+}
 
+#pragma clang diagnostic pop
+
 - (void)goToPreviousPage:(id)sender {
     if (hasHorizontalLayout(self) && [self canGoToPreviousPage]) {
         PDFDocument *doc = [self document];
         PDFPage *page = [doc pageAtIndex:[doc indexForPage:[self currentPage]] 
- 1];
-        [self goToPage:page];
+        [self horizontallyGoToPage:page];
     } else {
         [super goToPreviousPage:sender];
     }
@@ -272,7 +286,7 @@
     if (hasHorizontalLayout(self) && [self canGoToNextPage]) {
         PDFDocument *doc = [self document];
         PDFPage *page = [doc pageAtIndex:[doc indexForPage:[self currentPage]] 
+ 1];
-        [self goToPage:page];
+        [self horizontallyGoToPage:page];
     } else {
         [super goToNextPage:sender];
     }
@@ -282,9 +296,9 @@
     if (hasHorizontalLayout(self) && [self canGoToFirstPage]) {
         PDFDocument *doc = [self document];
         PDFPage *page = [doc pageAtIndex:0];
-        [self goToPage:page];
+        [self horizontallyGoToPage:page];
     } else {
-        [super goToFirstPage:sender];
+        [super goToPage:sender];
     }
 }
 
@@ -292,7 +306,7 @@
     if (hasHorizontalLayout(self) && [self canGoToLastPage]) {
         PDFDocument *doc = [self document];
         PDFPage *page = [doc pageAtIndex:[doc pageCount] - 1];
-        [self goToPage:page];
+        [self horizontallyGoToPage:page];
     } else {
         [super goToLastPage:sender];
     }
@@ -299,21 +313,10 @@
 }
 
 - (void)goToPage:(PDFPage *)page {
-    if (hasHorizontalLayout(self)) {
-        NSClipView *clipView = [[self scrollView] contentView];
-        NSRect bounds = [page boundsForBox:[self displayBox]];
-        if ([self displaysPageBreaks]) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
-            NSEdgeInsets margins = [self pageBreakMargins];
-#pragma clang diagnostic pop
-            bounds = NSInsetRect(bounds, -margins.left, ([page rotation] % 
180) == 0 ? -margins.bottom : -margins.left);
-        }
-        bounds = [self convertRect:[self convertRect:bounds fromPage:page] 
toView:clipView];
-        [clipView scrollToPoint:NSMakePoint(NSMinX(bounds), NSMinY([clipView 
bounds]))];
-    } else {
+    if (hasHorizontalLayout(self))
+        [self horizontallyGoToPage:page];
+    else
         [super goToPage:page];
-    }
 }
 
 @end

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to