[vlc-commits] macosx/playlist: iterate on item display

Felix Paul Kühne git at videolan.org
Sun Mar 10 19:56:02 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Mar 10 18:40:19 2019 +0100| [bd367ce467fecf01ca4a859afc28030847f3005c] | committer: Felix Paul Kühne

macosx/playlist: iterate on item display

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

 modules/gui/macosx/UI/VLCPlaylistTableCellView.xib | 42 +++++++++++++++++-----
 modules/gui/macosx/library/VLCLibraryWindow.m      |  2 +-
 .../gui/macosx/playlist/VLCPlaylistDataSource.m    | 17 +++++++--
 modules/gui/macosx/playlist/VLCPlaylistItem.h      |  1 +
 modules/gui/macosx/playlist/VLCPlaylistItem.m      | 13 +++++++
 .../gui/macosx/playlist/VLCPlaylistTableCellView.h |  2 ++
 .../gui/macosx/playlist/VLCPlaylistTableCellView.m |  7 ++--
 7 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/modules/gui/macosx/UI/VLCPlaylistTableCellView.xib b/modules/gui/macosx/UI/VLCPlaylistTableCellView.xib
index c68cf25a5b..7c19d096b3 100644
--- a/modules/gui/macosx/UI/VLCPlaylistTableCellView.xib
+++ b/modules/gui/macosx/UI/VLCPlaylistTableCellView.xib
@@ -9,50 +9,74 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="c22-O7-iKe" customClass="VLCPlaylistTableCellView">
-            <rect key="frame" x="0.0" y="0.0" width="398" height="65"/>
+            <rect key="frame" x="0.0" y="0.0" width="398" height="71"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ohB-P0-nCv">
-                    <rect key="frame" x="73" y="24" width="37" height="17"/>
+                    <rect key="frame" x="112" y="27" width="37" height="17"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="ZPw-XO-XD1">
                         <font key="font" usesAppearanceFont="YES"/>
                         <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" translatesAutoresizingMaskIntoConstraints="NO" id="xJW-ps-ycn">
+                    <rect key="frame" x="112" y="41" width="37" height="17"/>
+                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="aCe-ia-0Ww">
+                        <font key="font" usesAppearanceFont="YES"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
                 <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Hnm-OH-KKY">
-                    <rect key="frame" x="0.0" y="0.0" width="65" height="65"/>
+                    <rect key="frame" x="0.0" y="3" width="104" height="65"/>
                     <constraints>
-                        <constraint firstAttribute="width" secondItem="Hnm-OH-KKY" secondAttribute="height" multiplier="1:1" id="4tH-UG-Xdn"/>
+                        <constraint firstAttribute="width" secondItem="Hnm-OH-KKY" secondAttribute="height" multiplier="16:10" id="4tH-UG-Xdn"/>
                     </constraints>
                     <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="AB8-xJ-YJC"/>
                 </imageView>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Ha-ZH-fa9">
-                    <rect key="frame" x="353" y="24" width="37" height="17"/>
+                    <rect key="frame" x="349" y="27" width="37" height="17"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="33" id="0cB-ga-0Uw"/>
                     </constraints>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="N0j-xB-3t9">
                         <font key="font" usesAppearanceFont="YES"/>
-                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TPv-k2-6XS">
+                    <rect key="frame" x="112" y="13" width="37" height="17"/>
+                    <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="jZ4-pa-K3T">
+                        <font key="font" usesAppearanceFont="YES"/>
+                        <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
             </subviews>
             <constraints>
+                <constraint firstItem="TPv-k2-6XS" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="4qb-9H-TVg"/>
+                <constraint firstItem="xJW-ps-ycn" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="DYk-9g-adD"/>
+                <constraint firstItem="ohB-P0-nCv" firstAttribute="top" secondItem="xJW-ps-ycn" secondAttribute="bottom" constant="-3" id="Epo-on-wpL"/>
                 <constraint firstItem="3Ha-ZH-fa9" firstAttribute="centerY" secondItem="ohB-P0-nCv" secondAttribute="centerY" id="Flo-4k-Vaz"/>
-                <constraint firstAttribute="bottom" secondItem="Hnm-OH-KKY" secondAttribute="bottom" id="KCN-ec-D7a"/>
+                <constraint firstAttribute="bottom" secondItem="Hnm-OH-KKY" secondAttribute="bottom" constant="3" id="KCN-ec-D7a"/>
                 <constraint firstItem="ohB-P0-nCv" firstAttribute="leading" secondItem="Hnm-OH-KKY" secondAttribute="trailing" constant="10" id="L6s-Ro-Qtx"/>
-                <constraint firstAttribute="trailing" secondItem="3Ha-ZH-fa9" secondAttribute="trailing" constant="10" id="SVJ-UL-O5m"/>
+                <constraint firstItem="3Ha-ZH-fa9" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="10" id="NxZ-be-5y0"/>
+                <constraint firstAttribute="trailing" secondItem="3Ha-ZH-fa9" secondAttribute="trailing" constant="14" id="SVJ-UL-O5m"/>
+                <constraint firstItem="3Ha-ZH-fa9" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="TPv-k2-6XS" secondAttribute="trailing" constant="10" id="feB-7H-8HN"/>
                 <constraint firstItem="ohB-P0-nCv" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="mGo-gc-dR6"/>
-                <constraint firstItem="Hnm-OH-KKY" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="owl-FT-tZX"/>
+                <constraint firstItem="Hnm-OH-KKY" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="3" id="owl-FT-tZX"/>
                 <constraint firstItem="Hnm-OH-KKY" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="vEf-1U-gh4"/>
