[vlc-commits] macosx/main window: add dark mode dropzone icon

Felix Paul Kühne git at videolan.org
Mon Sep 24 18:46:02 CEST 2018


vlc/vlc-3.0 | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Sep 24 18:32:54 2018 +0200| [2da573174e5eee4145e860994b33ddfa890378fb] | committer: Felix Paul Kühne

macosx/main window: add dark mode dropzone icon

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

 modules/gui/macosx/Makefile.am                     |   2 ++
 .../mainwindow_mojave_dark/mj-dropzone-dark.png    | Bin 0 -> 1393 bytes
 .../mainwindow_mojave_dark/mj-dropzone-dark at 2x.png | Bin 0 -> 2951 bytes
 modules/gui/macosx/VLCMainWindow.m                 |  32 ++++++++++++++++++++-
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 01df841ab0..da4888f30e 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -567,6 +567,8 @@ libmacosx_plugin_la_RES = \
 	gui/macosx/Resources/mainwindow_dark_yosemite/ys-volume-high_dark at 2x.png \
 	gui/macosx/Resources/mainwindow_dark_yosemite/ys-volume-low_dark.png \
 	gui/macosx/Resources/mainwindow_dark_yosemite/ys-volume-low_dark at 2x.png \
+	gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark.png \
+	gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark at 2x.png \
 	gui/macosx/Resources/mainwindow_yosemite/ys-backward-3btns-pressed.png \
 	gui/macosx/Resources/mainwindow_yosemite/ys-backward-3btns-pressed at 2x.png \
 	gui/macosx/Resources/mainwindow_yosemite/ys-backward-3btns.png \
diff --git a/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark.png b/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark.png
new file mode 100644
index 0000000000..fa0855b6bd
Binary files /dev/null and b/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark.png differ
diff --git a/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark at 2x.png b/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark at 2x.png
new file mode 100644
index 0000000000..f340e467a5
Binary files /dev/null and b/modules/gui/macosx/Resources/mainwindow_mojave_dark/mj-dropzone-dark at 2x.png differ
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index 9ff62e4f34..96ad1925a7 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -135,6 +135,9 @@ static const float f_min_window_height = 307.;
 - (void)dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver: self];
+    if (@available(macOS 10_14, *)) {
+        [[NSApplication sharedApplication] removeObserver:self forKeyPath:@"effectiveAppearance"];
+    }
 }
 
 - (void)awakeFromNib
@@ -189,7 +192,20 @@ static const float f_min_window_height = 307.;
 
     // Dropzone
     [_dropzoneLabel setStringValue:_NS("Drop media here")];
-    [_dropzoneImageView setImage:imageFromRes(@"dropzone")];
+    if (@available(macOS 10.14, *)) {
+        NSApplication *app = [NSApplication sharedApplication];
+        if ([app.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua]) {
+            [_dropzoneImageView setImage:[NSImage imageNamed:@"mj-dropzone-dark"]];
+        } else {
+            [_dropzoneImageView setImage:imageFromRes(@"dropzone")];
+        }
+        [app addObserver:self
+              forKeyPath:@"effectiveAppearance"
+                 options:0
+                 context:nil];
+    } else {
+        [_dropzoneImageView setImage:imageFromRes(@"dropzone")];
+    }
     [_dropzoneButton setTitle:_NS("Open media...")];
     [_dropzoneButton.cell accessibilitySetOverrideValue:_NS("Open a dialog to select the media to play")
                                            forAttribute:NSAccessibilityDescriptionAttribute];
@@ -730,6 +746,20 @@ static const float f_min_window_height = 307.;
     [self.fspanel setVolumeLevel:[[VLCCoreInteraction sharedInstance] volume]];
 }
 
+- (void)observeValueForKeyPath:(NSString *)keyPath
+                      ofObject:(id)object
+                        change:(NSDictionary<NSKeyValueChangeKey,id> *)change
+                       context:(void *)context
+{
+    if (@available(macOS 10_14, *)) {
+        if ([[[NSApplication sharedApplication] effectiveAppearance].name isEqualToString:NSAppearanceNameDarkAqua]) {
+            [_dropzoneImageView setImage:[NSImage imageNamed:@"mj-dropzone-dark"]];
+        } else {
+            [_dropzoneImageView setImage:imageFromRes(@"dropzone")];
+        }
+    }
+}
+
 #pragma mark -
 #pragma mark Video Output handling
 



More information about the vlc-commits mailing list