Revision: 14357
          http://sourceforge.net/p/skim-app/code/14357
Author:   hofman
Date:     2024-07-01 09:17:46 +0000 (Mon, 01 Jul 2024)
Log Message:
-----------
rename selection highlight methods to avoid confusion between lineWidth and 
unitWidth

Modified Paths:
--------------
    trunk/PDFAnnotationInk_SKExtensions.m
    trunk/PDFAnnotationLine_SKExtensions.m
    trunk/PDFAnnotationMarkup_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/SKPDFView.m

Modified: trunk/PDFAnnotationInk_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationInk_SKExtensions.m       2024-07-01 08:43:28 UTC (rev 
14356)
+++ trunk/PDFAnnotationInk_SKExtensions.m       2024-07-01 09:17:46 UTC (rev 
14357)
@@ -176,9 +176,9 @@
     return NSUnionRect([super displayRectForBounds:bounds 
lineWidth:lineWidth], NSIntegralRect(rect));
 }
 
-- (void)drawShadowWithLineWidth:(CGFloat)lineWidth 
inContext:(CGContextRef)context {
+- (void)drawShadowWithUnitWidth:(CGFloat)unitWidth 
inContext:(CGContextRef)context {
     NSRect bounds = [self bounds];
-    CGFloat r = fmin(2.0, 2.0 * lineWidth);
+    CGFloat r = fmin(2.0, 2.0 * unitWidth);
     CGRect rect = NSRectToCGRect(NSInsetRect(bounds, 2.0 * r, 2.0 * r));
     CGAffineTransform t = CGAffineTransformConcat(CGContextGetCTM(context), 
CGAffineTransformInvert(CGContextGetBaseCTM_func(context)));
     r = fabs(CGSizeApplyAffineTransform(CGSizeMake(r, r), t).height);
@@ -216,8 +216,8 @@
     CGPathRelease(path);
 }
 
-- (void)drawFallbackShadowWithLineWidth:(CGFloat)lineWidth 
inContext:(CGContextRef)context {
-    CGFloat r = fmin(2.0 / lineWidth, 2.0);
+- (void)drawFallbackShadowWithUnitWidth:(CGFloat)unitWidth 
inContext:(CGContextRef)context {
+    CGFloat r = fmin(2.0 / unitWidth, 2.0);
     NSSize offset = NSZeroSize;
     switch ([[self page] rotation]) {
         case 0:   offset.height = -r; break;
@@ -227,13 +227,13 @@
         default:  offset.height = -r; break;
     }
     NSRect bounds = [self bounds];
-    NSRect rect = NSIntersectionRect(NSOffsetRect(NSInsetRect(bounds, -r * 
lineWidth, -r * lineWidth), offset.width * lineWidth, offset.height * 
lineWidth), NSRectFromCGRect(CGContextGetClipBoundingBox(context)));
+    NSRect rect = NSIntersectionRect(NSOffsetRect(NSInsetRect(bounds, -r * 
unitWidth, -r * unitWidth), offset.width * unitWidth, offset.height * 
unitWidth), NSRectFromCGRect(CGContextGetClipBoundingBox(context)));
     if (NSIsEmptyRect(rect) == NO) {
-        NSRect imgRect = NSMakeRect(0.0, 0.0, ceil(NSWidth(rect) / lineWidth), 
ceil(NSHeight(rect) / lineWidth));
-        rect.size = NSMakeSize(NSWidth(imgRect) * lineWidth, NSHeight(imgRect) 
* lineWidth);
+        NSRect imgRect = NSMakeRect(0.0, 0.0, ceil(NSWidth(rect) / unitWidth), 
ceil(NSHeight(rect) / unitWidth));
+        rect.size = NSMakeSize(NSWidth(imgRect) * unitWidth, NSHeight(imgRect) 
* unitWidth);
         NSImage *image = [NSImage imageWithSize:imgRect.size flipped:NO 
drawingHandler:^(NSRect dstRect){
             NSAffineTransform *transform = [NSAffineTransform transform];
-            [transform scaleBy:1.0 / lineWidth];
+            [transform scaleBy:1.0 / unitWidth];
             [transform translateXBy:NSMinX(bounds) - NSMinX(rect) 
yBy:NSMinY(bounds) - NSMinY(rect)];
             [transform concat];
             NSBezierPath *path = [NSBezierPath bezierPath];
@@ -262,14 +262,14 @@
     }
 }
 
-- (void)drawSelectionHighlightWithLineWidth:(CGFloat)lineWidth 
active:(BOOL)active inContext:(CGContextRef)context {
+- (void)drawSelectionHighlightWithUnitWidth:(CGFloat)unitWidth 
active:(BOOL)active inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]) == NO && [self isSkimNote]) {
         if (CGContextGetBaseCTM_func != NULL)
-            [self drawShadowWithLineWidth:lineWidth inContext:context];
+            [self drawShadowWithUnitWidth:unitWidth inContext:context];
         else
-            [self drawFallbackShadowWithLineWidth:lineWidth inContext:context];
+            [self drawFallbackShadowWithUnitWidth:unitWidth inContext:context];
     }
-    [super drawSelectionHighlightWithLineWidth:lineWidth active:active 
inContext:context];
+    [super drawSelectionHighlightWithUnitWidth:unitWidth active:active 
inContext:context];
 }
 
 - (NSString *)colorDefaultKey { return SKInkNoteColorKey; }

Modified: trunk/PDFAnnotationLine_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationLine_SKExtensions.m      2024-07-01 08:43:28 UTC (rev 
14356)
+++ trunk/PDFAnnotationLine_SKExtensions.m      2024-07-01 09:17:46 UTC (rev 
14357)
@@ -167,11 +167,11 @@
         return 0;
 }
 
