Revision: 25433
http://sourceforge.net/p/bibdesk/svn/25433
Author: hofman
Date: 2021-01-18 15:56:01 +0000 (Mon, 18 Jan 2021)
Log Message:
-----------
Add full size, as better size for image icon. Initialize sizes for text icon to
zero, only return non zero default value from size accessor, the full size may
not be the default one if the attributed string has page size attributes.
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.h 2021-01-18
15:10:30 UTC (rev 25432)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.h 2021-01-18
15:56:01 UTC (rev 25433)
@@ -45,6 +45,7 @@
CGImageRef _thumbnail;
NSSize _thumbnailSize;
CGImageRef _fullImage;
+ NSSize _fullSize;
BOOL _loadFailed;
FVIcon *_fallbackIcon;
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m 2021-01-18
15:10:30 UTC (rev 25432)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVImageIcon.m 2021-01-18
15:56:01 UTC (rev 25433)
@@ -75,8 +75,9 @@
_fullImage = NULL;
_thumbnail = NULL;
+ _fullSize = NSZeroSize;
_thumbnailSize = NSZeroSize;
-
+
// QTMovie fails regularly, and I've also seen a few images that
ImageIO won't load; this avoids looping trying to render them
_fallbackIcon = nil;
_loadFailed = NO;
@@ -115,7 +116,14 @@
}
// only guaranteed to have _thumbnailSize; returning NSZeroSize causes
_drawingRectWithRect: to return garbage
-- (NSSize)size { return NSEqualSizes(_thumbnailSize, NSZeroSize) ?
FVDefaultThumbnailSize() : _thumbnailSize; }
+- (NSSize)size {
+ if (NO == NSEqualSizes(_fullSize, NSZeroSize))
+ return _fullSize;
+ else if (NO == NSEqualSizes(_thumbnailSize, NSZeroSize))
+ return _thumbnailSize;
+ else
+ return NSMakeSize(FVDefaultPaperWidth * FVDefaultScale,
FVDefaultPaperHeight * FVDefaultScale);
+}
- (BOOL)needsRenderForSize:(NSSize)size
{
@@ -192,6 +200,7 @@
if (FVShouldDrawFullImageWithThumbnailSize(size, _thumbnailSize)
&& NULL == _fullImage) {
_fullImage = [FVCGImageCache newImageForKey:_cacheKey];
if (_fullImage) {
+ _fullSize = FVCGImageSize(_fullImage);
[self unlock];
[[self class] _stopRenderingForKey:_cacheKey];
return;
@@ -231,6 +240,12 @@
sourceImage = NULL;
// always initialize sizes
+ if (_fullImage) {
+ _fullSize = FVCGImageSize(_fullImage);
+ }
+ else {
+ _fullSize = NSZeroSize;
+ }
if (_thumbnail) {
_thumbnailSize = FVCGImageSize(_thumbnail);
}
@@ -237,7 +252,7 @@
else {
_thumbnailSize = NSZeroSize;
}
-
+
// dispose of this immediately if we're not going to draw it; we can
read from the cache if it's needed later
if (FVShouldDrawFullImageWithThumbnailSize(size, _thumbnailSize) ==
NO) {
CGImageRelease(_fullImage);
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2021-01-18
15:10:30 UTC (rev 25432)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVTextIcon.m 2021-01-18
15:56:01 UTC (rev 25433)
@@ -77,10 +77,8 @@
{
self = [super initWithURL:aURL drawsLinkBadge:drawsLinkBadge];
if (self) {
- _fullSize = NSMakeSize(FVDefaultPaperWidth * FVDefaultScale,
FVDefaultPaperHeight * FVDefaultScale);
- _thumbnailSize = _fullSize;
- // first approximation
- FVIconLimitThumbnailSize(&_thumbnailSize);
+ _fullSize = NSZeroSize;
+ _thumbnailSize = NSZeroSize;
_fullImage = NULL;
_thumbnail = NULL;
_isPlainText = isPlainText;
@@ -100,7 +98,15 @@
[super dealloc];
}
-- (NSSize)size { return _fullSize; }
+// _fullSize can be NSZeroSize when only _thumbnail was retrieved from cache;
returning NSZeroSize causes _drawingRectWithRect: to return garbage
+- (NSSize)size {
+ if (NO == NSEqualSizes(_fullSize, NSZeroSize))
+ return _fullSize;
+ else if (NO == NSEqualSizes(_thumbnailSize, NSZeroSize))
+ return _thumbnailSize;
+ else
+ return NSMakeSize(FVDefaultPaperWidth * FVDefaultScale,
FVDefaultPaperHeight * FVDefaultScale);
+}
- (BOOL)needsRenderForSize:(NSSize)size {
BOOL needsRender = NO;
@@ -310,6 +316,7 @@
if (FVShouldDrawFullImageWithThumbnailSize(size, _thumbnailSize)) {
_fullImage = [FVCGImageCache newImageForKey:_cacheKey];
if (NULL != _fullImage) {
+ _fullSize = FVCGImageSize(_fullImage);
[self unlock];
[[self class] _stopRenderingForKey:_cacheKey];
return;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit