Revision: 14426
          http://sourceforge.net/p/skim-app/code/14426
Author:   hofman
Date:     2024-08-16 09:19:41 +0000 (Fri, 16 Aug 2024)
Log Message:
-----------
only draw custom cursors when they are needed, remember cursor colors

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

Modified: trunk/NSCursor_SKExtensions.m
===================================================================
--- trunk/NSCursor_SKExtensions.m       2024-08-16 08:53:51 UTC (rev 14425)
+++ trunk/NSCursor_SKExtensions.m       2024-08-16 09:19:41 UTC (rev 14426)
@@ -64,6 +64,9 @@
 @interface SKCustomCursors : NSObject {
     NSUserDefaults *universalaccessDefaults;
     NSMutableDictionary *customCursors;
+    NSColor *cursorOutline;
+    NSColor *cursorFill;
+    BOOL customizedColors;
 }
 
 @property(class, nonatomic, readonly) SKCustomCursors *sharedCustomCursors;
@@ -274,12 +277,12 @@
     if (customCursors == nil) {
         customCursors = [NSMutableDictionary dictionary];
         
-        BOOL isCustomized = NO;
-        NSColor *cursorOutline = [NSColor whiteColor];
-        NSColor *cursorFill = [NSColor blackColor];
+        customizedColors = NO;
+        cursorOutline = [NSColor whiteColor];
+        cursorFill = [NSColor blackColor];
         if (@available(macOS 12.0, *)) {
             if ([[self universalaccessDefaults] 
boolForKey:@"cursorIsCustomized"]) {
-                isCustomized = YES;
+                customizedColors = YES;
                 NSDictionary *outlineDict = [[self universalaccessDefaults] 
dictionaryForKey:@"cursorOutline"];
                 NSDictionary *fillDict = [[self universalaccessDefaults] 
dictionaryForKey:@"cursorfill"];
                 if ([outlineDict count] == 4 && [fillDict count] == 4) {
@@ -288,13 +291,15 @@
                 }
             }
         }
+    }
+    
+    NSCursor *cursor = [customCursors objectForKey:name];
+    
+    if (cursor == nil) {
+        NSImage *image = nil;
+        NSPoint hotspot = NSZeroPoint;
         
-        NSImage *image;
-        NSCursor *cursor;
-        NSPoint hotspot;
-        
-        if ([NSCursor 
respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)] == NO || 
[NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)]) 
{
-            hotspot = NSMakePoint(8.0, 8.0);
+        if ([name isEqualToString:@"resizeDiagonal45Cursor"]) {
             
             image = [[NSImage alloc] initPDFWithSize:NSMakeSize(16.0, 16.0) 
drawingHandler:^(NSRect dstRect){
                 [cursorOutline setFill];
@@ -345,9 +350,10 @@
                 [path closePath];
                 [path fill];
             }];
-            cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-            [customCursors setObject:cursor forKey:@"resizeDiagonal45Cursor"];
+            hotspot = NSMakePoint(8.0, 8.0);
             
+        } else if ([name isEqualToString:@"resizeDiagonal135Cursor"]) {
+            
             image = [[NSImage alloc] initPDFWithSize:NSMakeSize(16.0, 16.0) 
drawingHandler:^(NSRect dstRect){
                 [cursorOutline setFill];
                 NSBezierPath *path = [NSBezierPath bezierPath];
@@ -397,210 +403,219 @@
                 [path closePath];
                 [path fill];
             }];
-            cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-            [customCursors setObject:cursor forKey:@"resizeDiagonal135Cursor"];
-        }
-        
-        hotspot = NSMakePoint(8.0, 7.0);
-        
-        image = [[NSImage alloc] initPDFWithSize:NSMakeSize(20.0, 20.0) 
drawingHandler:^(NSRect dstRect){
-            [cursorOutline set];
-            NSBezierPath *path = [NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(1.0, 6.0, 14.0, 14.0)];
-            [path moveToPoint:NSMakePoint(16.5, 1.5)];
-            [path lineToPoint:NSMakePoint(19.5, 4.5)];
-            [path lineToPoint:NSMakePoint(14.0, 10.0)];
-            [path lineToPoint:NSMakePoint(11.0, 7.0)];
-            [path closePath];
-            [NSGraphicsContext saveGraphicsState];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
-            [path fill];
-            [NSGraphicsContext restoreGraphicsState];
-            [cursorFill setStroke];
-            path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(2.5, 7.5, 
11.0, 11.0)];
-            [path setLineWidth:1.0];
-            [path stroke];
-            path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(17.25, 3.75)];
-            [path lineToPoint:NSMakePoint(11.75, 9.25)];
-            [path setLineWidth:2.0];
-            [path stroke];
-            path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(5.0, 13.0)];
-            [path lineToPoint:NSMakePoint(11.0, 13.0)];
-            [path moveToPoint:NSMakePoint(8.0, 10.0)];
-            [path lineToPoint:NSMakePoint(8.0, 16.0)];
-            [path setLineWidth:2.0];
-            [path stroke];
-        }];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"zoomInCursor"];
-        
-        image = [[NSImage alloc] initPDFWithSize:NSMakeSize(20.0, 20.0) 
drawingHandler:^(NSRect dstRect){
-            [cursorOutline set];
-            NSBezierPath *path = [NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(1.0, 6.0, 14.0, 14.0)];
-            [path moveToPoint:NSMakePoint(16.5, 1.5)];
-            [path lineToPoint:NSMakePoint(19.5, 4.5)];
-            [path lineToPoint:NSMakePoint(14.0, 10.0)];
-            [path lineToPoint:NSMakePoint(11.0, 7.0)];
-            [path closePath];
-            [NSGraphicsContext saveGraphicsState];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
-            [path fill];
-            [NSGraphicsContext restoreGraphicsState];
-            [cursorFill setStroke];
-            path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(2.5, 7.5, 
11.0, 11.0)];
-            [path setLineWidth:1.0];
-            [path stroke];
-            path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(17.25, 3.75)];
-            [path lineToPoint:NSMakePoint(11.75, 9.25)];
-            [path setLineWidth:2.0];
-            [path stroke];
-            path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(5.0, 13.0)];
-            [path lineToPoint:NSMakePoint(11.0, 13.0)];
-            [path setLineWidth:2.0];
-            [path stroke];
-        }];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"zoomOutCursor"];
-        
-        hotspot = NSMakePoint(9.0, 7.0);
-        
-        image = [[NSImage alloc] initPDFWithSize:NSMakeSize(18.0, 15.0) 
drawingHandler:^(NSRect dstRect){
-            NSBezierPath *path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(14.0, 12.0)];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(13.0, 12.0) 
toPoint:NSMakePoint(12.5, 13.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(12.0, 14.0) 
toPoint:NSMakePoint(6.5, 14.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(6.0, 14.0) 
toPoint:NSMakePoint(5.5, 13.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(5.5, 12.0) 
toPoint:NSMakePoint(5.0, 12.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(1.0, 12.0) 
toPoint:NSMakePoint(1.0, 10.0) radius:3.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(1.0, 2.0) 
toPoint:NSMakePoint(4.0, 2.0) radius:3.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(17.0, 2.0) 
toPoint:NSMakePoint(17.0, 5.0) radius:3.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(17.0, 12.0) 
toPoint:NSMakePoint(11.0, 12.0) radius:3.0];
-            [path closePath];
-            [NSGraphicsContext saveGraphicsState];
-            [cursorOutline set];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
-            [path fill];
-            [NSGraphicsContext restoreGraphicsState];
-            [cursorFill set];
-            path = [NSBezierPath bezierPath];
-            [path moveToPoint:NSMakePoint(14.0, 11.0)];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(12.5, 11.0) 
toPoint:NSMakePoint(12.0, 12.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(11.5, 13.0) 
toPoint:NSMakePoint(6.0, 13.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(6.5, 13.0) 
toPoint:NSMakePoint(6.0, 12.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(5.5, 11.0) 
toPoint:NSMakePoint(4.0, 11.0) radius:1.5];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0, 11.0) 
toPoint:NSMakePoint(2.0, 9.0) radius:2.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0, 3.0) 
toPoint:NSMakePoint(4.0, 3.0) radius:2.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(16.0, 3.0) 
toPoint:NSMakePoint(16.0, 5.0) radius:2.0];
-            [path appendBezierPathWithArcFromPoint:NSMakePoint(16.0, 11.0) 
toPoint:NSMakePoint(14.0, 11.0) radius:2.0];
-            [path closePath];
-            [path appendBezierPathWithOvalInRect:NSMakeRect(6.0, 5.0, 6.0, 
6.0)];
-            [path appendBezierPathWithOvalInRect:NSMakeRect(7.5, 6.5, 3.0, 
3.0)];
-            [path setWindingRule:NSEvenOddWindingRule];
-            [path fill];
+            hotspot = NSMakePoint(8.0, 8.0);
+            
+        } else if ([name isEqualToString:@"zoomInCursor"]) {
 
-        }];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"cameraCursor"];
-        
-        hotspot = NSMakePoint(16.0, 16.0);
-        
-        image = [[NSImage alloc] initPDFWithSize:NSMakeSize(32.0, 32.0) 
drawingHandler:^(NSRect dstRect){
-            [cursorOutline setFill];
-            [NSGraphicsContext saveGraphicsState];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
-            [NSBezierPath fillRect:NSMakeRect(1.0, 13.0, 30.0, 6.0)];
-            [NSGraphicsContext restoreGraphicsState];
-            [cursorFill setFill];
-            [NSBezierPath fillRect:NSMakeRect(2.0, 14.0, 28.0, 4.0)];
-            NSBezierPath *path = [NSBezierPath openHandBezierPath];
-            [NSGraphicsContext saveGraphicsState];
-            [(isCustomized ? cursorFill : cursorOutline) setFill];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.5 blurRadius:1.0 
yOffset:-1.4];
-            [path fill];
-            [NSGraphicsContext restoreGraphicsState];
-            [path moveToPoint:NSMakePoint(19.5664, 11.2656)];
-            [path lineToPoint:NSMakePoint(19.5664, 14.7246)];
-            [path moveToPoint:NSMakePoint(17.5508, 11.2539)];
-            [path lineToPoint:NSMakePoint(17.5348, 14.727)];
-            [path moveToPoint:NSMakePoint(15.5547, 14.6953)];
-            [path lineToPoint:NSMakePoint(15.5758, 11.2691)];
-            [(isCustomized ? cursorOutline : cursorFill) setStroke];
-            [path setLineWidth:0.75];
-            [path stroke];
-        }];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"openHandBarCursor"];
-        
-        image = [[NSImage alloc] initPDFWithSize:NSMakeSize(32.0, 32.0) 
drawingHandler:^(NSRect dstRect){
-            [cursorOutline setFill];
-            [NSGraphicsContext saveGraphicsState];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
-            [NSBezierPath fillRect:NSMakeRect(1.0, 13.0, 30.0, 6.0)];
-            [NSGraphicsContext restoreGraphicsState];
-            [cursorFill setFill];
-            [NSBezierPath fillRect:NSMakeRect(2.0, 14.0, 28.0, 4.0)];
-            NSBezierPath *path = [NSBezierPath closedHandBezierPath];
-            [NSGraphicsContext saveGraphicsState];
-            [(isCustomized ? cursorFill : cursorOutline) setFill];
-            [NSShadow setShadowWithWhite:0.0 alpha:0.5 blurRadius:1.0 
yOffset:-1.4];
-            [path fill];
-            [NSGraphicsContext restoreGraphicsState];
-            [path moveToPoint:NSMakePoint(19.5664, 11.2656)];
-            [path lineToPoint:NSMakePoint(19.5664, 14.7246)];
-            [path moveToPoint:NSMakePoint(17.5508, 11.2539)];
-            [path lineToPoint:NSMakePoint(17.5348, 14.727)];
-            [path moveToPoint:NSMakePoint(15.5547, 14.6953)];
-            [path lineToPoint:NSMakePoint(15.5758, 11.2691)];
-            [(isCustomized ? cursorOutline : cursorFill) setStroke];
-            [path setLineWidth:0.75];
-            [path stroke];
-        }];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"closedHandBarCursor"];
-        
-        hotspot = NSMakePoint(4.0, 4.0);
+            image = [[NSImage alloc] initPDFWithSize:NSMakeSize(20.0, 20.0) 
drawingHandler:^(NSRect dstRect){
+                [cursorOutline set];
+                NSBezierPath *path = [NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(1.0, 6.0, 14.0, 14.0)];
+                [path moveToPoint:NSMakePoint(16.5, 1.5)];
+                [path lineToPoint:NSMakePoint(19.5, 4.5)];
+                [path lineToPoint:NSMakePoint(14.0, 10.0)];
+                [path lineToPoint:NSMakePoint(11.0, 7.0)];
+                [path closePath];
+                [NSGraphicsContext saveGraphicsState];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
+                [path fill];
+                [NSGraphicsContext restoreGraphicsState];
+                [cursorFill setStroke];
+                path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(2.5, 
7.5, 11.0, 11.0)];
+                [path setLineWidth:1.0];
+                [path stroke];
+                path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(17.25, 3.75)];
+                [path lineToPoint:NSMakePoint(11.75, 9.25)];
+                [path setLineWidth:2.0];
+                [path stroke];
+                path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(5.0, 13.0)];
+                [path lineToPoint:NSMakePoint(11.0, 13.0)];
+                [path moveToPoint:NSMakePoint(8.0, 10.0)];
+                [path lineToPoint:NSMakePoint(8.0, 16.0)];
+                [path setLineWidth:2.0];
+                [path stroke];
+            }];
+            hotspot = NSMakePoint(8.0, 7.0);
+            
+        } else if ([name isEqualToString:@"zoomOutCursor"]) {
+            
+            image = [[NSImage alloc] initPDFWithSize:NSMakeSize(20.0, 20.0) 
drawingHandler:^(NSRect dstRect){
+                [cursorOutline set];
+                NSBezierPath *path = [NSBezierPath 
bezierPathWithOvalInRect:NSMakeRect(1.0, 6.0, 14.0, 14.0)];
+                [path moveToPoint:NSMakePoint(16.5, 1.5)];
+                [path lineToPoint:NSMakePoint(19.5, 4.5)];
+                [path lineToPoint:NSMakePoint(14.0, 10.0)];
+                [path lineToPoint:NSMakePoint(11.0, 7.0)];
+                [path closePath];
+                [NSGraphicsContext saveGraphicsState];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
+                [path fill];
+                [NSGraphicsContext restoreGraphicsState];
+                [cursorFill setStroke];
+                path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(2.5, 
7.5, 11.0, 11.0)];
+                [path setLineWidth:1.0];
+                [path stroke];
+                path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(17.25, 3.75)];
+                [path lineToPoint:NSMakePoint(11.75, 9.25)];
+                [path setLineWidth:2.0];
+                [path stroke];
+                path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(5.0, 13.0)];
+                [path lineToPoint:NSMakePoint(11.0, 13.0)];
+                [path setLineWidth:2.0];
+                [path stroke];
+            }];
+            hotspot = NSMakePoint(8.0, 7.0);
+            
+        } else if ([name isEqualToString:@"cameraCursor"]) {
+            
+            image = [[NSImage alloc] initPDFWithSize:NSMakeSize(18.0, 15.0) 
drawingHandler:^(NSRect dstRect){
+                NSBezierPath *path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(14.0, 12.0)];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(13.0, 12.0) 
toPoint:NSMakePoint(12.5, 13.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(12.0, 14.0) 
toPoint:NSMakePoint(6.5, 14.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(6.0, 14.0) 
toPoint:NSMakePoint(5.5, 13.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(5.5, 12.0) 
toPoint:NSMakePoint(5.0, 12.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(1.0, 12.0) 
toPoint:NSMakePoint(1.0, 10.0) radius:3.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(1.0, 2.0) 
toPoint:NSMakePoint(4.0, 2.0) radius:3.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(17.0, 2.0) 
toPoint:NSMakePoint(17.0, 5.0) radius:3.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(17.0, 12.0) 
toPoint:NSMakePoint(11.0, 12.0) radius:3.0];
+                [path closePath];
+                [NSGraphicsContext saveGraphicsState];
+                [cursorOutline set];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
+                [path fill];
+                [NSGraphicsContext restoreGraphicsState];
+                [cursorFill set];
+                path = [NSBezierPath bezierPath];
+                [path moveToPoint:NSMakePoint(14.0, 11.0)];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(12.5, 11.0) 
toPoint:NSMakePoint(12.0, 12.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(11.5, 13.0) 
toPoint:NSMakePoint(6.0, 13.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(6.5, 13.0) 
toPoint:NSMakePoint(6.0, 12.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(5.5, 11.0) 
toPoint:NSMakePoint(4.0, 11.0) radius:1.5];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0, 11.0) 
toPoint:NSMakePoint(2.0, 9.0) radius:2.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0, 3.0) 
toPoint:NSMakePoint(4.0, 3.0) radius:2.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(16.0, 3.0) 
toPoint:NSMakePoint(16.0, 5.0) radius:2.0];
+                [path appendBezierPathWithArcFromPoint:NSMakePoint(16.0, 11.0) 
toPoint:NSMakePoint(14.0, 11.0) radius:2.0];
+                [path closePath];
+                [path appendBezierPathWithOvalInRect:NSMakeRect(6.0, 5.0, 6.0, 
6.0)];
+                [path appendBezierPathWithOvalInRect:NSMakeRect(7.5, 6.5, 3.0, 
3.0)];
+                [path setWindingRule:NSEvenOddWindingRule];
+                [path fill];
 
-        image = [NSImage cursorTextNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
+            }];
+            hotspot = NSMakePoint(9.0, 7.0);
+            
+        } else if ([name isEqualToString:@"openHandBarCursor"]) {
+            
+            image = [[NSImage alloc] initPDFWithSize:NSMakeSize(32.0, 32.0) 
drawingHandler:^(NSRect dstRect){
+                [cursorOutline setFill];
+                [NSGraphicsContext saveGraphicsState];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
+                [NSBezierPath fillRect:NSMakeRect(1.0, 13.0, 30.0, 6.0)];
+                [NSGraphicsContext restoreGraphicsState];
+                [cursorFill setFill];
+                [NSBezierPath fillRect:NSMakeRect(2.0, 14.0, 28.0, 4.0)];
+                NSBezierPath *path = [NSBezierPath openHandBezierPath];
+                [NSGraphicsContext saveGraphicsState];
+                [(customizedColors ? cursorFill : cursorOutline) setFill];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.5 blurRadius:1.0 
yOffset:-1.4];
+                [path fill];
+                [NSGraphicsContext restoreGraphicsState];
+                [path moveToPoint:NSMakePoint(19.5664, 11.2656)];
+                [path lineToPoint:NSMakePoint(19.5664, 14.7246)];
+                [path moveToPoint:NSMakePoint(17.5508, 11.2539)];
+                [path lineToPoint:NSMakePoint(17.5348, 14.727)];
+                [path moveToPoint:NSMakePoint(15.5547, 14.6953)];
+                [path lineToPoint:NSMakePoint(15.5758, 11.2691)];
+                [(customizedColors ? cursorOutline : cursorFill) setStroke];
+                [path setLineWidth:0.75];
+                [path stroke];
+            }];
+            hotspot = NSMakePoint(16.0, 16.0);
+            
+        } else if ([name isEqualToString:@"closedHandBarCursor"]) {
+            
+            image = [[NSImage alloc] initPDFWithSize:NSMakeSize(32.0, 32.0) 
drawingHandler:^(NSRect dstRect){
+                [cursorOutline setFill];
+                [NSGraphicsContext saveGraphicsState];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.33333 blurRadius:1.0 
yOffset:-1.0];
+                [NSBezierPath fillRect:NSMakeRect(1.0, 13.0, 30.0, 6.0)];
+                [NSGraphicsContext restoreGraphicsState];
+                [cursorFill setFill];
+                [NSBezierPath fillRect:NSMakeRect(2.0, 14.0, 28.0, 4.0)];
+                NSBezierPath *path = [NSBezierPath closedHandBezierPath];
+                [NSGraphicsContext saveGraphicsState];
+                [(customizedColors ? cursorFill : cursorOutline) setFill];
+                [NSShadow setShadowWithWhite:0.0 alpha:0.5 blurRadius:1.0 
yOffset:-1.4];
+                [path fill];
+                [NSGraphicsContext restoreGraphicsState];
+                [path moveToPoint:NSMakePoint(19.5664, 11.2656)];
+                [path lineToPoint:NSMakePoint(19.5664, 14.7246)];
+                [path moveToPoint:NSMakePoint(17.5508, 11.2539)];
+                [path lineToPoint:NSMakePoint(17.5348, 14.727)];
+                [path moveToPoint:NSMakePoint(15.5547, 14.6953)];
+                [path lineToPoint:NSMakePoint(15.5758, 11.2691)];
+                [(customizedColors ? cursorOutline : cursorFill) setStroke];
+                [path setLineWidth:0.75];
+                [path stroke];
+            }];
+            hotspot = NSMakePoint(16.0, 16.0);
+            
+        } else if ([name isEqualToString:@"textNoteCursor"]) {
+            
+            image = [NSImage cursorTextNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"anchoredNoteCursor"]) {
+            
+            image = [NSImage 
cursorAnchoredNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"circleNoteCursor"]) {
+            
+            image = [NSImage 
cursorCircleNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"squareNoteCursor"]) {
+            
+            image = [NSImage 
cursorSquareNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"highlightNoteCursor"]) {
+            
+            image = [NSImage 
cursorHighlightNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"underlineNoteCursor"]) {
+            
+            image = [NSImage 
cursorUnderlineNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"strikeOutNoteCursor"]) {
+            
+            image = [NSImage 
cursorStrikeOutNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"lineNoteCursor"]) {
+            
+            image = [NSImage cursorLineNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        } else if ([name isEqualToString:@"inkNoteCursor"]) {
+            
+            image = [NSImage cursorInkNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
+            hotspot = NSMakePoint(4.0, 4.0);
+            
+        }
+            
         cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"textNoteCursor"];
-        
-        image = [NSImage cursorAnchoredNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"anchoredNoteCursor"];
-        
-        image = [NSImage cursorCircleNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"circleNoteCursor"];
-        
-        image = [NSImage cursorSquareNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"squareNoteCursor"];
-        
-        image = [NSImage 
cursorHighlightNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"highlightNoteCursor"];
-        
-        image = [NSImage 
cursorUnderlineNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"underlineNoteCursor"];
-        
-        image = [NSImage 
cursorStrikeOutNoteImageWithOutlineColor:cursorOutline fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"strikeOutNoteCursor"];
-        
-        image = [NSImage cursorLineNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"lineNoteCursor"];
-        
-        image = [NSImage cursorInkNoteImageWithOutlineColor:cursorOutline 
fillColor:cursorFill];
-        cursor = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
-        [customCursors setObject:cursor forKey:@"inkNoteCursor"];
+        [customCursors setObject:cursor forKey:name];
     }
     
-    return [customCursors objectForKey:name];
+    return cursor ?: [NSCursor arrowCursor];
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)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