[vlc-commits] macosx/playlist: add indicator for the number of items

Felix Paul Kühne git at videolan.org
Fri May 31 15:05:36 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri May 31 15:05:20 2019 +0200| [5715f6df2300700571e1c3ffff1e8fa719391e32] | committer: Felix Paul Kühne

macosx/playlist: add indicator for the number of items

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

 modules/gui/macosx/UI/VLCLibraryWindow.xib         | 13 +++++++++++-
 .../macosx/library/VLCLibraryCollectionViewItem.m  |  4 ++--
 modules/gui/macosx/library/VLCLibraryWindow.h      |  2 ++
 modules/gui/macosx/library/VLCLibraryWindow.m      |  6 ++++++
 .../gui/macosx/playlist/VLCPlaylistDataSource.h    |  1 +
 .../gui/macosx/playlist/VLCPlaylistDataSource.m    |  6 +++++-
 .../gui/macosx/views/VLCRoundedCornerTextField.h   |  2 ++
 .../gui/macosx/views/VLCRoundedCornerTextField.m   | 24 +++++++++++++++++++++-
 8 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib
index 4c2f970b25..86049f80a8 100644
--- a/modules/gui/macosx/UI/VLCLibraryWindow.xib
+++ b/modules/gui/macosx/UI/VLCLibraryWindow.xib
@@ -23,7 +23,7 @@
                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
                     <segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="W1M-0o-qYG">
-                        <rect key="frame" x="212" y="333" width="56" height="23"/>
+                        <rect key="frame" x="212.5" y="333" width="56" height="23"/>
                         <segmentedCell key="cell" borderStyle="border" alignment="left" style="texturedRounded" trackingMode="selectOne" id="Twg-gp-8ng">
                             <font key="font" metaFont="system"/>
                             <segments>
@@ -52,6 +52,14 @@
                                             <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                     </textField>
+                                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mbV-My-cm7" customClass="VLCRoundedCornerTextField">
+                                        <rect key="frame" x="182" y="230" width="37" height="17"/>
+                                        <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="4hq-fU-NXW">
+                                            <font key="font" metaFont="system"/>
+                                            <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                        </textFieldCell>
+                                    </textField>
                                     <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="qmL-Ar-cj1">
                                         <rect key="frame" x="20" y="220" width="197" height="5"/>
                                     </box>
@@ -212,9 +220,11 @@
                                     <constraint firstItem="TET-5r-zHx" firstAttribute="leading" secondItem="qmL-Ar-cj1" secondAttribute="leading" id="jsm-nZ-hT7"/>
                                     <constraint firstItem="qmL-Ar-cj1" firstAttribute="top" secondItem="TET-5r-zHx" secondAttribute="bottom" constant="7" id="lz9-Mt-0RI"/>
                                     <constraint firstItem="qmL-Ar-cj1" firstAttribute="leading" secondItem="dus-WQ-AmE" secondAttribute="leading" constant="20" id="st7-tK-qLh"/>
+                                    <constraint firstItem="mbV-My-cm7" firstAttribute="trailing" secondItem="qmL-Ar-cj1" secondAttribute="trailing" id="wcN-mU-GN0"/>
                                     <constraint firstAttribute="trailing" secondItem="Z7y-D0-11Q" secondAttribute="trailing" id="x0A-xI-BVt"/>
                                     <constraint firstItem="jg5-33-vH0" firstAttribute="firstBaseline" secondItem="cih-xp-HmY" secondAttribute="firstBaseline" id="xwe-Nb-2Rz"/>
                                     <constraint firstItem="VFI-oW-dMZ" firstAttribute="leading" secondItem="dus-WQ-AmE" secondAttribute="leading" id="y24-g1-nh1"/>
+                                    <constraint firstItem="mbV-My-cm7" firstAttribute="centerY" secondItem="TET-5r-zHx" secondAttribute="centerY" id="yW0-3I-bbG"/>
                                     <constraint firstItem="nAW-KH-ipk" firstAttribute="top" secondItem="VFI-oW-dMZ" secondAttribute="bottom" id="yZy-ia-HIz"/>
                                     <constraint firstAttribute="bottom" secondItem="nAW-KH-ipk" secondAttribute="bottom" constant="54" id="z8O-Xk-fS8"/>
                                     <constraint firstItem="jg5-33-vH0" firstAttribute="leading" secondItem="dus-WQ-AmE" secondAttribute="leading" constant="20" id="zEw-GJ-NfA"/>