-- (void)drawSelectionHighlightWithLineWidth:(CGFloat)lineWidth 
active:(BOOL)active inContext:(CGContextRef)context {
+- (void)drawSelectionHighlightWithUnitWidth:(CGFloat)unitWidth 
active:(BOOL)active inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     NSPoint origin = [self bounds].origin;
-    SKDrawResizeHandlePair(context, SKAddPoints(origin, [self startPoint]), 
SKAddPoints(origin, [self endPoint]), lineWidth, active);
+    SKDrawResizeHandlePair(context, SKAddPoints(origin, [self startPoint]), 
SKAddPoints(origin, [self endPoint]), unitWidth, active);
 }
 
 - (NSString *)colorDefaultKey { return SKLineNoteColorKey; }

Modified: trunk/PDFAnnotationMarkup_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationMarkup_SKExtensions.m    2024-07-01 08:43:28 UTC (rev 
14356)
+++ trunk/PDFAnnotationMarkup_SKExtensions.m    2024-07-01 09:17:46 UTC (rev 
14357)
@@ -230,7 +230,7 @@
     return bounds;
 }
 
-- (void)drawSelectionHighlightWithLineWidth:(CGFloat)lineWidth 
active:(BOOL)active inContext:(CGContextRef)context {
+- (void)drawSelectionHighlightWithUnitWidth:(CGFloat)unitWidth 
active:(BOOL)active inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     
@@ -240,10 +240,10 @@
     
     CGContextSaveGState(context);
     CGContextSetStrokeColorWithColor(context, color);
-    CGContextSetLineWidth(context, lineWidth);
+    CGContextSetLineWidth(context, unitWidth);
     for (i = 0; i < iMax; i++) {
         CGRect rect = CGContextConvertRectToUserSpace(context, 
CGRectIntegral(CGContextConvertRectToDeviceSpace(context, NSRectToCGRect([lines 
rectAtIndex:i]))));
-        CGContextStrokeRect(context, CGRectInset(rect, -0.5 * lineWidth, -0.5 
* lineWidth));
+        CGContextStrokeRect(context, CGRectInset(rect, -0.5 * unitWidth, -0.5 
* unitWidth));
     }
     CGContextRestoreGState(context);
 }

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2024-07-01 08:43:28 UTC (rev 14356)
+++ trunk/PDFAnnotation_SKExtensions.h  2024-07-01 09:17:46 UTC (rev 14357)
@@ -124,7 +124,7 @@
 
 - (SKRectEdges)resizeHandleForPoint:(NSPoint)point 
