1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-04 09:11:33 +02:00

macosx/playlist: add indicator for the number of items

This commit is contained in:
Felix Paul Kühne 2019-05-31 15:05:20 +02:00
parent a4dac2767d
commit 5715f6df23
8 changed files with 53 additions and 5 deletions

View File

@ -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"/>

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCRoundedCornerTextField : NSTextField
@property (readwrite, assign, nonatomic) BOOL useStrongRounding;
@end
NS_ASSUME_NONNULL_END

View File

@ -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