Revision: 15990
          http://sourceforge.net/p/skim-app/code/15990
Author:   hofman
Date:     2026-01-09 17:23:31 +0000 (Fri, 09 Jan 2026)
Log Message:
-----------
set highlight annotation in layer controller, no need for setter

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

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2026-01-09 16:59:13 UTC (rev 15989)
+++ trunk/SKPDFView.h   2026-01-09 17:23:31 UTC (rev 15990)
@@ -150,7 +150,6 @@
     SKTypeSelectHelper *typeSelectHelper;
     
        PDFAnnotation *currentAnnotation;
-       PDFAnnotation *highlightAnnotation;
     
     SKTextNoteEditor *editor;
     

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2026-01-09 16:59:13 UTC (rev 15989)
+++ trunk/SKPDFView.m   2026-01-09 17:23:31 UTC (rev 15990)
@@ -173,11 +173,13 @@
     __weak id<SKLayerDelegate> delegate;
     NSRect rect;
     NSInteger type;
+    PDFAnnotation *annotation;
 }
 @property (nonatomic, strong) CALayer *layer;
 @property (nonatomic, weak) id<SKLayerDelegate> delegate;
 @property (nonatomic) NSRect rect;
 @property (nonatomic) NSInteger type;
+@property (nonatomic, strong) PDFAnnotation *annotation;
 @end
 
 #pragma mark -
@@ -847,21 +849,6 @@
     return loupeController ? [loupeController magnification] : 0.0;
 }
 
-- (void)setHighlightAnnotation:(PDFAnnotation *)annotation {
-    if (annotation != highlightAnnotation) {
-        highlightAnnotation = annotation;
-        if (highlightAnnotation) {
-            if (highlightLayerController == nil)
-                [self makeHighlightLayerForType:SKLayerTypeRect];
-            
-            NSRect rect = [self convertRect:[highlightAnnotation bounds] 
fromPage:[highlightAnnotation page]];
-            [highlightLayerController setRect:NSInsetRect(rect, -1.0, -1.0)];
-        } else if (highlightLayerController) {
-            [self removeHighlightLayer];
-        }
-    }
-}
-
 - (NSUndoManager *)undoManager {
     NSUndoManager *undoManager = nil;
     if ([[self delegate] respondsToSelector:@selector(undoManagerForPDFView:)])
@@ -2141,7 +2128,12 @@
             for (PDFAnnotation *annotation in [[page annotations] 
reverseObjectEnumerator]) {
                 if ([annotation hitTest:location] &&
                     ([pboard 
canReadItemWithDataConformingToTypes:@[NSPasteboardTypeColor]] || [annotation 
hasBorder])) {
-                    [self setHighlightAnnotation:annotation];
+                    if (annotation != [highlightLayerController annotation]) {
+                        if (highlightLayerController == nil)
+                            [self makeHighlightLayerForType:SKLayerTypeRect];
+                        [highlightLayerController setAnnotation:annotation];
+                        [highlightLayerController setRect:NSInsetRect([self 
convertRect:[annotation bounds] fromPage:[annotation page]], -1.0, -1.0)];
+                    }
                     dragOp = NSDragOperationGeneric;
                     break;
                 }
@@ -2148,7 +2140,7 @@
             }
         }
         if (dragOp == NSDragOperationNone)