+                <constraint firstItem="TPv-k2-6XS" firstAttribute="top" secondItem="ohB-P0-nCv" secondAttribute="bottom" constant="-3" id="vSW-bd-8ac"/>
                 <constraint firstItem="3Ha-ZH-fa9" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ohB-P0-nCv" secondAttribute="trailing" constant="10" id="wQv-VX-Hhb"/>
             </constraints>
             <connections>
+                <outlet property="artistTextField" destination="TPv-k2-6XS" id="jJV-4C-USY"/>
                 <outlet property="durationTextField" destination="3Ha-ZH-fa9" id="vbh-oE-Afj"/>
                 <outlet property="mediaImageView" destination="Hnm-OH-KKY" id="SzS-Oe-Ghh"/>
                 <outlet property="mediaTitleTextField" destination="ohB-P0-nCv" id="iS6-q4-h8I"/>
+                <outlet property="secondaryMediaTitleTextField" destination="xJW-ps-ycn" id="KpP-ao-QlW"/>
             </connections>
             <point key="canvasLocation" x="98" y="50.5"/>
         </customView>
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 56c4085aca..7aa877a0c6 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -30,7 +30,7 @@
 
 static const float f_min_window_width = 604.;
 static const float f_min_window_height = 307.;
-static const float f_playlist_row_height = 40.;
+static const float f_playlist_row_height = 72.;
 
 static NSString *VLCLibraryCellIdentifier = @"VLCLibraryCellIdentifier";
 
diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
index f93b9633dc..b930ac7397 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
@@ -78,9 +78,22 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
         return cellView;
     }
 
-    cellView.mediaTitleTextField.stringValue = item.title;
+    NSString *artist = item.artistName;
+    if (artist && artist.length > 0) {
+        cellView.mediaTitleTextField.hidden = YES;
+        cellView.secondaryMediaTitleTextField.hidden = NO;
+        cellView.artistTextField.hidden = NO;
+        cellView.secondaryMediaTitleTextField.stringValue = item.title;
+        cellView.artistTextField.stringValue = artist;
+    } else {
+        cellView.mediaTitleTextField.hidden = NO;
+        cellView.secondaryMediaTitleTextField.hidden = YES;
+        cellView.artistTextField.hidden = YES;
+        cellView.mediaTitleTextField.stringValue = item.title;
+    }
+
     cellView.durationTextField.stringValue = [NSString stringWithTimeFromTicks:item.duration];
-    cellView.mediaImageView.image = [NSImage imageNamed: @"noart.png"];
+    cellView.mediaImageView.image = item.artworkImage;
     cellView.representsCurrentPlaylistItem = _playlistController.currentPlaylistIndex == row;
 
     return cellView;
diff --git a/modules/gui/macosx/playlist/VLCPlaylistItem.h b/modules/gui/macosx/playlist/VLCPlaylistItem.h
index b1b0f28ffb..f9732d945b 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistItem.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistItem.h
@@ -35,6 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, retain, nullable) NSString *artistName;
 @property (readwrite, retain, nullable) NSString *albumName;
 @property (readwrite, retain, nullable) NSString *artworkURLString;
+ at property (readonly, copy) NSImage *artworkImage;
 
 - (instancetype)initWithPlaylistItem:(vlc_playlist_item_t *)p_item;
 - (void)updateRepresentation;
diff --git a/modules/gui/macosx/playlist/VLCPlaylistItem.m b/modules/gui/macosx/playlist/VLCPlaylistItem.m
index 2aca94f26d..92aadfef52 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistItem.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistItem.m
@@ -85,4 +85,17 @@
     return path;
 }
 
+- (NSImage *)artworkImage
+{
+    NSImage *image;
+
+    if (_artworkURLString != nil && _artworkURLString.length > 0) {
+        image = [[NSImage alloc] initWithContentsOfURL: [NSURL URLWithString:_artworkURLString]];
+    } else {
+        image = [NSImage imageNamed: @"noart.png"];
+    }
+
+    return image;
+}
+
 @end
diff --git a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.h b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.h
index 2a3b10730c..5333d88a78 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.h
@@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
 @interface VLCPlaylistTableCellView : NSTableCellView
 
 @property (readwrite, nonatomic) BOOL representsCurrentPlaylistItem;
+ at property (readwrite, assign) IBOutlet NSTextField *artistTextField;
+ at property (readwrite, assign) IBOutlet NSTextField *secondaryMediaTitleTextField;
 @property (readwrite, assign) IBOutlet NSTextField *mediaTitleTextField;
 @property (readwrite, assign) IBOutlet NSTextField *durationTextField;
 @property (readwrite, assign) IBOutlet NSImageView *mediaImageView;
diff --git a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
index bfcbeb515d..1f0bec1b3b 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
@@ -29,11 +29,14 @@ static const float fontSizeForMediaTitle = 13.;
 - (void)setRepresentsCurrentPlaylistItem:(BOOL)representsCurrentPlaylistItem
 {
     _representsCurrentPlaylistItem = representsCurrentPlaylistItem;
+    NSFont *displayedFont;
     if (_representsCurrentPlaylistItem) {
-        self.mediaTitleTextField.font = [NSFont boldSystemFontOfSize:fontSizeForMediaTitle];
+        displayedFont = [NSFont boldSystemFontOfSize:fontSizeForMediaTitle];
     } else {
-        self.mediaTitleTextField.font = [NSFont systemFontOfSize:fontSizeForMediaTitle];
+        displayedFont = [NSFont systemFontOfSize:fontSizeForMediaTitle];
     }
+    self.mediaTitleTextField.font = displayedFont;
+    self.secondaryMediaTitleTextField.font = displayedFont;
 }
 
 @end



More information about the vlc-commits mailing list