Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
9d563e19 by Claudio Cambra at 2024-06-18T06:47:25+00:00
macosx: Ensure the detail label is hidden in main video view controls bar if 
not playing a media library media item

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
50cf7695 by Claudio Cambra at 2024-06-18T06:47:25+00:00
macosx: Separate notification handler and detail label update

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
f0335464 by Claudio Cambra at 2024-06-18T06:47:25+00:00
macosx: Separate notification handler and float on top button update

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
ee838b3c by Claudio Cambra at 2024-06-18T06:47:25+00:00
macosx: Override update method in main video view controls bar to update 
relevant components

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -


1 changed file:

- modules/gui/macosx/windows/controlsbar/VLCMainVideoViewControlsBar.m


Changes:

=====================================
modules/gui/macosx/windows/controlsbar/VLCMainVideoViewControlsBar.m
=====================================
@@ -68,20 +68,50 @@
 
     NSNotificationCenter * const notificationCenter = 
NSNotificationCenter.defaultCenter;
     [notificationCenter addObserver:self
-                           selector:@selector(updateDetailLabel:)
+                           selector:@selector(currentMediaItemChanged:)
                                name:VLCPlayerCurrentMediaItemChanged
                              object:nil];
     [notificationCenter addObserver:self
-                           selector:@selector(updateFloatOnTopButton:)
+                           selector:@selector(floatOnTopChanged:)
                                name:VLCWindowFloatOnTopChangedNotificationName
                              object:nil];
+
+    [self update];
+}
+
+- (void)update
+{
+    [super update];
+    [self updateDetailLabel];
+    [self updateFloatOnTopButton];
+}
+
+- (void)currentMediaItemChanged:(NSNotification *)notification
+{
+    [self updateDetailLabel];
+}
+
+- (void)floatOnTopChanged:(NSNotification *)notification
+{
+    VLCVideoWindowCommon * const videoWindow = (VLCVideoWindowCommon 
*)notification.object;
+    NSAssert(videoWindow != nil, @"Received video window should not be nil!");
+    VLCVideoWindowCommon * const selfVideoWindow =
+        (VLCVideoWindowCommon *)self.floatOnTopButton.window;
+
+    if (videoWindow != selfVideoWindow) {
+        return;
+    }
+
+    [self updateFloatOnTopButton];
 }
 
-- (void)updateDetailLabel:(NSNotification *)notification
+- (void)updateDetailLabel
 {
+    VLCMediaLibraryMediaItem * const mediaItem =
+        [VLCMediaLibraryMediaItem 
mediaItemForURL:_playerController.URLOfCurrentMediaItem];
 
-    VLCMediaLibraryMediaItem * const mediaItem = [VLCMediaLibraryMediaItem 
mediaItemForURL:_playerController.URLOfCurrentMediaItem];
     if (!mediaItem) {
+        self.detailLabel.hidden = YES;
         return;
     }
 
@@ -90,6 +120,29 @@
     _detailLabel.stringValue = mediaItem.primaryDetailString;
 }
 
+- (void)updateFloatOnTopButton
+{
+    VLCVideoWindowCommon * const videoWindow = (VLCVideoWindowCommon 
*)self.floatOnTopButton.window;
+    if (videoWindow == nil) {
+        return;
+    }
+
+    VLCVoutView * const voutView = videoWindow.videoViewController.voutView;
+    NSAssert(voutView != nil, @"Vout view should not be nil!");
+    vout_thread_t * const voutThread = voutView.voutThread;
+
+    if (voutThread == NULL) {
+        return;
+    }
+
+    const bool floatOnTopEnabled = var_GetBool(voutThread, "video-on-top");
+
+    if (@available(macOS 10.14, *)) {
+        self.floatOnTopButton.contentTintColor =
+            floatOnTopEnabled ? NSColor.controlAccentColor : 
NSColor.controlTextColor;
+    }
+}
+
 - (IBAction)openBookmarks:(id)sender
 {
     [VLCMain.sharedInstance.bookmarks toggleWindow:sender];
@@ -125,19 +178,4 @@
     vout_Release(p_vout);
 }
 
-- (void)updateFloatOnTopButton:(NSNotification *)notification
-{
-    VLCVideoWindowCommon * const videoWindow = (VLCVideoWindowCommon 
*)notification.object;
-    NSAssert(videoWindow != nil, @"Received video window should not be nil!");
-    NSDictionary<NSString *, NSNumber *> * const userInfo = 
notification.userInfo;
-    NSAssert(userInfo != nil, @"Received user info should not be nil!");
-    NSNumber * const enabledNumberWrapper = 
userInfo[VLCWindowFloatOnTopEnabledNotificationKey];
-    NSAssert(enabledNumberWrapper != nil, @"Received user info enabled wrapper 
should not be nil!");
-
-    if (@available(macOS 10.14, *)) {
-        self.floatOnTopButton.contentTintColor =
-            enabledNumberWrapper.boolValue ? NSColor.controlAccentColor : 
NSColor.controlTextColor;
-    }
-}
-
 @end



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/02c3a9e7fcc709ca84d993a9192ef0773d9b1e30...ee838b3c6a4e31565763ec6c7b9aa6b737beb629

-- 
This project does not include diff previews in email notifications.
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/02c3a9e7fcc709ca84d993a9192ef0773d9b1e30...ee838b3c6a4e31565763ec6c7b9aa6b737beb629
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to