Revision: 15768
          http://sourceforge.net/p/skim-app/code/15768
Author:   hofman
Date:     2025-11-07 17:51:19 +0000 (Fri, 07 Nov 2025)
Log Message:
-----------
calculate size ratio for dragged note once

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

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2025-11-07 16:28:12 UTC (rev 15767)
+++ trunk/SKPDFView.m   2025-11-07 17:51:19 UTC (rev 15768)
@@ -1802,7 +1802,7 @@
         if ((area & kPDFLinkArea))
             [super mouseDown:theEvent];
         else
-            [self doDragContentWithEvent:theEvent];    
+            [self doDragContentWithEvent:theEvent];
     } else if (toolMode == SKToolModeSelect) {
         [self setCurrentSelection:nil];                
         [self doSelectWithEvent:theEvent];
@@ -3883,7 +3883,7 @@
     }
 }
 
-- (void)dragAnnotationResizeHandle:(SKRectEdges)resizeHandle 
by:(NSPoint)relPoint originalBounds:(NSRect)originalBounds 
originalPaths:(NSArray *)originalPaths margin:(CGFloat)margin 
shiftDown:(BOOL)shiftDown {
+- (void)dragAnnotationResizeHandle:(SKRectEdges)resizeHandle 
by:(NSPoint)relPoint originalBounds:(NSRect)originalBounds 
originalPaths:(NSArray *)originalPaths margin:(CGFloat)margin 
sizeRatio:(CGFloat)ratio {
     PDFPage *page = [currentAnnotation page];
     NSRect newBounds = originalBounds;
     NSRect pageBounds = [page  boundsForBox:[self displayBox]];
@@ -3890,7 +3890,7 @@
     CGFloat minSize = fmax(MIN_NOTE_SIZE, 2.0 * margin + 2.0);
     BOOL isInk = [currentAnnotation isInk];
     
-    if (shiftDown == NO) {
+    if (ratio <= 0.0) {
         
         if ((resizeHandle & SKMaxXEdgeMask)) {
             newBounds.size.width += relPoint.x;
@@ -3934,11 +3934,6 @@
         CGFloat width = NSWidth(newBounds);
         CGFloat height = NSHeight(newBounds);
         CGFloat ds = 2.0 * margin;
-        CGFloat ratio = isInk ? fmax(1.0, NSWidth(originalBounds) - ds) / 
fmax(1.0, NSHeight(originalBounds) - ds) : 1.0;
-        if ([currentAnnotation isNote] && [(SKNPDFAnnotationNote 
*)currentAnnotation drawsImage] && [currentAnnotation image]) {
-            NSSize size = [[currentAnnotation image] size];
-            ratio = size.width / size.height;
-        }
         
         if ((resizeHandle & SKMaxXEdgeMask))
             width = fmax(minSize, width + relPoint.x);
@@ -4007,7 +4002,7 @@
         CGFloat sy = fmax(1.0, NSHeight(newBounds) - 2.0 * margin) / fmax(1.0, 
NSHeight(originalBounds) - 2.0 * margin);
         
         [transform translateXBy:margin yBy:margin];
-        if (shiftDown)
+        if (ratio > 0.0)
             [transform scaleBy:fmin(sx, sy)];
         else
             [transform scaleXBy:sx yBy:sy];
@@ -4037,6 +4032,7 @@
     NSPoint originalEndPoint = NSZeroPoint;
     NSArray *originalPaths = nil;
     CGFloat margin = 0.0;
+    CGFloat ratio = 0.0;
     // Hit-test for resize box.
     SKRectEdges resizeHandle = [currentAnnotation 
resizeHandleForPoint:initialPoint scaleFactor:[self scaleFactor]];
     
@@ -4118,7 +4114,17 @@
                     [self 
setCursorForAreaOfInterest:SKAreaOfInterestForResizeHandle(resizeHandle, page)];
                 }
             }
-            [self dragAnnotationResizeHandle:resizeHandle by:draggedPoint 
originalBounds:originalBounds originalPaths:originalPaths margin:margin 
shiftDown:shiftDown];
+            if (shiftDown && ratio <= 0.0) {
+                if ([currentAnnotation isInk]) {
+                    ratio = fmax(1.0, NSWidth(originalBounds) - 2.0 * margin) 
/ fmax(1.0, NSHeight(originalBounds) - 2.0 * margin);
+                } else if ([currentAnnotation isNote] && 
[(SKNPDFAnnotationNote *)currentAnnotation drawsImage] && [currentAnnotation 
image]) {
+                    NSSize size = [[currentAnnotation image] size];
+                    ratio = size.width / size.height;
+                } else {
+                    ratio = 1.0;
+                }
+            }
+            [self dragAnnotationResizeHandle:resizeHandle by:draggedPoint 
originalBounds:originalBounds originalPaths:originalPaths margin:margin 
sizeRatio:shiftDown ? ratio : 0.0];
         }
         [[highlightLayerController layer] setNeedsDisplay];
     }

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