Revision: 28439
http://sourceforge.net/p/bibdesk/svn/28439
Author: hofman
Date: 2023-11-13 15:27:13 +0000 (Mon, 13 Nov 2023)
Log Message:
-----------
code for changing appearance or running code with a particular appearance in
place where it is used
Modified Paths:
--------------
trunk/bibdesk/BDSKLevelIndicatorCell.m
trunk/bibdesk/BDSKZoomablePDFView.m
trunk/bibdesk/BibDocument_DataSource.m
trunk/bibdesk/NSColor_BDSKExtensions.h
trunk/bibdesk/NSColor_BDSKExtensions.m
trunk/bibdesk/NSImage_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKLevelIndicatorCell.m
===================================================================
--- trunk/bibdesk/BDSKLevelIndicatorCell.m 2023-11-13 10:37:35 UTC (rev
28438)
+++ trunk/bibdesk/BDSKLevelIndicatorCell.m 2023-11-13 15:27:13 UTC (rev
28439)
@@ -38,8 +38,11 @@
#import "BDSKLevelIndicatorCell.h"
#import "NSGeometry_BDSKExtensions.h"
-#import "NSColor_BDSKExtensions.h"
+#if SDK_BEFORE(10_14)
+#define NSAppearanceNameDarkAqua @"NSAppearanceNameDarkAqua"
+#endif
+
/* Subclass of NSLevelIndicatorCell. The default relevancy cell draws bars
the entire vertical height of the table row, which looks bad. Using
setControlSize: seems to have no effect.
*/
@@ -65,11 +68,13 @@
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
[super setBackgroundStyle:backgroundStyle];
- if ([[self controlView] isKindOfClass:[NSLevelIndicator class]]) {
- if (backgroundStyle == NSBackgroundStyleDark)
- BDSKSetHasDarkAppearance([self controlView]);
- else
- BDSKSetHasDefaultAppearance([self controlView]);
+ if (@available(macOS 10.14, *)) {
+ if ([[self controlView] isKindOfClass:[NSLevelIndicator class]]) {
+ if (backgroundStyle == NSBackgroundStyleDark)
+ [[self controlView] setAppearance:[NSAppearance
appearanceNamed:NSAppearanceNameDarkAqua]];
+ else
+ [[self controlView] setAppearance:nil];
+ }
}
}
Modified: trunk/bibdesk/BDSKZoomablePDFView.m
===================================================================
--- trunk/bibdesk/BDSKZoomablePDFView.m 2023-11-13 10:37:35 UTC (rev 28438)
+++ trunk/bibdesk/BDSKZoomablePDFView.m 2023-11-13 15:27:13 UTC (rev 28439)
@@ -287,8 +287,10 @@
[self updateScrollerInsets];
- BDSKSetHasDefaultAppearance(self);
- BDSKSetHasLightAppearance([self scrollView]);
+ if (@available(macOS 10.14, *)) {
+ [self setAppearance:nil];
+ [[self scrollView] setAppearance:[NSAppearance
appearanceNamed:NSAppearanceNameAqua]];
+ }
[self updateColorFilters];
}
Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m 2023-11-13 10:37:35 UTC (rev
28438)
+++ trunk/bibdesk/BibDocument_DataSource.m 2023-11-13 15:27:13 UTC (rev
28439)
@@ -81,7 +81,6 @@
#import "NSPasteboard_BDSKExtensions.h"
#import "NSView_BDSKExtensions.h"
#import "BDSKParentGroup.h"
-#import "NSColor_BDSKExtensions.h"
#import "BDSKColorRowView.h"
#import "BDSKGroupCellView.h"
#import "BDSKGroupRowView.h"
@@ -608,13 +607,20 @@
image = [[[NSImage alloc] initWithSize:size] autorelease];
- BDSKRunWithAppearance(tableView, ^{
- [image lockFocus];
+ [image lockFocus];
+ if (@available(macOS 10.14, *)) {
+ NSAppearance *appearance = [[[NSAppearance currentAppearance]
retain] autorelease];
+ [NSAppearance setCurrentAppearance:[tableView
effectiveAppearance]];
[NSBezierPath drawHighlightInRect:rect radius:4.0
lineWidth:2.0 color:color];
NSRectClip(NSInsetRect(rect, 3.0, 3.0));
[attrString drawAtPoint:point];
- [image unlockFocus];
- });
+ [NSAppearance setCurrentAppearance:appearance];
+ } else {
+ [NSBezierPath drawHighlightInRect:rect radius:4.0
lineWidth:2.0 color:color];
+ NSRectClip(NSInsetRect(rect, 3.0, 3.0));
+ [attrString drawAtPoint:point];
+ }
+ [image unlockFocus];
}
}
Modified: trunk/bibdesk/NSColor_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.h 2023-11-13 10:37:35 UTC (rev
28438)
+++ trunk/bibdesk/NSColor_BDSKExtensions.h 2023-11-13 15:27:13 UTC (rev
28439)
@@ -49,11 +49,6 @@
};
extern BOOL BDSKHasDarkAppearance(id object);
-extern void BDSKSetHasDarkAppearance(id object);
-extern void BDSKSetHasLightAppearance(id object);
-extern void BDSKSetHasDefaultAppearance(id object);
-extern void BDSKSetAppearance(id toObject, id fromObject);
-extern void BDSKRunWithAppearance(id object, void (^code)(void));
@interface NSColor (BDSKExtensions)
Modified: trunk/bibdesk/NSColor_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.m 2023-11-13 10:37:35 UTC (rev
28438)
+++ trunk/bibdesk/NSColor_BDSKExtensions.m 2023-11-13 15:27:13 UTC (rev
28439)
@@ -62,50 +62,6 @@
return NO;
}
-void BDSKSetHasDarkAppearance(id object) {
- if (@available(macOS 10.14, *)) {
- if ([object respondsToSelector:@selector(setAppearance:)])
- [(id<NSAppearanceCustomization>)object setAppearance:[NSAppearance
appearanceNamed:@"NSAppearanceNameDarkAqua"]];
- }
-}
-
-void BDSKSetHasLightAppearance(id object) {
- if (@available(macOS 10.14, *)) {
- if ([object respondsToSelector:@selector(setAppearance:)])
- [(id<NSAppearanceCustomization>)object setAppearance:[NSAppearance
appearanceNamed:@"NSAppearanceNameAqua"]];
- }
-}
-
-void BDSKSetHasDefaultAppearance(id object) {
- if (@available(macOS 10.14, *)) {
- if ([object respondsToSelector:@selector(setAppearance:)])
- [(id<NSAppearanceCustomization>)object setAppearance:nil];
- }
-}
-
-void BDSKSetAppearance(id toObject, id fromObject) {
- if (@available(macOS 10.14, *)) {
- if ([fromObject respondsToSelector:@selector(appearance)] && [toObject
respondsToSelector:@selector(setAppearance:)])
- [(id<NSAppearanceCustomization>)toObject
setAppearance:[(id<NSAppearanceCustomization>)fromObject appearance]];
- }
-}
-
-void BDSKRunWithAppearance(id object, void (^code)(void)) {
- if (@available(macOS 10.14, *)) {
- if ([object respondsToSelector:@selector(effectiveAppearance)]) {
- NSAppearance *appearance = nil;
- appearance = [[[NSAppearance currentAppearance] retain]
autorelease];
- [NSAppearance
setCurrentAppearance:[(id<NSAppearanceCustomization>)object
effectiveAppearance]];
- code();
- [NSAppearance setCurrentAppearance:appearance];
- } else {
- code();
- }
- } else {
- code();
- }
-}
-
@interface BDSKDynamicColor : NSColor {
NSColor *aquaColor;
NSColor *darkAquaColor;
Modified: trunk/bibdesk/NSImage_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSImage_BDSKExtensions.m 2023-11-13 10:37:35 UTC (rev
28438)
+++ trunk/bibdesk/NSImage_BDSKExtensions.m 2023-11-13 15:27:13 UTC (rev
28439)
@@ -63,6 +63,10 @@
NSString *BDSKImageNameCautionIcon = @"BDSKCautionIcon";
+#if SDK_BEFORE(10_14)
+#define NSAppearanceNameDarkAqua @"NSAppearanceNameDarkAqua"
+#endif
+
@implementation NSImage (BDSKExtensions)
+ (void)makePreviewDisplayImages {
@@ -602,7 +606,7 @@
+ (NSImage *)paperclipImage;
{
static NSImage *image = nil;
- if(image == nil) {
+ if (image == nil) {
image = createPaperclipImageWithColor([NSColor
colorWithGenericGamma22White:0.0 alpha:0.9], NO);
[image setTemplate:YES];
[image setAccessibilityDescription:NSLocalizedString(@"attachment",
@"Accessibility description")];
@@ -614,11 +618,18 @@
{
static NSImage *image[2] = {nil, nil};
NSUInteger i = BDSKHasDarkAppearance(NSApp);
- if(image[i] == nil){
- __block NSImage *img = nil;
- BDSKRunWithAppearance(NSApp, ^{
+ if (image[i] == nil) {
+ NSImage *img = nil;
+ if (i == 1) {
+ if (@available(macOS 10.14, *)) {
+ NSAppearance *appearance = [[[NSAppearance currentAppearance]
retain] autorelease];
+ [NSAppearance setCurrentAppearance:[NSAppearance
appearanceNamed:NSAppearanceNameDarkAqua]];
+ img = createPaperclipImageWithColor([NSColor systemRedColor],
NO);
+ [NSAppearance setCurrentAppearance:appearance];
+ }
+ }
+ if (img == nil)
img = createPaperclipImageWithColor([NSColor systemRedColor], NO);
- });
[img setAccessibilityDescription:NSLocalizedString(@"missing
attachment", @"Accessibility description")];
image[i] = img;
}
@@ -629,11 +640,18 @@
{
static NSImage *image[2] = {nil, nil};
NSUInteger i = BDSKHasDarkAppearance(NSApp);
- if(image[i] == nil){
- __block NSImage *img = nil;
- BDSKRunWithAppearance(NSApp, ^{
+ if (image[i] == nil) {
+ NSImage *img = nil;
+ if (i == 1) {
+ if (@available(macOS 10.14, *)) {
+ NSAppearance *appearance = [[[NSAppearance currentAppearance]
retain] autorelease];
+ [NSAppearance setCurrentAppearance:[NSAppearance
appearanceNamed:NSAppearanceNameDarkAqua]];
+ img = createPaperclipImageWithColor([NSColor systemRedColor],
YES);
+ [NSAppearance setCurrentAppearance:appearance];
+ }
+ }
+ if (img == nil)
img = createPaperclipImageWithColor([NSColor systemRedColor], YES);
- });
[img setAccessibilityDescription:NSLocalizedString(@"missing
attachment with notes", @"Accessibility description")];
image[i] = img;
}
@@ -643,7 +661,7 @@
+ (NSImage *)annotatedPaperclipImage;
{
static NSImage *image = nil;
- if(image == nil) {
+ if (image == nil) {
image = createPaperclipImageWithColor([NSColor
colorWithGenericGamma22White:0.0 alpha:0.9], YES);
[image setTemplate:YES];
[image setAccessibilityDescription:NSLocalizedString(@"attachment with
notes", @"Accessibility description")];
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