]> granicus.if.org Git - transmission/commitdiff
On 10.14, use the accent color for the selected info tab
authorMitchell Livingston <livings124@mac.com>
Fri, 21 Dec 2018 22:58:15 +0000 (17:58 -0500)
committerMitchell Livingston <livings124@mac.com>
Fri, 21 Dec 2018 22:58:15 +0000 (17:58 -0500)
macosx/InfoTabButtonCell.m

index b15a5c884004dddbf5cf5f0691beca40d83190ca..efa5b86ef586fa0eb8c2127eef3b314dbd3e382f 100644 (file)
 
 - (void) awakeFromNib
 {
-    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
-    [nc addObserver: self selector: @selector(updateControlTint:)
-        name: NSControlTintDidChangeNotification object: NSApp];
+    if (![NSApp isOnMojaveOrBetter]) {
+        NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
+        [nc addObserver: self selector: @selector(updateControlTint:)
+            name: NSControlTintDidChangeNotification object: NSApp];
+    }
 
     fSelected = NO;
 
     NSGradient * gradient;
     if (fSelected)
     {
-        NSColor * lightColor = [NSColor colorForControlTint: [NSColor currentControlTint]];
-        NSColor * darkColor = [lightColor blendedColorWithFraction: 0.2 ofColor: [NSColor blackColor]];
+        NSColor * lightColor, * darkColor;
+        if (@available(macOS 10.14, *)) {
+            lightColor = [NSColor.controlAccentColor blendedColorWithFraction: 0.35 ofColor: [NSColor whiteColor]];
+            darkColor = [NSColor.controlAccentColor blendedColorWithFraction: 0.15 ofColor: [NSColor whiteColor]];
+        } else {
+            lightColor = [NSColor colorForControlTint: [NSColor currentControlTint]];
+            darkColor = [lightColor blendedColorWithFraction: 0.2 ofColor: [NSColor blackColor]];
+        }
         gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     }
     else
 
 - (void) updateControlTint: (NSNotification *) notification
 {
+    NSAssert(![NSApp isOnMojaveOrBetter], @"should not be observing control tint color when accent color is available");
+    
     if (fSelected)
         [self setSelectedTab: YES];
 }