Revision: 25430
          http://sourceforge.net/p/bibdesk/svn/25430
Author:   hofman
Date:     2021-01-18 00:19:34 +0000 (Mon, 18 Jan 2021)
Log Message:
-----------
Allow link badge fopr webview icon initialized from file URL

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.h
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m  2021-01-18 00:02:45 UTC 
(rev 25429)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVIcon.m  2021-01-18 00:19:34 UTC 
(rev 25430)
@@ -159,7 +159,7 @@
         // FVWebViewIcon may be disabled, and does only support regular 
schemess
         // return a Finder scheme based icon in that case
         if ([FVWebViewIcon canInitWithURL:representedURL withType:nil])
-            return (id)[[FVWebViewIcon alloc] initWithURL:representedURL];
+            return (id)[[FVWebViewIcon alloc] initWithURL:representedURL 
drawsLinkBadge:NO];
         else
             return (id)[FVFinderIcon newWithScheme:[representedURL scheme]];
     }
@@ -256,7 +256,7 @@
         anIcon = [[FVMovieIcon alloc] initWithURL:resolvedURL 
drawsLinkBadge:isLink];
     }
     else if ([FVWebViewIcon canInitWithURL:resolvedURL withType:type]) {
-        anIcon = [[FVWebViewIcon alloc] initWithURL:resolvedURL];
+        anIcon = [[FVWebViewIcon alloc] initWithURL:resolvedURL 
drawsLinkBadge:isLink];
     }
     else if (dataPhysicalSize < maximumTextDataSize && [FVTextIcon 
canInitWithURL:resolvedURL withType:type]) {
         anIcon = [[FVTextIcon alloc] initWithURL:resolvedURL 
drawsLinkBadge:isLink isPlainText:(UTTypeConformsTo(theUTI, kUTTypePlainText))];

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.h   2021-01-18 
00:02:45 UTC (rev 25429)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.h   2021-01-18 
00:19:34 UTC (rev 25430)
@@ -55,6 +55,7 @@
     WebView         *_webView;
     NSCountedSet    *_redirectedFrames;
     id               _cacheKey;
+    BOOL             _drawsLinkBadge;
     bool             _cancelledLoad;
     BOOL             _loadFailed;
     NSConditionLock *_condLock;
@@ -62,6 +63,6 @@
 
 + (BOOL)canInitWithURL:(NSURL *)aURL withType:(NSString *)type;
 
-- (id)initWithURL:(NSURL *)aURL;
+- (id)initWithURL:(NSURL *)aURL drawsLinkBadge:(BOOL)drawsLinkBadge;
 
 @end

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m   2021-01-18 
00:02:45 UTC (rev 25429)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVWebViewIcon.m   2021-01-18 
00:19:34 UTC (rev 25430)
@@ -124,7 +124,7 @@
     }
 }
 
-- (id)initWithURL:(NSURL *)aURL;
+- (id)initWithURL:(NSURL *)aURL drawsLinkBadge:(BOOL)drawsLinkBadge
 {    
     NSParameterAssert(nil != [aURL scheme]);
     
@@ -140,6 +140,7 @@
         _thumbnail = NULL;
         _viewImage = NULL;
         _fallbackIcon = nil;
+        _drawsLinkBadge = drawsLinkBadge;
         _loadFailed = NO;
         _webView = nil;
         _redirectedFrames = [NSCountedSet new];
@@ -665,6 +666,13 @@
         if (_thumbnail) {
             CGContextDrawImage(context, [self _drawingRectWithRect:dstRect], 
_thumbnail);
             [self unlock];
+            if (_drawsLinkBadge) {
+                // get rid of any shadow, or we may draw a text shadow if the 
page is transparent
+                CGContextSaveGState(context);
+                CGContextSetShadowWithColor(context, CGSizeZero, 0, NULL);
+                [self _badgeIconInRect:dstRect ofContext:context];
+                CGContextSaveGState(context);
+            }
         }
         else {
             [self unlock];
@@ -695,6 +703,14 @@
             [self _drawPlaceholderInRect:dstRect ofContext:context];
         
         [self unlock];
+        
+        if (_drawsLinkBadge) {
+            // get rid of any shadow, or we may draw a text shadow if the page 
is transparent
+            CGContextSaveGState(context);
+            CGContextSetShadowWithColor(context, CGSizeZero, 0, NULL);
+            [self _badgeIconInRect:dstRect ofContext:context];
+            CGContextSaveGState(context);
+        }
     }
     else {
         [self _drawPlaceholderInRect:dstRect ofContext:context];

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

Reply via email to