@@ -512,6 +522,7 @@
                 <outlet property="mediaSourceCollectionView" destination="r7v-GI-W1U" id="3JJ-GU-o5o"/>
                 <outlet property="mediaSourceScrollView" destination="cFG-c9-cI9" id="gRO-Y7-kdb"/>
                 <outlet property="openMediaButton" destination="SWh-4E-Qtf" id="sIZ-xo-GLA"/>
+                <outlet property="playlistCounterTextField" destination="mbV-My-cm7" id="ZYU-Jq-Z8R"/>
                 <outlet property="playlistDragDropView" destination="VFI-oW-dMZ" id="gVc-mu-f8T"/>
                 <outlet property="playlistTableView" destination="Fr1-af-8gb" id="yaB-Ab-jrx"/>
                 <outlet property="playlistView" destination="dus-WQ-AmE" id="fTF-HP-Chb"/>
diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
index a4b1aa2523..7c40d68e66 100644
--- a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
@@ -184,10 +184,10 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
 - (void)showVideoSizeIfNeededForWidth:(CGFloat)width andHeight:(CGFloat)height
 {
     if (width >= VLCMediaLibrary4KWidth || height >= VLCMediaLibrary4KHeight) {
-        _annotationTextField.stringValue = @" 4K ";
+        _annotationTextField.stringValue = _NS("4K");
         _annotationTextField.hidden = NO;
     } else if (width >= VLCMediaLibrary720pWidth || height >= VLCMediaLibrary720pHeight) {
-        _annotationTextField.stringValue = @" HD ";
+        _annotationTextField.stringValue = _NS("HD");
         _annotationTextField.hidden = NO;
     }
 }
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.h b/modules/gui/macosx/library/VLCLibraryWindow.h
index 8611d7e238..01ca4893ff 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.h
+++ b/modules/gui/macosx/library/VLCLibraryWindow.h
@@ -25,6 +25,7 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @class VLCDragDropView;
+ at class VLCRoundedCornerTextField;
 
 @interface VLCLibraryWindowController : NSWindowController
 
@@ -56,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, weak) IBOutlet NSBox *clearPlaylistSeparator;
 @property (readwrite, weak) IBOutlet NSButton *repeatPlaylistButton;
 @property (readwrite, weak) IBOutlet NSButton *shufflePlaylistButton;
+ at property (readwrite, weak) IBOutlet VLCRoundedCornerTextField *playlistCounterTextField;
 @property (readwrite, weak) IBOutlet NSView *alternativeAudioView;
 @property (readwrite, weak) IBOutlet NSCollectionView *alternativeAudioCollectionView;
 @property (readwrite, weak) IBOutlet NSSegmentedControl *alternativeAudioSegmentedControl;
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 6747da672b..f9bf5fa646 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -42,6 +42,7 @@
 #import "media-source/VLCMediaSourceDataSource.h"
 
 #import "views/VLCDragDropView.h"
+#import "views/VLCRoundedCornerTextField.h"
 
 #import "windows/mainwindow/VLCControlsBarCommon.h"
 #import "windows/video/VLCFSPanelController.h"
@@ -141,11 +142,16 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
     [_segmentedTitleControl setSelectedSegment:0];
 
     _playlistDragDropView.dropTarget = self;
+    _playlistCounterTextField.useStrongRounding = YES;
+    _playlistCounterTextField.font = [NSFont VLCplaylistSelectedItemLabelFont];
+    _playlistCounterTextField.textColor = [NSColor VLClibraryAnnotationColor];
+    _playlistCounterTextField.hidden = YES;
 
     _playlistDataSource = [[VLCPlaylistDataSource alloc] init];
     _playlistDataSource.playlistController = _playlistController;
     _playlistDataSource.tableView = _playlistTableView;
     _playlistDataSource.dragDropView = _playlistDragDropView;
