Revision: 10191
          http://sourceforge.net/p/skim-app/code/10191
Author:   hofman
Date:     2018-12-28 13:50:21 +0000 (Fri, 28 Dec 2018)
Log Message:
-----------
cache active note state image

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

Modified: trunk/SKAnnotationTypeImageCell.h
===================================================================
--- trunk/SKAnnotationTypeImageCell.h   2018-12-28 13:42:29 UTC (rev 10190)
+++ trunk/SKAnnotationTypeImageCell.h   2018-12-28 13:50:21 UTC (rev 10191)
@@ -44,5 +44,6 @@
 @interface SKAnnotationTypeImageCell : NSImageCell {
     NSString *type;
     BOOL active;
+    NSImage *activeImage;
 }
 @end

Modified: trunk/SKAnnotationTypeImageCell.m
===================================================================
--- trunk/SKAnnotationTypeImageCell.m   2018-12-28 13:42:29 UTC (rev 10190)
+++ trunk/SKAnnotationTypeImageCell.m   2018-12-28 13:50:21 UTC (rev 10191)
@@ -72,6 +72,7 @@
 
 - (void)dealloc {
     SKDESTROY(type);
+    SKDESTROY(activeImage);
     [super dealloc];
 }
 
@@ -116,14 +117,17 @@
     if (active) {
         NSSize size = cellFrame.size;
         size.height = fmin(size.width, size.height);
-        image = [[[NSImage alloc] initWithSize:size] autorelease];
-        [image lockFocus];
-        [[NSColor blackColor] setFill];
-        [NSBezierPath setDefaultLineWidth:1.0];
-        [NSBezierPath strokeRect:NSMakeRect(0.5, 1.5, size.width - 1.0, 
size.height - 2.0)];
-        [image unlockFocus];
-        [image setTemplate:YES];
-        [super setObjectValue:image];
+        if (activeImage == nil || NSEqualSizes([activeImage size], size) == 
NO) {
+            SKDESTROY(activeImage);
+            activeImage = [[[NSImage alloc] initWithSize:size] autorelease];
+            [activeImage lockFocus];
+            [[NSColor blackColor] setFill];
+            [NSBezierPath setDefaultLineWidth:1.0];
+            [NSBezierPath strokeRect:NSMakeRect(0.5, 1.5, size.width - 1.0, 
size.height - 2.0)];
+            [activeImage unlockFocus];
+            [activeImage setTemplate:YES];
+        }
+        [super setObjectValue:activeImage];
         [super drawWithFrame:cellFrame inView:controlView];
     }
 }

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