[vlc-commits] macosx/VLCSlider: add dark mode support for mojave

Felix Paul Kühne git at videolan.org
Mon Sep 24 15:45:03 CEST 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Sep 24 00:07:58 2018 +0200| [bbf24219d60e2ce0e9f3c3fc6197811a46bc0774] | committer: Felix Paul Kühne

macosx/VLCSlider: add dark mode support for mojave

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bbf24219d60e2ce0e9f3c3fc6197811a46bc0774
---

 modules/gui/macosx/VLCSlider.m     | 15 +++++++++++++++
 modules/gui/macosx/VLCSliderCell.m | 12 +++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/VLCSlider.m b/modules/gui/macosx/VLCSlider.m
index b89d2c3f0d..cbe433a659 100644
--- a/modules/gui/macosx/VLCSlider.m
+++ b/modules/gui/macosx/VLCSlider.m
@@ -34,6 +34,11 @@
         NSAssert([self.cell isKindOfClass:[VLCSliderCell class]],
                  @"VLCSlider cell is not VLCSliderCell");
         _isScrollable = YES;
+        if (@available(macOS 10.14, *)) {
+            [self viewDidChangeEffectiveAppearance];
+        } else {
+            [self setSliderStyleLight];
+        }
     }
     return self;
 }
@@ -109,4 +114,14 @@
     [(VLCSliderCell*)[self cell] setSliderStyleDark];
 }
 
+- (void)viewDidChangeEffectiveAppearance
+{
+    if (@available(macOS 10_14, *)) {
+        if ([self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua])
+            [self setSliderStyleDark];
+        else
+            [self setSliderStyleLight];
+    }
+}
+
 @end
diff --git a/modules/gui/macosx/VLCSliderCell.m b/modules/gui/macosx/VLCSliderCell.m
index 69a0d65ed2..e1ed05cc26 100644
--- a/modules/gui/macosx/VLCSliderCell.m
+++ b/modules/gui/macosx/VLCSliderCell.m
@@ -82,12 +82,18 @@
 - (void)setSliderStyleDark
 {
     // Color Declarations
-    _gradientColor = [NSColor colorWithCalibratedRed: 0.24 green: 0.24 blue: 0.24 alpha: 1];
+    if (OSX_MOJAVE_AND_HIGHER) {
+        _gradientColor = [NSColor colorWithCalibratedRed: 0.20 green: 0.20 blue: 0.20 alpha: 1];
+        _knobFillColor = [NSColor colorWithCalibratedRed: 0.81 green: 0.81 blue: 0.81 alpha: 1];
+        _activeKnobFillColor = [NSColor colorWithCalibratedRed: 0.76 green: 0.76 blue: 0.76 alpha: 1];
+    } else {
+        _gradientColor = [NSColor colorWithCalibratedRed: 0.24 green: 0.24 blue: 0.24 alpha: 1];
+        _knobFillColor = [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
+        _activeKnobFillColor = [NSColor colorWithCalibratedRed: 0.95 green: 0.95 blue: 0.95 alpha: 1];
+    }
     _gradientColor2 = [NSColor colorWithCalibratedRed: 0.15 green: 0.15 blue: 0.15 alpha: 1];
     _trackStrokeColor = [NSColor colorWithCalibratedRed: 0.23 green: 0.23 blue: 0.23 alpha: 1];
     _filledTrackColor = [NSColor colorWithCalibratedRed: 0.15 green: 0.15 blue: 0.15 alpha: 1];
-    _knobFillColor = [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
-    _activeKnobFillColor = [NSColor colorWithCalibratedRed: 0.95 green: 0.95 blue: 0.95 alpha: 1];
     _shadowColor = [NSColor colorWithCalibratedRed: 0.32 green: 0.32 blue: 0.32 alpha: 1];
     _knobStrokeColor = [NSColor colorWithCalibratedRed: 0.592 green: 0.596 blue: 0.596 alpha: 1];
 



More information about the vlc-commits mailing list