Revision: 13912
http://sourceforge.net/p/skim-app/code/13912
Author: hofman
Date: 2023-12-17 16:38:15 +0000 (Sun, 17 Dec 2023)
Log Message:
-----------
no need to keep our own viewLoaded ivar, no need to check whether object
responds to prepareForReuse
Modified Paths:
--------------
trunk/SKThumbnailItem.h
trunk/SKThumbnailItem.m
Modified: trunk/SKThumbnailItem.h
===================================================================
--- trunk/SKThumbnailItem.h 2023-12-17 15:48:57 UTC (rev 13911)
+++ trunk/SKThumbnailItem.h 2023-12-17 16:38:15 UTC (rev 13912)
@@ -41,7 +41,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface SKThumbnailItem : NSCollectionViewItem {
- BOOL viewLoaded;
NSBackgroundStyle backgroundStyle;
NSInteger highlightLevel;
BOOL marked;
Modified: trunk/SKThumbnailItem.m
===================================================================
--- trunk/SKThumbnailItem.m 2023-12-17 15:48:57 UTC (rev 13911)
+++ trunk/SKThumbnailItem.m 2023-12-17 16:38:15 UTC (rev 13912)
@@ -55,13 +55,13 @@
- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];
- if (viewLoaded)
+ if ([self isViewLoaded])
[(SKThumbnailView *)[self view] setThumbnail:[representedObject
isKindOfClass:[SKThumbnail class]] ? representedObject : nil];
}
- (void)setSelected:(BOOL)selected {
[super setSelected:selected];
- if (viewLoaded)
+ if ([self isViewLoaded])
[(SKThumbnailView *)[self view] setSelected:selected];
}
@@ -68,7 +68,7 @@
- (void)setBackgroundStyle:(NSBackgroundStyle)newBackgroundStyle {
if (backgroundStyle != newBackgroundStyle) {
backgroundStyle = newBackgroundStyle;
- if (viewLoaded)
+ if ([self isViewLoaded])
[(SKThumbnailView *)[self view]
setBackgroundStyle:newBackgroundStyle];
}
}
@@ -76,7 +76,7 @@
- (void)setHighlightLevel:(NSInteger)newHighlightLevel {
if (highlightLevel != newHighlightLevel) {
highlightLevel = newHighlightLevel;
- if (viewLoaded)
+ if ([self isViewLoaded])
[(SKThumbnailView *)[self view]
setHighlightLevel:newHighlightLevel];
}
}
@@ -84,31 +84,27 @@
- (void)setMarked:(BOOL)newMarked {
if (marked != newMarked) {
marked = newMarked;
- if (viewLoaded)
+ if ([self isViewLoaded])
[(SKThumbnailView *)[self view] setMarked:newMarked];
}
}
- (void)loadView {
- if (viewLoaded == NO) {
- NSRect rect = NSZeroRect;
- rect.size = [SKThumbnailView sizeForImageSize:NSMakeSize(32.0, 32.0)];
- SKThumbnailView *view = [[SKThumbnailView alloc] initWithFrame:rect];
- [view setController:self];
- if ([[self representedObject] isKindOfClass:[SKThumbnail class]])
- [view setThumbnail:[self representedObject]];
- [view setSelected:[self isSelected]];
- [view setBackgroundStyle:[self backgroundStyle]];
- [view setHighlightLevel:[self highlightLevel]];
- [view setMarked:[self isMarked]];
- [self setView:view];
- }
- viewLoaded = YES;
+ NSRect rect = NSZeroRect;
+ rect.size = [SKThumbnailView sizeForImageSize:NSMakeSize(32.0, 32.0)];
+ SKThumbnailView *view = [[SKThumbnailView alloc] initWithFrame:rect];
+ [view setController:self];
+ if ([[self representedObject] isKindOfClass:[SKThumbnail class]])
+ [view setThumbnail:[self representedObject]];
+ [view setSelected:[self isSelected]];
+ [view setBackgroundStyle:[self backgroundStyle]];
+ [view setHighlightLevel:[self highlightLevel]];
+ [view setMarked:[self isMarked]];
+ [self setView:view];
}
- (void)prepareForReuse {
- if ([[SKThumbnailItem superclass] instancesRespondToSelector:_cmd])
- [super prepareForReuse];
+ [super prepareForReuse];
[self setSelected:NO];
[self setBackgroundStyle:NSBackgroundStyleLight];
[self setHighlightLevel:0];
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