[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Use only one textfield for song name and artist name in VLCLibraryWindow XIB

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Apr 13 15:17:14 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
7e3b86b8 by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Use only one textfield for song name and artist name in VLCLibraryWindow XIB

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

- - - - -
ec54b314 by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Rename the songNameTextField outlet to more accurate playingItemDisplayField

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

- - - - -
370e0068 by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Update display components showing current media item when the media item changes, rather than on every single tick

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

- - - - -
1698eb9e by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Use custom attributed string with playing item name and artist in main library window control bar

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

- - - - -
b94a2c66 by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Ensure we get the current playing item in control bar

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

- - - - -
b555a373 by Claudio Cambra at 2023-04-13T14:32:29+00:00
macosx: Listen to more reliable VLCPlayerCurrentMediaItemChanged notification in control bar updaters, removing need for workarounds

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

- - - - -


6 changed files:

- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/UI/VLCMainVideoView.xib
- modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h
- modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
- modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h
- modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -368,28 +368,10 @@
                                                     <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="d0e-29-yNq" userLabel="Song Name" customClass="VLCWrappableTextField">
                                                         <rect key="frame" x="-2" y="0.0" width="78" height="16"/>
                                                         <constraints>
+                                                            <constraint firstAttribute="height" constant="16" id="aQy-pz-H7F"/>
                                                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="60" id="uah-Xv-MK9"/>
                                                         </constraints>
-                                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="right" title="Song Name" id="o4l-8l-eNX">
-                                                            <font key="font" metaFont="systemBold"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="XbZ-eQ-zmA">
-                                                        <rect key="frame" x="76" y="0.0" width="14" height="16"/>
-                                                        <textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="·" id="iAI-Pb-eVu">
-                                                            <font key="font" metaFont="systemBlack" size="13"/>
-                                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="0jI-HH-uWa" userLabel="Artist Name" customClass="VLCWrappableTextField">
-                                                        <rect key="frame" x="90" y="0.0" width="76" height="16"/>
-                                                        <constraints>
-                                                            <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="60" id="dVn-o0-6hg"/>
-                                                        </constraints>
-                                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="left" title="Artist Name" id="n8Z-ER-5JE">
+                                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="right" title="Song Name · Artist Name" id="o4l-8l-eNX">
                                                             <font key="font" metaFont="system"/>
                                                             <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -401,13 +383,9 @@
                                                 </constraints>
                                                 <visibilityPriorities>
                                                     <integer value="1000"/>
-                                                    <integer value="1000"/>
-                                                    <integer value="1000"/>
                                                 </visibilityPriorities>
                                                 <customSpacing>
                                                     <real value="3.4028234663852886e+38"/>
-                                                    <real value="3.4028234663852886e+38"/>
-                                                    <real value="3.4028234663852886e+38"/>
                                                 </customSpacing>
                                             </stackView>
                                             <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zOB-QJ-TUy" customClass="VLCTimeField">
@@ -468,7 +446,7 @@
                                             <constraint firstItem="5o7-Z0-dqS" firstAttribute="centerY" secondItem="Ktr-qT-1fr" secondAttribute="centerY" id="6rb-4H-ISj"/>
                                             <constraint firstItem="zOB-QJ-TUy" firstAttribute="centerY" secondItem="9Hg-t2-K5z" secondAttribute="centerY" id="Egp-c6-x6Y"/>
                                             <constraint firstItem="oGd-mG-cFw" firstAttribute="centerY" secondItem="9Hg-t2-K5z" secondAttribute="centerY" id="Gzr-dU-oMG"/>
-                                            <constraint firstItem="jlv-jC-dQB" firstAttribute="bottom" secondItem="9Hg-t2-K5z" secondAttribute="top" constant="-8" id="HiH-c5-MZq"/>
+                                            <constraint firstItem="9Hg-t2-K5z" firstAttribute="top" secondItem="jlv-jC-dQB" secondAttribute="bottom" constant="8" id="HiH-c5-MZq"/>
                                             <constraint firstAttribute="bottom" secondItem="5o7-Z0-dqS" secondAttribute="bottom" id="Hui-Gh-xyv"/>
                                             <constraint firstItem="jlv-jC-dQB" firstAttribute="top" secondItem="Ktr-qT-1fr" secondAttribute="top" id="ORY-q8-DFB"/>
                                             <constraint firstItem="5o7-Z0-dqS" firstAttribute="top" secondItem="Ktr-qT-1fr" secondAttribute="top" id="Qmp-zE-IXn"/>
@@ -825,8 +803,6 @@
         </window>
         <customObject id="Uzf-Tf-H8x" userLabel="Detached Window Controls Bar" customClass="VLCMainWindowControlsBar">
             <connections>
-                <outlet property="artistNameTextField" destination="0jI-HH-uWa" id="ftC-MD-ymJ"/>
-                <outlet property="artistNameTextFieldWidthConstraint" destination="dVn-o0-6hg" id="f7h-af-ae8"/>
                 <outlet property="artworkButton" destination="15t-2s-22l" id="aR1-bU-1to"/>
                 <outlet property="artworkImageView" destination="5o7-Z0-dqS" id="Pns-yT-lKx"/>
                 <outlet property="backwardButton" destination="jGc-Xw-GYI" id="0AG-44-SN3"/>
@@ -836,10 +812,9 @@
                 <outlet property="fullscreenButton" destination="dwM-Uz-pAw" id="gXA-WS-Gig"/>
                 <outlet property="muteVolumeButton" destination="IAy-58-UPp" id="dDN-pE-Vmj"/>
                 <outlet property="playButton" destination="WgO-zh-k4s" id="0yC-Yh-H4V"/>
+                <outlet property="playingItemDisplayField" destination="d0e-29-yNq" id="QUe-1S-TQO"/>
                 <outlet property="repeatButton" destination="t4r-bt-Jxm" id="U7s-Tb-Ado"/>
                 <outlet property="shuffleButton" destination="SYG-jf-oHJ" id="b4m-v0-sC9"/>
-                <outlet property="songArtistSeparatorTextField" destination="XbZ-eQ-zmA" id="lh8-I7-g90"/>
-                <outlet property="songNameTextField" destination="d0e-29-yNq" id="JTI-XG-miC"/>
                 <outlet property="timeField" destination="zOB-QJ-TUy" id="mJL-1V-2lQ"/>
                 <outlet property="timeSlider" destination="9Hg-t2-K5z" id="sVe-s8-xW6"/>
                 <outlet property="trailingTimeField" destination="oGd-mG-cFw" id="geo-iq-0th"/>


=====================================
modules/gui/macosx/UI/VLCMainVideoView.xib
=====================================
@@ -37,7 +37,7 @@
                 <outlet property="fullscreenButton" destination="dYZ-ri-Kra" id="Cw2-BS-QG9"/>
                 <outlet property="fullscreenButtonWidthConstraint" destination="quS-fD-Od7" id="6hT-nR-yQI"/>
                 <outlet property="playButton" destination="PCC-8a-sVF" id="ddT-ZM-Jhz"/>
-                <outlet property="songNameTextField" destination="lEW-MN-FFU" id="btX-L9-7TO"/>
+                <outlet property="playingItemDisplayField" destination="lEW-MN-FFU" id="hKa-df-8UB"/>
                 <outlet property="subtitlesButton" destination="YTl-LZ-WDe" id="893-XB-eDY"/>
                 <outlet property="timeField" destination="3ri-8b-8mw" id="f0i-Gh-R8V"/>
                 <outlet property="timeSlider" destination="qNZ-Fh-W8i" id="Fkk-fj-s5Q"/>


=====================================
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h
=====================================
@@ -52,8 +52,7 @@
 
 @property (readwrite, strong) IBOutlet VLCImageView *artworkImageView;
 @property (readwrite, strong) IBOutlet NSButton *artworkButton;
- at property (readwrite, strong) IBOutlet VLCWrappableTextField *songNameTextField;
- at property (readwrite, strong) IBOutlet VLCWrappableTextField *artistNameTextField;
+ at property (readwrite, strong) IBOutlet VLCWrappableTextField *playingItemDisplayField;
 @property (readwrite, strong) IBOutlet VLCTimeField *timeField;
 @property (readwrite, strong) IBOutlet VLCTimeField *trailingTimeField;
 
@@ -79,5 +78,6 @@
 - (void)updateTimeSlider:(NSNotification *)aNotification;
 - (void)updateVolumeSlider:(NSNotification *)aNotification;
 - (void)updateMuteVolumeButton:(NSNotification *)aNotification;
+- (void)updateCurrentItemDisplayControls:(NSNotification *)aNotification;
 
 @end


=====================================
modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m
=====================================
@@ -26,6 +26,8 @@
 #import "extensions/NSString+Helpers.h"
 #import "main/VLCMain.h"
 #import "playlist/VLCPlaylistController.h"
+#import "playlist/VLCPlaylistItem.h"
+#import "playlist/VLCPlaylistModel.h"
 #import "playlist/VLCPlayerController.h"
 #import "library/VLCInputItem.h"
 
@@ -92,7 +94,12 @@
                                name:VLCPlayerStateChanged
                              object:nil];
     [notificationCenter addObserver:self
-                           selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged
+                           selector:@selector(updatePlaybackControls:)
+                               name:VLCPlayerCurrentMediaItemChanged
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateCurrentItemDisplayControls:)
+                               name:VLCPlayerCurrentMediaItemChanged
                              object:nil];
     [notificationCenter addObserver:self
                            selector:@selector(fullscreenStateUpdated:)
@@ -342,17 +349,6 @@
         return;
     }
 
