Revision: 16363
          http://sourceforge.net/p/skim-app/code/16363
Author:   hofman
Date:     2026-06-06 14:29:06 +0000 (Sat, 06 Jun 2026)
Log Message:
-----------
convenience method to get size from user defaults

Modified Paths:
--------------
    trunk/NSUserDefaults_SKExtensions.h
    trunk/NSUserDefaults_SKExtensions.m
    trunk/PDFPage_SKExtensions.m
    trunk/SKPDFView.m

Modified: trunk/NSUserDefaults_SKExtensions.h
===================================================================
--- trunk/NSUserDefaults_SKExtensions.h 2026-06-06 13:56:28 UTC (rev 16362)
+++ trunk/NSUserDefaults_SKExtensions.h 2026-06-06 14:29:06 UTC (rev 16363)
@@ -47,5 +47,7 @@
 
 - (nullable NSFont *)fontForNameKey:(NSString *)nameKey sizeKey:(NSString 
*)sizeKey;
 
+- (NSSize)sizeForWidthKey:(NSString *)widthKey heightKey:(NSString *)heightKey;
+
 @end
 NS_ASSUME_NONNULL_END

Modified: trunk/NSUserDefaults_SKExtensions.m
===================================================================
--- trunk/NSUserDefaults_SKExtensions.m 2026-06-06 13:56:28 UTC (rev 16362)
+++ trunk/NSUserDefaults_SKExtensions.m 2026-06-06 14:29:06 UTC (rev 16363)
@@ -85,4 +85,8 @@
     return fontName ? [NSFont fontWithName:fontName size:fontSize] : nil;
 }
 
+- (NSSize)sizeForWidthKey:(NSString *)widthKey heightKey:(NSString *)heightKey 
{
+    return NSMakeSize([self doubleForKey:widthKey], [self 
doubleForKey:heightKey]);
+}
+
 @end

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2026-06-06 13:56:28 UTC (rev 16362)
+++ trunk/PDFPage_SKExtensions.m        2026-06-06 14:29:06 UTC (rev 16363)
@@ -749,8 +749,7 @@
             }
         } else if (type && [[NSSet setWithObjects:SKNFreeTextString, 
SKNNoteString, SKNCircleString, SKNSquareString, SKNLineString, nil] 
containsObject:type]) {
             NSRect bounds = NSZeroRect;
-            bounds.size.width = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteWidthKey];
-            bounds.size.height = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteHeightKey];
+            bounds.size = [[NSUserDefaults standardUserDefaults] 
sizeForWidthKey:SKDefaultNoteWidthKey heightKey:SKDefaultNoteHeightKey];
             if ([type isEqualToString:SKNNoteString])
                 bounds.size = SKNPDFAnnotationNoteSize;
             bounds = 
NSIntegralRect(SKRectFromCenterAndSize(SKIntegralPoint(SKCenterPoint([self 
boundsForBox:kPDFDisplayBoxCropBox])), bounds.size));

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2026-06-06 13:56:28 UTC (rev 16362)
+++ trunk/SKPDFView.m   2026-06-06 14:29:06 UTC (rev 16363)
@@ -2470,8 +2470,7 @@
             CGFloat lw = [[NSUserDefaults standardUserDefaults] 
doubleForKey:SKSquareNoteLineWidthKey];
             bounds = NSInsetRect(bounds, -lw, -lw);
         } else if (annotationType == SKNoteTypeLine) {
-            CGFloat defaultWidth = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteWidthKey];
-            CGFloat defaultHeight = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteHeightKey];
+            NSSize defaultSize = [[NSUserDefaults standardUserDefaults] 
sizeForWidthKey:SKDefaultNoteWidthKey heightKey:SKDefaultNoteHeightKey];
             NSRect pageBounds = [page boundsForBox:[self displayBox]];
             NSPoint p1, p2;
             switch ([page intrinsicRotation]) {
@@ -2478,32 +2477,32 @@
                 case 0:
                     p2.x = floor(NSMinX(bounds));
                     p2.y = ceil(NSMidY(bounds));
-                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultWidth);
-                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultHeight);
+                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultSize.width);
+                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultSize.height);
                     break;
                 case 90:
                     p2.x = floor(NSMidX(bounds));
                     p2.y = floor(NSMinY(bounds));
-                    p1.x = fmin(NSMaxX(pageBounds), p2.x + defaultHeight);
-                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultWidth);
+                    p1.x = fmin(NSMaxX(pageBounds), p2.x + defaultSize.height);
+                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultSize.width);
                     break;
                 case 180:
                     p2.x = ceil(NSMaxX(bounds));
                     p2.y = floor(NSMidY(bounds));
-                    p1.x = fmin(NSMaxX(pageBounds), p2.x + defaultWidth);
-                    p1.y = fmin(NSMaxY(pageBounds), p2.y + defaultHeight);
+                    p1.x = fmin(NSMaxX(pageBounds), p2.x + defaultSize.width);
+                    p1.y = fmin(NSMaxY(pageBounds), p2.y + defaultSize.height);
                     break;
                 case 270:
                     p2.x = ceil(NSMidX(bounds));
                     p2.y = ceil(NSMaxY(bounds));
-                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultHeight);
-                    p1.y = fmin(NSMaxY(pageBounds), p2.y + defaultWidth);
+                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultSize.height);
+                    p1.y = fmin(NSMaxY(pageBounds), p2.y + defaultSize.width);
                     break;
                 default:
                     p2.x = floor(NSMinX(bounds));
                     p2.y = ceil(NSMidY(bounds));
-                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultWidth);
-                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultHeight);
+                    p1.x = fmax(NSMinX(pageBounds), p2.x - defaultSize.width);
+                    p1.y = fmax(NSMinY(pageBounds), p2.y - defaultSize.height);
                     break;
             }
             bounds = SKRectFromPoints(p1, p2);
@@ -2561,9 +2560,14 @@
             }
         }
         
-        CGFloat defaultWidth = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteWidthKey];
-        CGFloat defaultHeight = [[NSUserDefaults standardUserDefaults] 
floatForKey:SKDefaultNoteHeightKey];
-        NSSize defaultSize = (annotationType == SKNoteTypeAnchored) ? 
SKNPDFAnnotationNoteSize : ([page rotation] % 180 == 0) ? 
NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight, 
defaultWidth);
+        NSSize defaultSize;
+        if (annotationType == SKNoteTypeAnchored) {
+            defaultSize = SKNPDFAnnotationNoteSize;
+        } else {
+            defaultSize = [[NSUserDefaults standardUserDefaults] 
sizeForWidthKey:SKDefaultNoteWidthKey heightKey:SKDefaultNoteHeightKey];
+            if (([page rotation] % 180))
+                defaultSize = NSMakeSize(defaultSize.height, 
defaultSize.width);
+        }
         
         // Convert to "page space".
         point = SKIntegralPoint([self convertPoint:point toPage: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