Revision: 10215
http://sourceforge.net/p/skim-app/code/10215
Author: hofman
Date: 2019-01-07 19:48:24 +0000 (Mon, 07 Jan 2019)
Log Message:
-----------
cache all active indicator images, use size as key
Modified Paths:
--------------
trunk/SKAnnotationTypeImageCell.h
trunk/SKAnnotationTypeImageCell.m
Modified: trunk/SKAnnotationTypeImageCell.h
===================================================================
--- trunk/SKAnnotationTypeImageCell.h 2019-01-07 19:16:44 UTC (rev 10214)
+++ trunk/SKAnnotationTypeImageCell.h 2019-01-07 19:48:24 UTC (rev 10215)
@@ -44,6 +44,5 @@
@interface SKAnnotationTypeImageCell : NSImageCell {
NSString *type;
BOOL active;
- NSImage *activeImage;
}
@end
Modified: trunk/SKAnnotationTypeImageCell.m
===================================================================
--- trunk/SKAnnotationTypeImageCell.m 2019-01-07 19:16:44 UTC (rev 10214)
+++ trunk/SKAnnotationTypeImageCell.m 2019-01-07 19:48:24 UTC (rev 10215)
@@ -48,11 +48,17 @@
@implementation SKAnnotationTypeImageCell
+static NSMutableDictionary *activeImages;
+
++ (void)initialize {
+ SKINITIALIZE;
+ activeImages = [[NSMutableDictionary alloc] init];
+}
+
- (id)copyWithZone:(NSZone *)aZone {
SKAnnotationTypeImageCell *copy = [super copyWithZone:aZone];
copy->type = [type retain];
copy->active = active;
- copy->activeImage = [activeImage retain];
return copy;
}
@@ -73,7 +79,6 @@
- (void)dealloc {
SKDESTROY(type);
- SKDESTROY(activeImage);
[super dealloc];
}
@@ -118,17 +123,19 @@
if (active) {
NSSize size = cellFrame.size;
size.height = fmin(size.width, size.height);
- if (activeImage == nil || NSEqualSizes([activeImage size], size) ==
NO) {
- SKDESTROY(activeImage);
- activeImage = [[NSImage alloc] initWithSize:size];
- [activeImage lockFocus];
+ NSString *sizeKey = NSStringFromSize(size);
+ image = [activeImages objectForKey:sizeKey];
+ if (image == nil) {
+ 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)];
- [activeImage unlockFocus];
- [activeImage setTemplate:YES];
+ [image unlockFocus];
+ [image setTemplate:YES];
+ [activeImages setObject:image forKey:sizeKey];
}
- [super setObjectValue:activeImage];
+ [super setObjectValue:image];
[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