scaleFactor:(CGFloat)scaleFactor;
 
-- (void)drawSelectionHighlightWithLineWidth:(CGFloat)lineWidth 
active:(BOOL)active inContext:(CGContextRef)context;
+- (void)drawSelectionHighlightWithUnitWidth:(CGFloat)unitWidth 
active:(BOOL)active inContext:(CGContextRef)context;
 
 - (void)registerUserName;
 

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2024-07-01 08:43:28 UTC (rev 14356)
+++ trunk/PDFAnnotation_SKExtensions.m  2024-07-01 09:17:46 UTC (rev 14357)
@@ -493,7 +493,7 @@
     return [self isResizable] ? SKResizeHandleForPointFromRect(point, [self 
bounds], 4.0 / scaleFactor) : 0;
 }
 
-- (void)drawSelectionHighlightWithLineWidth:(CGFloat)lineWidth 
active:(BOOL)active inContext:(CGContextRef)context {
+- (void)drawSelectionHighlightWithUnitWidth:(CGFloat)unitWidth 
active:(BOOL)active inContext:(CGContextRef)context {
     if (NSIsEmptyRect([self bounds]))
         return;
     if ([self isSkimNote]) {
@@ -500,11 +500,11 @@
         CGRect rect = CGContextConvertRectToUserSpace(context, 
CGRectIntegral(CGContextConvertRectToDeviceSpace(context, NSRectToCGRect([self 
bounds]))));
         CGContextSaveGState(context);
         if ([self isResizable]) {
-            SKDrawResizeHandles(context, NSRectFromCGRect(rect), lineWidth, 
YES, active);
+            SKDrawResizeHandles(context, NSRectFromCGRect(rect), unitWidth, 
YES, active);
         } else {
             CGColorRef color = [[NSColor selectionHighlightColor:active] 
CGColor];
             CGContextSetStrokeColorWithColor(context, color);
-            CGContextStrokeRectWithWidth(context, CGRectInset(rect, -0.5 * 
lineWidth, -0.5 * lineWidth), lineWidth);
+            CGContextStrokeRectWithWidth(context, CGRectInset(rect, -0.5 * 
unitWidth, -0.5 * unitWidth), unitWidth);
         }
         CGContextRestoreGState(context);
     } else if ([self isLink]) {

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2024-07-01 08:43:28 UTC (rev 14356)
+++ trunk/SKPDFView.m   2024-07-01 09:17:46 UTC (rev 14357)
@@ -473,7 +473,7 @@
         }
         
         if ([[annotation page] isEqual:pdfPage])
-            [annotation drawSelectionHighlightWithLineWidth:[self 
unitWidthOnPage:pdfPage] active:[self drawsActiveSelections] inContext:context];
+            [annotation drawSelectionHighlightWithUnitWidth:[self 
unitWidthOnPage:pdfPage] active:[self drawsActiveSelections] inContext:context];
     }
     
     [self drawSelectionForPage:pdfPage inContext:context];
@@ -511,7 +511,7 @@
         CGContextTranslateCTM(context, offset.x, offset.y);
         CGContextScaleCTM(context, scaleFactor, scaleFactor);
         [page transformContext:context forBox:[self displayBox]];
-        [currentAnnotation drawSelectionHighlightWithLineWidth:1.0 / 
scaleFactor active:[self drawsActiveSelections] inContext:context];
+        [currentAnnotation drawSelectionHighlightWithUnitWidth:1.0 / 
scaleFactor active:[self drawsActiveSelections] inContext:context];
         CGContextRestoreGState(context);
     } else {
         CGRect rect = NSRectToCGRect([highlightLayerController rect]);

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