[vlc-commits] [Git][videolan/vlc][master] macosx: use dark appearance helper for appearance checks

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 30 02:30:59 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b5536cde by Serhii Bykov at 2026-07-30T02:16:31+00:00
macosx: use dark appearance helper for appearance checks

- - - - -


9 changed files:

- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/extensions/NSAppearance+VLCAdditions.h
- + modules/gui/macosx/extensions/NSAppearance+VLCAdditions.m
- modules/gui/macosx/extensions/NSView+VLCAdditions.m
- modules/gui/macosx/library/VLCLibraryHeaderView.m
- modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.m
- modules/gui/macosx/library/VLCLibraryWindowPlayQueueSidebarViewController.m
- modules/gui/macosx/views/VLCMediaItemCollectionViewItem.m
- modules/gui/macosx/windows/controlsbar/VLCMainWindowControlsBar.m


Changes:

=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -98,6 +98,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/coreinteraction/VLCHotkeysController.m \
 	gui/macosx/coreinteraction/VLCVideoFilterHelper.h \
 	gui/macosx/coreinteraction/VLCVideoFilterHelper.m \
+	gui/macosx/extensions/NSAppearance+VLCAdditions.h \
+	gui/macosx/extensions/NSAppearance+VLCAdditions.m \
 	gui/macosx/extensions/NSAnimationContext+VLCAdditions.h \
 	gui/macosx/extensions/NSAnimationContext+VLCAdditions.m \
 	gui/macosx/extensions/NSArray+VLCAdditions.h \


=====================================
modules/gui/macosx/extensions/NSAppearance+VLCAdditions.h
=====================================
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * NSAppearance+VLCAdditions.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2026 VLC authors and VideoLAN
+ *
+ * Authors: Serhii Bykov <esphynox at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface NSAppearance (VLCAdditions)
+
+ at property (readonly) BOOL shouldShowDarkAppearance;
+
+ at end
+
+NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/extensions/NSAppearance+VLCAdditions.m
=====================================
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * NSAppearance+VLCAdditions.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2026 VLC authors and VideoLAN
+ *
+ * Authors: Serhii Bykov <esphynox at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "NSAppearance+VLCAdditions.h"
+
+#import "main/CompatibilityFixes.h"
+
+ at implementation NSAppearance (VLCAdditions)
+
+- (BOOL)shouldShowDarkAppearance
+{
+    if (@available(macOS 10.14, *)) {
+        return [self.name isEqualToString:NSAppearanceNameDarkAqua] ||
+               [self.name isEqualToString:NSAppearanceNameVibrantDark];
+    }
+
+    return NO;
+}
+
+ at end


=====================================
modules/gui/macosx/extensions/NSView+VLCAdditions.m
=====================================
@@ -23,7 +23,7 @@
 
 #import "NSView+VLCAdditions.h"
 
-#import "main/CompatibilityFixes.h"
+#import "NSAppearance+VLCAdditions.h"
 
 @implementation NSView (VLCAdditions)
 
@@ -54,12 +54,7 @@
 
 - (BOOL)shouldShowDarkAppearance
 {
-    if (@available(macOS 10.14, *)) {
-        return [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua] ||
-               [self.effectiveAppearance.name isEqualToString:NSAppearanceNameVibrantDark];
-    }
-
-    return NO;
+    return self.effectiveAppearance.shouldShowDarkAppearance;
 }
 
 - (void)enableSubviews:(BOOL)enabled


=====================================
modules/gui/macosx/library/VLCLibraryHeaderView.m
=====================================
@@ -22,6 +22,7 @@
 
 #import "VLCLibraryHeaderView.h"
 
