Revision: 28185
          http://sourceforge.net/p/bibdesk/svn/28185
Author:   hofman
Date:     2023-03-12 09:42:20 +0000 (Sun, 12 Mar 2023)
Log Message:
-----------
observe changes to accessibility display options for group bubble

Modified Paths:
--------------
    trunk/bibdesk/BDSKGroupBubbleView.m

Modified: trunk/bibdesk/BDSKGroupBubbleView.m
===================================================================
--- trunk/bibdesk/BDSKGroupBubbleView.m 2023-03-10 23:36:40 UTC (rev 28184)
+++ trunk/bibdesk/BDSKGroupBubbleView.m 2023-03-12 09:42:20 UTC (rev 28185)
@@ -45,22 +45,27 @@
 @end
 #endif
 
+@interface BDSKGroupBubbleView (BDSKPrivate)
+- (void)updateMaterial:(id)sender;
+@end
+
 @implementation BDSKGroupBubbleView
 
 + (Class)cellClass { return [BDSKGroupBubbleCell class]; }
 
+- (void)commonInit {
+    bgView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
+    [bgView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+    [self addSubview:bgView];
+    [self updateMaterial:nil];
+    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self 
selector:@selector(updateMaterial:) 
name:@"NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification" object:nil];
+}
+
 - (id)initWithFrame:(NSRect)frameRect {
     self = [super initWithFrame:frameRect];
     if (self) {
-        if (RUNNING_AFTER(10_15)) {
-            bgView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
-            if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldIncreaseContrast] || [[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldReduceTransparency])
-                [bgView setMaterial:4];
-            else
-                [bgView setMaterial:7];
-            [bgView setAutoresizingMask:NSViewWidthSizable | 
NSViewHeightSizable];
-            [self addSubview:bgView];
-        }
+        if (RUNNING_AFTER(10_15))
+            [self commonInit];
     }
     return self;
 }
@@ -68,15 +73,8 @@
 - (id)initWithCoder:(NSCoder *)coder {
     self = [super initWithCoder:coder];
     if (self) {
-        if (RUNNING_AFTER(10_15)) {
-            bgView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
-            if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldIncreaseContrast] || [[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldReduceTransparency])
-                [bgView setMaterial:4];
-            else
-                [bgView setMaterial:7];
-            [bgView setAutoresizingMask:NSViewWidthSizable | 
NSViewHeightSizable];
-            [self addSubview:bgView];
-        }
+        if (RUNNING_AFTER(10_15))
+            [self commonInit];
     }
     return self;
 }
@@ -87,7 +85,7 @@
     [super dealloc];
 }
 
-- (void)updateMaterial {
+- (void)updateMaterial:(id)sender {
     if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldIncreaseContrast])
         [bgView setMaterial:[(NSTableRowView *)[[self superview] superview] 
isSelected] ? 7 : 4];
     else if ([[NSWorkspace sharedWorkspace] 
accessibilityDisplayShouldReduceTransparency])
@@ -103,7 +101,7 @@
     [super viewDidChangeEffectiveAppearance];
 #pragma clang diagnostic pop
     if (RUNNING_AFTER(10_15))
-        [self updateMaterial];
+        [self updateMaterial:nil];
 }
 
 - (void)setImage:(NSImage *)image {
@@ -153,7 +151,7 @@
 - (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
     [super setBackgroundStyle:backgroundStyle];
     if (RUNNING_AFTER(10_15))
-        [(BDSKGroupBubbleView *)[self controlView] updateMaterial];
+        [(BDSKGroupBubbleView *)[self controlView] updateMaterial:nil];
 }
 
 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {

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