+    _playlistDataSource.counterTextField = _playlistCounterTextField;
     _playlistController.playlistDataSource = _playlistDataSource;
 
     _playlistTableView.dataSource = _playlistDataSource;
diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.h b/modules/gui/macosx/playlist/VLCPlaylistDataSource.h
index 73a778b502..884e195d0b 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistDataSource.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistDataSource.h
@@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, assign, nonatomic) VLCPlaylistController *playlistController;
 @property (readwrite, assign) NSTableView *tableView;
 @property (readwrite, assign) VLCDragDropView *dragDropView;
+ at property (readwrite, assign) NSTextField *counterTextField;
 
 - (void)playlistUpdated;
 
diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
index bbbfdaf316..5ccef8232a 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m
@@ -86,9 +86,13 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
 
 - (void)playlistUpdated
 {
-    self.dragDropView.hidden = _playlistModel.numberOfPlaylistItems > 0 ? YES : NO;
+    NSUInteger numberOfPlaylistItems = _playlistModel.numberOfPlaylistItems;
+    self.dragDropView.hidden = numberOfPlaylistItems > 0 ? YES : NO;
+    self.counterTextField.hidden = numberOfPlaylistItems == 0 ? YES : NO;
+    self.counterTextField.stringValue = [NSString stringWithFormat:@"%lu", numberOfPlaylistItems];
 
     [_tableView reloadData];
 }
 
 @end
+
diff --git a/modules/gui/macosx/views/VLCRoundedCornerTextField.h b/modules/gui/macosx/views/VLCRoundedCornerTextField.h
index ded84ae0d3..df30dd7d79 100644
--- a/modules/gui/macosx/views/VLCRoundedCornerTextField.h
+++ b/modules/gui/macosx/views/VLCRoundedCornerTextField.h
@@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCRoundedCornerTextField : NSTextField
 
+ at property (readwrite, assign, nonatomic) BOOL useStrongRounding;
+
 @end
 
 NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/views/VLCRoundedCornerTextField.m b/modules/gui/macosx/views/VLCRoundedCornerTextField.m
index 916ed44a06..3051695c82 100644
--- a/modules/gui/macosx/views/VLCRoundedCornerTextField.m
+++ b/modules/gui/macosx/views/VLCRoundedCornerTextField.m
@@ -23,6 +23,9 @@
 #import "VLCRoundedCornerTextField.h"
 #import "extensions/NSColor+VLCAdditions.h"
 
+const CGFloat VLCRoundedCornerTextFieldLightCornerRadius = 3.;
+const CGFloat VLCRoundedCornerTextFieldStrongCornerRadius = 10.;
+
 @implementation VLCRoundedCornerTextField
 
 - (instancetype)initWithCoder:(NSCoder *)coder
@@ -46,7 +49,7 @@
 - (void)setupCustomAppearance
 {
     self.wantsLayer = YES;
-    self.layer.cornerRadius = 3.;
+    self.layer.cornerRadius = VLCRoundedCornerTextFieldLightCornerRadius;
     self.layer.masksToBounds = YES;
     self.layer.backgroundColor = [NSColor VLClibraryAnnotationBackgroundColor].CGColor;
 }
@@ -56,4 +59,23 @@
     self.layer.backgroundColor = backgroundColor.CGColor;
 }
 
+- (void)setUseStrongRounding:(BOOL)useStrongRounding
+{
+    _useStrongRounding = useStrongRounding;
+    if (_useStrongRounding) {
+        self.layer.cornerRadius = VLCRoundedCornerTextFieldStrongCornerRadius;
+    } else {
+        self.layer.cornerRadius = VLCRoundedCornerTextFieldLightCornerRadius;
+    }
+}
+
+- (void)setStringValue:(NSString *)stringValue
+{
+    if (stringValue != nil) {
+        [super setStringValue:[NSString stringWithFormat:@" %@ ", stringValue]];
+    } else {
+        [super setStringValue:@""];
+    }
+}
+
 @end



More information about the vlc-commits mailing list