+#import "extensions/NSAppearance+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
@@ -235,8 +236,7 @@ NSString * const VLCLibraryHeaderViewIdentifier = @"VLCLibraryHeaderView";
     } else if ([keyPath isEqualToString:@"effectiveAppearance"]) {
         if (@available(macOS 10.14, *))  {
             NSAppearance * const appearance = change[NSKeyValueChangeNewKey];
-            const BOOL isDark = [appearance.name isEqualToString:NSAppearanceNameDarkAqua] ||
-                                [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
+            const BOOL isDark = appearance.shouldShowDarkAppearance;
             self.backgroundView.layer.borderColor = isDark ?
                 NSColor.VLCDarkSubtleBorderColor.CGColor : NSColor.VLCLightSubtleBorderColor.CGColor;
         }


=====================================
modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.m
=====================================
@@ -22,6 +22,7 @@
 
 #import "VLCLibraryWindowAbstractSidebarViewController.h"
 
+#import "extensions/NSAppearance+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSFont+VLCAdditions.h"
 
@@ -70,11 +71,7 @@
 - (void)updateColorsBasedOnAppearance:(NSAppearance *)appearance
 {
     NSParameterAssert(appearance);
-    BOOL isDark = NO;
-    if (@available(macOS 10.14, *)) {
-        isDark = [appearance.name isEqualToString:NSAppearanceNameDarkAqua] ||
-                 [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
-    }
+    const BOOL isDark = appearance.shouldShowDarkAppearance;
 
     // If we try to pull the view's effectiveAppearance we are going to get the previous
     // appearance's name despite responding to the effectiveAppearance change (???) so it is a


=====================================
modules/gui/macosx/library/VLCLibraryWindowPlayQueueSidebarViewController.m
=====================================
@@ -24,6 +24,7 @@
 
 #import <QuartzCore/QuartzCore.h>
 
+#import "extensions/NSAppearance+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSImage+VLCAdditions.h"
@@ -263,11 +264,7 @@
 {
     [super updateColorsBasedOnAppearance:appearance];
 
-    BOOL isDark = NO;
-    if (@available(macOS 10.14, *)) {
-        isDark = [appearance.name isEqualToString:NSAppearanceNameDarkAqua] || 
-                 [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
-    }
+    const BOOL isDark = appearance.shouldShowDarkAppearance;
 
     // If we try to pull the view's effectiveAppearance we are going to get the previous 
     // appearance's name despite responding to the effectiveAppearance change (???) so it is a


=====================================
modules/gui/macosx/views/VLCMediaItemCollectionViewItem.m
=====================================
@@ -23,6 +23,7 @@
 
 #import "VLCMediaItemCollectionViewItem.h"
 
+#import "extensions/NSAppearance+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
@@ -109,12 +110,7 @@ const CGFloat VLCMediaItemCollectionViewItemMaximumDisplayedProgress = 0.95;
 - (void)updateColoredAppearance:(NSAppearance *)appearance
 {
     NSParameterAssert(appearance);
-    BOOL isDark = NO;
-    if (@available(macOS 10.14, *)) {
-        isDark = 
-            [appearance.name isEqualToString:NSAppearanceNameDarkAqua] ||
-            [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
-    }
+    const BOOL isDark = appearance.shouldShowDarkAppearance;
 
     self.mediaTitleTextField.textColor = isDark 
         ? NSColor.VLClibraryDarkTitleColor


=====================================
modules/gui/macosx/windows/controlsbar/VLCMainWindowControlsBar.m
=====================================
@@ -25,6 +25,7 @@
 
 #import "VLCControlsBarCommon.h"
 
+#import "extensions/NSAppearance+VLCAdditions.h"
 #import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSImage+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
@@ -148,8 +149,7 @@
         return;
     } else if (@available(macOS 10.14, *)) {
         NSAppearance * const appearance = change[NSKeyValueChangeNewKey];
-        const BOOL isDark = [appearance.name isEqualToString:NSAppearanceNameDarkAqua] || 
-                            [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
+        const BOOL isDark = appearance.shouldShowDarkAppearance;
         self.visualEffectView.layer.borderColor = isDark ?
             NSColor.VLCDarkSubtleBorderColor.CGColor : NSColor.VLCLightSubtleBorderColor.CGColor;
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b5536cdea24b313ba9215eacfbd7fa3295d7f3ee

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b5536cdea24b313ba9215eacfbd7fa3295d7f3ee
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list