-            [self setHighlightAnnotation:nil];
+            [self removeHighlightLayer];
     } else if ([self hideNotes] == NO && [pboard 
canReadObjectForClasses:@[[NSURL class]] 
options:@{NSPasteboardURLReadingFileURLsOnlyKey:@YES, 
NSPasteboardURLReadingContentsConformToTypesKey:[NSImage imageTypes]}]) {
         if (([[sender draggingSource] respondsToSelector:@selector(window)] == 
NO || [[sender draggingSource] window] != [self window]) && [self 
pageForPoint:[self convertPoint:[sender draggingLocation] fromView:nil] 
nearest:NO])
             dragOp = NSDragOperationGeneric;
@@ -2161,7 +2153,7 @@
 - (void)draggingExited:(id <NSDraggingInfo>)sender {
     NSPasteboard *pboard = [sender draggingPasteboard];
     if ([self hideNotes] == NO && ([pboard 
canReadItemWithDataConformingToTypes:@[NSPasteboardTypeColor, 
SKPasteboardTypeLineStyle]] || [pboard canReadObjectForClasses:@[[NSURL class]] 
options:@{NSPasteboardURLReadingFileURLsOnlyKey:@YES, 
NSPasteboardURLReadingContentsConformToTypesKey:[NSImage imageTypes]}])) {
-        [self setHighlightAnnotation:nil];
+        [self removeHighlightLayer];
     } else if ([[SKPDFView superclass] instancesRespondToSelector:_cmd]) {
         [super draggingExited:sender];
     }
@@ -2171,30 +2163,31 @@
     BOOL performedDrag = NO;
     NSPasteboard *pboard = [sender draggingPasteboard];
     if ([self hideNotes] == NO && [pboard 
canReadItemWithDataConformingToTypes:@[NSPasteboardTypeColor, 
SKPasteboardTypeLineStyle]]) {
-        if (highlightAnnotation) {
+        PDFAnnotation *annotation = [highlightLayerController annotation];
+        if (annotation) {
             if ([pboard 
canReadItemWithDataConformingToTypes:@[NSPasteboardTypeColor]]) {
                 BOOL isShift = ([NSEvent modifierFlags] & 
NSEventModifierFlagShift) != 0;
                 BOOL isAlt = ([NSEvent modifierFlags] & 
NSEventModifierFlagOption) != 0;
-                [highlightAnnotation setColor:[NSColor 
colorFromPasteboard:pboard] alternate:isAlt updateDefaults:isShift];
+                [annotation setColor:[NSColor colorFromPasteboard:pboard] 
alternate:isAlt updateDefaults:isShift];
                 performedDrag = YES;
-            } else if ([highlightAnnotation hasBorder]) {
+            } else if ([annotation hasBorder]) {
                 [pboard types];
                 NSDictionary *dict = [pboard 
propertyListForType:SKPasteboardTypeLineStyle];
                 NSNumber *number;
                 if ((number = [dict objectForKey:SKLineWellLineWidthKey]))
-                    [highlightAnnotation setLineWidth:[number doubleValue]];
-                [highlightAnnotation setDashPattern:[dict 
objectForKey:SKLineWellDashPatternKey]];
+                    [annotation setLineWidth:[number doubleValue]];
+                [annotation setDashPattern:[dict 
objectForKey:SKLineWellDashPatternKey]];
                 if ((number = [dict objectForKey:SKLineWellStyleKey]))
-                    [highlightAnnotation setBorderStyle:[number integerValue]];
-                if ([highlightAnnotation isLine]) {
+                    [annotation setBorderStyle:[number integerValue]];
+                if ([annotation isLine]) {
                     if ((number = [dict 
objectForKey:SKLineWellStartLineStyleKey]))
-                        [highlightAnnotation setStartLineStyle:[number 
integerValue]];
+                        [annotation setStartLineStyle:[number integerValue]];
                     if ((number = [dict 
objectForKey:SKLineWellEndLineStyleKey]))
-                        [highlightAnnotation setEndLineStyle:[number 
integerValue]];
+                        [annotation setEndLineStyle:[number integerValue]];
                 }
                 performedDrag = YES;
             }
-            [self setHighlightAnnotation:nil];
+            [self removeHighlightLayer];
         }
     } else if ([self hideNotes] == NO && [pboard 
canReadObjectForClasses:@[[NSURL class]] 
options:@{NSPasteboardURLReadingFileURLsOnlyKey:@YES, 
NSPasteboardURLReadingContentsConformToTypesKey:[NSImage imageTypes]}]) {
         NSPoint location = [self convertPoint:[sender draggingLocation] 
fromView:nil];
@@ -5135,7 +5128,7 @@
 
 @implementation SKLayerController
 
-@synthesize layer, delegate, rect, type;
+@synthesize layer, delegate, rect, type, annotation;
 
 - (void)drawLayer:(CALayer *)aLayer inContext:(CGContextRef)context {
     [delegate drawLayerControllerInContext:context];

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