Revision: 15210
http://sourceforge.net/p/skim-app/code/15210
Author: hofman
Date: 2025-05-14 16:30:26 +0000 (Wed, 14 May 2025)
Log Message:
-----------
Draw placeholder thumbnail for snapshot from configuration, generate
placeholder whenever tthumbnail of snapshot is nil when updating.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKSnapshotConfiguration.h
trunk/SKSnapshotConfiguration.m
trunk/SKSnapshotWindowController.h
trunk/SKSnapshotWindowController.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2025-05-14 15:58:06 UTC (rev 15209)
+++ trunk/SKMainWindowController.m 2025-05-14 16:30:26 UTC (rev 15210)
@@ -2361,8 +2361,6 @@
if (openType == SKSnapshotOpenPreview)
return;
- NSImage *image = [controller
placeholderThumbnailWithSize:snapshotCacheSize scale:[[self window]
backingScaleFactor]];
- [controller setThumbnail:image];
[self snapshotNeedsUpdate:controller lowPriority:openType ==
SKSnapshotOpenFromSetup];
if (openType == SKSnapshotOpenFromSetup) {
@@ -3073,6 +3071,9 @@
NSDate *date = [NSDate date];
dispatch_queue_t queue;
+ if ([controller thumbnail] == nil)
+ [controller setThumbnail:[configuration
placeholderThumbnailWithSize:snapshotCacheSize scale:backingScale]];
+
if ([rightSideController.snapshotTableView window] == nil || [self
leftSidePaneIsOpen] == NO)
queue = [[self class] backgroundThumbnailQueue];
else if (lowPriority)
Modified: trunk/SKSnapshotConfiguration.h
===================================================================
--- trunk/SKSnapshotConfiguration.h 2025-05-14 15:58:06 UTC (rev 15209)
+++ trunk/SKSnapshotConfiguration.h 2025-05-14 16:30:26 UTC (rev 15210)
@@ -52,6 +52,7 @@
- (instancetype)initWithPDFView:(PDFView *)pdfView;
- (NSImage *)thumbnailWithSize:(CGFloat)aSize scale:(CGFloat)scale;
+- (NSImage *)placeholderThumbnailWithSize:(CGFloat)aSize scale:(CGFloat)scale;
- (NSBitmapImageRep *)bitmapImageRepWithSize:(CGFloat)aSize
scale:(CGFloat)scale;
@end
Modified: trunk/SKSnapshotConfiguration.m
===================================================================
--- trunk/SKSnapshotConfiguration.m 2025-05-14 15:58:06 UTC (rev 15209)
+++ trunk/SKSnapshotConfiguration.m 2025-05-14 16:30:26 UTC (rev 15210)
@@ -65,7 +65,7 @@
return self;
}
-- (NSBitmapImageRep *)bitmapImageRepWithSize:(CGFloat)aSize
scale:(CGFloat)scale {
+- (NSBitmapImageRep *)bitmapImageRepWithSize:(CGFloat)aSize
scale:(CGFloat)scale placeholder:(BOOL)placeholder {
NSAffineTransform *transform = [NSAffineTransform transform];
NSSize thumbnailSize = size;
CGFloat shadowBlurRadius = 0.0;
@@ -94,19 +94,22 @@
if (shadowBlurRadius > 0.0)
[NSShadow setShadowWithWhite:0.0 alpha:0.3
blurRadius:shadowBlurRadius yOffset:shadowOffset];
NSRectFill((NSRect){NSZeroPoint, size});
- [[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationDefault];
- [NSGraphicsContext restoreGraphicsState];
- [[NSBezierPath bezierPathWithRect:(NSRect){NSZeroPoint, size}]
addClip];
- CGContextRef context = [[NSGraphicsContext currentContext] CGContext];
- CGContextSetInterpolationQuality(context, interpolationQuality + 1);
- for (PDFDestination *dest in pages) {
- NSPoint point = [dest point];
- CGContextSaveGState(context);
- CGContextTranslateCTM(context, point.x, point.y);
- CGContextScaleCTM(context, scaleFactor, scaleFactor);
- [[dest page] drawWithBox:displayBox toContext:context];
- CGContextRestoreGState(context);
+ if (placeholder == NO) {
+ [[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationDefault];
+ [NSGraphicsContext restoreGraphicsState];
+ [[NSBezierPath bezierPathWithRect:(NSRect){NSZeroPoint, size}]
addClip];
+
+ CGContextRef context = [[NSGraphicsContext currentContext]
CGContext];
+ CGContextSetInterpolationQuality(context, interpolationQuality +
1);
+ for (PDFDestination *dest in pages) {
+ NSPoint point = [dest point];
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, point.x, point.y);
+ CGContextScaleCTM(context, scaleFactor, scaleFactor);
+ [[dest page] drawWithBox:displayBox toContext:context];
+ CGContextRestoreGState(context);
+ }
}
}];
@@ -114,6 +117,10 @@
return imageRep;
}
+- (NSBitmapImageRep *)bitmapImageRepWithSize:(CGFloat)aSize
scale:(CGFloat)scale {
+ return [self bitmapImageRepWithSize:aSize scale:scale placeholder:NO];
+}
+
- (NSImage *)thumbnailWithSize:(CGFloat)aSize scale:(CGFloat)scale {
NSBitmapImageRep *imageRep = [self bitmapImageRepWithSize:aSize
scale:scale];
NSImage *image = [[NSImage alloc] initWithSize:[imageRep size]];
@@ -121,4 +128,11 @@
return image;
}
+- (NSImage *)placeholderThumbnailWithSize:(CGFloat)aSize scale:(CGFloat)scale {
+ NSBitmapImageRep *imageRep = [self bitmapImageRepWithSize:aSize
scale:scale placeholder:YES];
+ NSImage *image = [[NSImage alloc] initWithSize:[imageRep size]];
+ [image addRepresentation:imageRep];
+ return image;
+}
+
@end
Modified: trunk/SKSnapshotWindowController.h
===================================================================
--- trunk/SKSnapshotWindowController.h 2025-05-14 15:58:06 UTC (rev 15209)
+++ trunk/SKSnapshotWindowController.h 2025-05-14 16:30:26 UTC (rev 15210)
@@ -87,8 +87,6 @@
- (void)updatePageLabel;
-- (NSImage *)placeholderThumbnailWithSize:(CGFloat)size scale:(CGFloat)scale;
-
- (NSAttributedString *)thumbnailAttachmentWithSize:(CGFloat)size;
- (void)miniaturize;
Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m 2025-05-14 15:58:06 UTC (rev 15209)
+++ trunk/SKSnapshotWindowController.m 2025-05-14 16:30:26 UTC (rev 15210)
@@ -484,14 +484,6 @@
#pragma mark Thumbnails
-- (NSImage *)placeholderThumbnailWithSize:(CGFloat)size scale:(CGFloat)scale {
- PDFPage *page = [[PDFPage alloc] init];
- NSRect bounds = [pdfView visibleContentRect];
- bounds.origin = NSZeroPoint;
- [page setBounds:bounds forBox:kPDFDisplayBoxMediaBox];
- return [page thumbnailWithSize:size scale:scale
forBox:kPDFDisplayBoxMediaBox hasShadow:YES highlights:nil];
-}
-
- (NSAttributedString *)thumbnailAttachmentWithSize:(CGFloat)size {
SKSnapshotConfiguration *configuration = [self currentConfiguration];
NSBitmapImageRep *imageRep1 = [configuration bitmapImageRepWithSize:size
scale:1.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