Revision: 15944
          http://sourceforge.net/p/skim-app/code/15944
Author:   hofman
Date:     2026-01-02 10:48:09 +0000 (Fri, 02 Jan 2026)
Log Message:
-----------
fix zoom to rect for rotated pages

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

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2026-01-02 10:33:54 UTC (rev 15943)
+++ trunk/SKPDFView.m   2026-01-02 10:48:09 UTC (rev 15944)
@@ -3037,25 +3037,31 @@
     if (NSIsEmptyRect(rect) == NO) {
         NSScrollView *scrollView = [self scrollView];
         CGFloat scrollerWidth = [NSScroller effectiveScrollerWidth];
-        NSRect bounds = [self bounds];
+        NSSize size = [self bounds].size;
         CGFloat scale = 1.0;
-        bounds.size.width -= scrollerWidth;
-        bounds.size.height -= scrollerWidth + [scrollView contentInsets].top;
-        if (NSWidth(bounds) * NSHeight(rect) > NSWidth(rect) * 
NSHeight(bounds))
-            scale = NSHeight(bounds) / NSHeight(rect);
+        CGFloat width = NSWidth(rect);
+        CGFloat height = NSHeight(rect);
+        if (([page rotation] % 180)) {
+            width = NSHeight(rect);
+            height = NSHeight(rect);
+        }
+        size.width -= scrollerWidth;
+        size.height -= scrollerWidth + [scrollView contentInsets].top;
+        if (size.width * height > width * size.height)
+            scale = size.height / height;
         else
-            scale = NSWidth(bounds) / NSWidth(rect);
+            scale = size.width / width;
         [self setScaleFactor:scale];
         
         if (scrollerWidth > 0.0 && ([scrollView hasHorizontalScroller] == NO 
|| [scrollView hasVerticalScroller] == NO)) {
             if ([scrollView hasVerticalScroller] == NO)
-                bounds.size.width += scrollerWidth;
+                size.width += scrollerWidth;
             if ([scrollView hasHorizontalScroller] == NO)
-                bounds.size.height += scrollerWidth;
-            if (NSWidth(bounds) * NSHeight(rect) > NSWidth(rect) * 
NSHeight(bounds))
-                scale = NSHeight(bounds) / NSHeight(rect);
+                size.height += scrollerWidth;
+            if (size.width * height > width * size.height)
+                scale = size.height / height;
             else
-                scale = NSWidth(bounds) / NSWidth(rect);
+                scale = size.width / width;
             [self setScaleFactor:scale];
         }
         [self goToRect:rect onPage: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