-    _songNameTextField.stringValue = inputItem.name;
-    _artistNameTextField.stringValue = inputItem.artist;
-
-    NSURL *artworkURL = inputItem.artworkURL;
-
-    if (artworkURL) {
-        [_artworkImageView setImageURL:inputItem.artworkURL placeholderImage:[NSImage imageNamed:@"noart"]];
-    } else {
-        _artworkImageView.image = [NSImage imageNamed:@"noart"];
-    }
-
     [self.timeSlider setHidden:NO];
     [self.timeSlider setKnobHidden:NO];
     [self.timeSlider setFloatValue:_playerController.position];
@@ -427,6 +423,24 @@
     [self.backwardButton setEnabled: (b_seekable || _playlistController.hasPreviousPlaylistItem || b_chapters)];
 }
 
+- (void)updateCurrentItemDisplayControls:(NSNotification *)aNotification
+{
+    VLCInputItem * const inputItem = _playerController.currentMedia;
+    if (!inputItem) {
+        return;
+    }
+
+    _playingItemDisplayField.stringValue = inputItem.name;
+
+    NSURL * const artworkURL = inputItem.artworkURL;
+
+    if (artworkURL) {
+        [_artworkImageView setImageURL:inputItem.artworkURL placeholderImage:[NSImage imageNamed:@"noart"]];
+    } else {
+        _artworkImageView.image = [NSImage imageNamed:@"noart"];
+    }
+}
+
 - (void)setPause
 {
     [self.playButton setImage: _pauseImage];


=====================================
modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.h
=====================================
@@ -43,9 +43,6 @@
 @property (readwrite, strong) IBOutlet NSButton *repeatButton;
 @property (readwrite, strong) IBOutlet NSButton *shuffleButton;
 
- at property (readwrite, strong) IBOutlet NSLayoutConstraint *artistNameTextFieldWidthConstraint;
-
- at property (readwrite, strong) IBOutlet NSTextField *songArtistSeparatorTextField;
 @property (readwrite, strong) IBOutlet NSButton *volumeUpButton;
 
 - (IBAction)stop:(id)sender;


=====================================
modules/gui/macosx/windows/mainwindow/VLCMainWindowControlsBar.m
=====================================
@@ -33,6 +33,8 @@
 #import "main/VLCMain.h"
 
 #import "playlist/VLCPlaylistController.h"
+#import "playlist/VLCPlaylistItem.h"
+#import "playlist/VLCPlaylistModel.h"
 #import "playlist/VLCPlayerController.h"
 
 #import "views/VLCTimeField.h"
@@ -69,7 +71,7 @@
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
     [notificationCenter addObserver:self
                            selector:@selector(updatePlaybackControls:)
-                               name:VLCPlaylistCurrentItemChanged
+                               name:VLCPlayerCurrentMediaItemChanged
                              object:nil];
     [notificationCenter addObserver:self
                            selector:@selector(playbackStateChanged:)
@@ -192,6 +194,31 @@
     [self.volumeUpButton setEnabled: !b_muted];
 }
 
+- (void)updateCurrentItemDisplayControls:(NSNotification *)aNotification;
+{
+    [super updateCurrentItemDisplayControls:aNotification];
+
+    VLCInputItem * const inputItem = _playerController.currentMedia;
+    if (!inputItem) {
+        return;
+    }
+
+    NSFont * const boldSystemFont = [NSFont boldSystemFontOfSize:12.];
+    NSDictionary<NSString *, id> * const boldAttribute = @{NSFontAttributeName: boldSystemFont};
+
+    NSMutableAttributedString * const displayString = [[NSMutableAttributedString alloc] initWithString:inputItem.name attributes:boldAttribute];
+
+    if (inputItem.artist.length != 0) {
+        NSAttributedString * const separator = [[NSAttributedString alloc] initWithString:@" · " attributes:boldAttribute];
+        [displayString appendAttributedString:separator];
+
+        NSAttributedString * const artistString = [[NSAttributedString alloc] initWithString:inputItem.artist];
+        [displayString appendAttributedString:artistString];
+    }
+
+    self.playingItemDisplayField.attributedStringValue = displayString;
+}
+
 - (void)updateMuteVolumeButtonImage
 {
     self.muteVolumeButton.image = imageFromRes(@"VLCVolumeOffTemplate");



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4b8cc4971d7eeabfff9be32fa228e98c5695a44c...b555a373b2920836bc21e0714abf6850346d2263

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4b8cc4971d7eeabfff9be32fa228e98c5695a44c...b555a373b2920836bc21e0714abf6850346d2263
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