Revision: 24113
          http://sourceforge.net/p/bibdesk/svn/24113
Author:   hofman
Date:     2019-08-02 22:14:31 +0000 (Fri, 02 Aug 2019)
Log Message:
-----------
get appearance to draw image from NSApp

Modified Paths:
--------------
    trunk/bibdesk/NSColor_BDSKExtensions.h
    trunk/bibdesk/NSColor_BDSKExtensions.m
    trunk/bibdesk/NSImage_BDSKExtensions.m

Modified: trunk/bibdesk/NSColor_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.h      2019-08-02 20:55:12 UTC (rev 
24112)
+++ trunk/bibdesk/NSColor_BDSKExtensions.h      2019-08-02 22:14:31 UTC (rev 
24113)
@@ -43,8 +43,6 @@
 extern void BDSKSetHasDarkAppearance(id object);
 extern void BDSKSetHasLightAppearance(id object);
 extern void BDSKRunWithAppearance(id object, void (^code)(void));
-extern void BDSKRunWithLightAppearance(void (^code)(void));
-extern void BDSKRunWithDarkAppearance(void (^code)(void));
 
 @interface NSColor (BDSKExtensions)
 

Modified: trunk/bibdesk/NSColor_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.m      2019-08-02 20:55:12 UTC (rev 
24112)
+++ trunk/bibdesk/NSColor_BDSKExtensions.m      2019-08-02 22:14:31 UTC (rev 
24113)
@@ -114,34 +114,6 @@
     }
 }
 
-void BDSKRunWithLightAppearance(void (^code)(void)) {
-    if (RUNNING_AFTER(10_13)) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
-        NSAppearance *appearance = [[[NSAppearance currentAppearance] retain] 
autorelease];
-        [NSAppearance setCurrentAppearance:[NSAppearance 
appearanceNamed:@"NSAppearanceNameAqua"]];
-        code();
-        [NSAppearance setCurrentAppearance:appearance];
-#pragma clang diagnostic pop
-    } else {
-        code();
-    }
-}
-
-void BDSKRunWithDarkAppearance(void (^code)(void)) {
-    if (RUNNING_AFTER(10_13)) {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
-        NSAppearance *appearance = [[[NSAppearance currentAppearance] retain] 
autorelease];
-        [NSAppearance setCurrentAppearance:[NSAppearance 
appearanceNamed:@"NSAppearanceNameDarkAqua"]];
-        code();
-        [NSAppearance setCurrentAppearance:appearance];
-#pragma clang diagnostic pop
-    } else {
-        code();
-    }
-}
-
 @interface BDSKDynamicColor : NSColor {
     NSColor *aquaColor;
     NSColor *darkAquaColor;

Modified: trunk/bibdesk/NSImage_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSImage_BDSKExtensions.m      2019-08-02 20:55:12 UTC (rev 
24112)
+++ trunk/bibdesk/NSImage_BDSKExtensions.m      2019-08-02 22:14:31 UTC (rev 
24113)
@@ -486,52 +486,30 @@
 
 + (NSImage *)redPaperclipImage;
 {
-    if (BDSKHasDarkAppearance(NSApp)) {
-        static NSImage *image = nil;
-        if(image == nil){
-            __block NSImage *img = nil;
-            BDSKRunWithDarkAppearance(^{
-                img = createPaperclipImageWithColor([NSColor systemRedColor], 
NO);
-            });
-            image = img;
-        }
-        return image;
-    } else {
-        static NSImage *image = nil;
-        if(image == nil){
-            __block NSImage *img = nil;
-            BDSKRunWithLightAppearance(^{
-                img = createPaperclipImageWithColor([NSColor systemRedColor], 
NO);
-            });
-            image = img;
-        }
-        return image;
+    static NSImage *image[2] = {nil, nil};
+    NSUInteger i = BDSKHasDarkAppearance(NSApp);
+    if(image[i] == nil){
+        __block NSImage *img = nil;
+        BDSKRunWithAppearance(NSApp, ^{
+            img = createPaperclipImageWithColor([NSColor systemRedColor], NO);
+        });
+        image[i] = img;
     }
+    return image[i];
 }
 
 + (NSImage *)redAnnotatedPaperclipImage;
 {
-    if (BDSKHasDarkAppearance(NSApp)) {
-        static NSImage *image = nil;
-        if(image == nil){
-            __block NSImage *img = nil;
-            BDSKRunWithDarkAppearance(^{
-                img = createPaperclipImageWithColor([NSColor systemRedColor], 
YES);
-            });
-            image = img;
-        }
-        return image;
-    } else {
-        static NSImage *image = nil;
-        if(image == nil){
-            __block NSImage *img = nil;
-            BDSKRunWithLightAppearance(^{
-                img = createPaperclipImageWithColor([NSColor systemRedColor], 
YES);
-            });
-            image = img;
-        }
-        return image;
+    static NSImage *image[2] = {nil, nil};
+    NSUInteger i = BDSKHasDarkAppearance(NSApp);
+    if(image[i] == nil){
+        __block NSImage *img = nil;
+        BDSKRunWithAppearance(NSApp, ^{
+            img = createPaperclipImageWithColor([NSColor systemRedColor], YES);
+        });
+        image[i] = img;
     }
+    return image[i];
 }
 
 + (NSImage *)annotatedPaperclipImage;

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