[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Ensure control bar repeat button image gets correctly updated

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jan 6 12:22:26 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e834b31f by Claudio Cambra at 2023-01-06T10:38:52+00:00
macosx: Ensure control bar repeat button image gets correctly updated

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
7d274452 by Claudio Cambra at 2023-01-06T10:38:52+00:00
macosx: Ensure control bar shuffle button image gets correctly updated

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m


Changes:

=====================================
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
=====================================
@@ -24,6 +24,7 @@
 #import "VLCControlsBarCommon.h"
 
 #import "extensions/NSString+Helpers.h"
+#import "extensions/NSColor+VLCAdditions.h"
 #import "main/VLCMain.h"
 #import "playlist/VLCPlaylistController.h"
 #import "playlist/VLCPlayerController.h"
@@ -75,10 +76,29 @@
     _playerController = _playlistController.playerController;
 
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
-    [notificationCenter addObserver:self selector:@selector(updateTimeSlider:) name:VLCPlayerTimeAndPositionChanged object:nil];
-    [notificationCenter addObserver:self selector:@selector(playerStateUpdated:) name:VLCPlayerStateChanged object:nil];
-    [notificationCenter addObserver:self selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged object:nil];
-    [notificationCenter addObserver:self selector:@selector(fullscreenStateUpdated:) name:VLCPlayerFullscreenChanged object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateTimeSlider:)
+                               name:VLCPlayerTimeAndPositionChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(playerStateUpdated:)
+                               name:VLCPlayerStateChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(fullscreenStateUpdated:)
+                               name:VLCPlayerFullscreenChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(shuffleStateUpdated:)
+                               name:VLCPlaybackOrderChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(repeatStateUpdated:)
+                               name:VLCPlaybackRepeatChanged
+                             object:nil];
 
     _nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode");
 
@@ -142,6 +162,8 @@
     [self.backwardButton setAction:@selector(bwd:)];
 
     [self playerStateUpdated:nil];
+    [self repeatStateUpdated:nil];
+    [self shuffleStateUpdated:nil];
 
     [_artworkImageView setCropsImagesToRoundedCorners:YES];
     [_artworkImageView setImage:[NSImage imageNamed:@"noart"]];
@@ -151,13 +173,8 @@
     _repeatOffImage = [NSImage imageNamed:@"repeatOff"];
     _repeatOneImage = [NSImage imageNamed:@"repeatOne"];
 
-    [_repeatButton setImage:_repeatOffImage];
-
     _shuffleOffImage = [NSImage imageNamed:@"shuffleOff"];
     _shuffleOnImage = [NSImage imageNamed:@"shuffleOn"];
-
-    [_shuffleButton setImage:_shuffleOffImage];
-
 }
 
 - (void)dealloc
@@ -352,6 +369,40 @@
     }
 }
 
+- (void)repeatStateUpdated:(NSNotification *)aNotification
+{
+    enum vlc_playlist_playback_repeat currentRepeatState = _playlistController.playbackRepeat;
+
+    switch (currentRepeatState) {
+        case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT:
+            self.repeatButton.image = _repeatOneImage;
+            break;
+        case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL:
+            self.repeatButton.image = _repeatAllImage;
+            break;
+        case VLC_PLAYLIST_PLAYBACK_REPEAT_NONE:
+        default:
+            self.repeatButton.image = _repeatOffImage;
+            break;
+    }
+
+    if (@available(macOS 11.0, *)) {
+        self.repeatButton.contentTintColor = currentRepeatState == VLC_PLAYLIST_PLAYBACK_REPEAT_NONE ?
+            nil : [NSColor VLCAccentColor];
+    }
+}
+
+- (void)shuffleStateUpdated:(NSNotification *)aNotification
+{
+    self.shuffleButton.image = _playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL ?
+        _shuffleOffImage : _shuffleOnImage;
+
+    if (@available(macOS 11.0, *)) {
+        self.shuffleButton.contentTintColor = _playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL ?
+            nil : [NSColor VLCAccentColor];
+    }
+}
+
 - (void)updatePlaybackControls:(NSNotification *)aNotification
 {
     bool b_seekable = _playerController.seekable;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6c08c24b075157241eaca3543bb77107a1b9b853...7d274452f204e1151c7db64199b98026163f1419

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6c08c24b075157241eaca3543bb77107a1b9b853...7d274452f204e1151c7db64199b98026163f1419
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list