Revision: 27816
http://sourceforge.net/p/bibdesk/svn/27816
Author: hofman
Date: 2022-08-20 15:01:51 +0000 (Sat, 20 Aug 2022)
Log Message:
-----------
use selection material for count bubble in high contrast appearance, except for
selected rows
Modified Paths:
--------------
trunk/bibdesk/BDSKGroupBubbleView.m
trunk/bibdesk/NSColor_BDSKExtensions.h
trunk/bibdesk/NSColor_BDSKExtensions.m
Modified: trunk/bibdesk/BDSKGroupBubbleView.m
===================================================================
--- trunk/bibdesk/BDSKGroupBubbleView.m 2022-08-20 09:36:08 UTC (rev 27815)
+++ trunk/bibdesk/BDSKGroupBubbleView.m 2022-08-20 15:01:51 UTC (rev 27816)
@@ -39,6 +39,11 @@
#import "BDSKGroupBubbleView.h"
#import "NSColor_BDSKExtensions.h"
+#if SDK_BEFORE(10_14)
+@interface NSView (BDSKMojaveDeclarations)
+- (void)viewDidChangeEffectiveAppearance;
+@end
+#endif
@implementation BDSKGroupBubbleView
@@ -48,7 +53,7 @@
self = [super initWithFrame:frameRect];
if (self && RUNNING_AFTER(10_15)) {
bgView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
- [bgView setMaterial:7];
+ [bgView setMaterial:BDSKHasHighContrastAppearance(NSApp) ? 4 : 7];
[bgView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[bgView setHidden:YES];
[self addSubview:bgView];
@@ -60,7 +65,7 @@
self = [super initWithCoder:coder];
if (self && RUNNING_AFTER(10_15)) {
bgView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
- [bgView setMaterial:7];
+ [bgView setMaterial:BDSKHasHighContrastAppearance(NSApp) ? 4 : 7];
[bgView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[bgView setHidden:YES];
[self addSubview:bgView];
@@ -74,6 +79,19 @@
[super dealloc];
}
+- (void)updateMaterial {
+ [bgView setMaterial:BDSKHasHighContrastAppearance(NSApp) &&
[(NSTableRowView *)[[self superview] superview] isSelected] == NO ? 4 : 7];
+}
+
+- (void)viewDidChangeEffectiveAppearance {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ [super viewDidChangeEffectiveAppearance];
+#pragma clang diagnostic pop
+ if (RUNNING_AFTER(10_15))
+ [self updateMaterial];
+}
+
- (void)setImage:(NSImage *)image {
[super setImage:image];
if (RUNNING_AFTER(10_15)) {
@@ -119,6 +137,12 @@
return [super isEnabled];
}
+- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
+ [super setBackgroundStyle:backgroundStyle];
+ if (RUNNING_AFTER(10_15))
+ [(BDSKGroupBubbleView *)[self controlView] updateMaterial];
+}
+
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
if (RUNNING_AFTER(10_15)) {
} else if (RUNNING_AFTER(10_9) || [self backgroundStyle] ==
NSBackgroundStyleDark || [self backgroundStyle] == NSBackgroundStyleLowered) {
Modified: trunk/bibdesk/NSColor_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.h 2022-08-20 09:36:08 UTC (rev
27815)
+++ trunk/bibdesk/NSColor_BDSKExtensions.h 2022-08-20 15:01:51 UTC (rev
27816)
@@ -51,6 +51,7 @@
extern BOOL BDSKHasDarkAppearance(id object);
extern void BDSKSetHasDarkAppearance(id object);
extern void BDSKSetHasLightAppearance(id object);
+extern BOOL BDSKHasHighContrastAppearance(id object);
extern void BDSKSetHasDefaultAppearance(id object);
extern void BDSKSetAppearance(id toObject, id fromObject);
extern void BDSKRunWithAppearance(id object, void (^code)(void));
Modified: trunk/bibdesk/NSColor_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSColor_BDSKExtensions.m 2022-08-20 09:36:08 UTC (rev
27815)
+++ trunk/bibdesk/NSColor_BDSKExtensions.m 2022-08-20 15:01:51 UTC (rev
27816)
@@ -81,6 +81,21 @@
[(id<NSAppearanceCustomization>)object setAppearance:[NSAppearance
appearanceNamed:@"NSAppearanceNameAqua"]];
}
+BOOL BDSKHasHighContrastAppearance(id object) {
+ if (RUNNING_AFTER(10_13)) {
+ id appearance = nil;
+ if (object == nil)
+ appearance = [NSAppearance currentAppearance];
+ else if ([object respondsToSelector:@selector(effectiveAppearance)])
+ appearance = [(id<NSAppearanceCustomization>)object
effectiveAppearance];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ return [[appearance bestMatchFromAppearancesWithNames:[NSArray
arrayWithObjects:@"NSAppearanceNameAqua", @"NSAppearanceNameDarkAqua",
@"NSAppearanceNameAccessibilityAqua", @"NSAppearanceNameAccessibilityDarkAqua",
nil]] hasPrefix:@"NSAppearanceNameAccessibility"];
+#pragma clang diagnostic pop
+ }
+ return NO;
+}
+
void BDSKSetHasDefaultAppearance(id object) {
if (RUNNING_AFTER(10_13) && [object
respondsToSelector:@selector(setAppearance:)])
[(id<NSAppearanceCustomization>)object setAppearance:nil];
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