diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib index 4c2f970b252a5cf41c40821f843be3a7cef5b645..86049f80a8d6b4b5f5d01357fb19e2bc67cb3b87 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 a4b1aa2523c3604b42dd6eccabb0e24931711c7d..7c40d68e6657400c829a68dba3eee905447a6278 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 8611d7e23898d09dc75c030d789d2fd8d211d1be..01ca4893ffcea9ec77b9f6112c7924743bd212e3 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; +@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; +@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 6747da672b33b1a072ba585674af35be86c2863e..f9bf5fa6463a4d8ca1e2110edc472e4e050cca4b 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 73a778b50207f7fab33f21aef16dffe09dd69dde..884e195d0b99fe110e6e958fef48b41feef2f139 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; +@property (readwrite, assign) NSTextField *counterTextField; - (void)playlistUpdated; diff --git a/modules/gui/macosx/playlist/VLCPlaylistDataSource.m b/modules/gui/macosx/playlist/VLCPlaylistDataSource.m index bbbfdaf316259c6d038a8bf98ea3d4945ade840f..5ccef8232ae852a9d570ffe16646bb4b72c5a016 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 ded84ae0d32bae773849a79d0410339c921ef1b2..df30dd7d79e22f6b95498af67d961166338b2fd7 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 +@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 916ed44a066775807d79986603b8ef19dcfe2b0d..3051695c82d50e270b3676c1725ab423ba13dfc4 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