[vlc-commits] [Git][videolan/vlc][master] 32 commits: macosx: Add and setup a header label for playlist sidebar
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Oct 28 11:48:30 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
f87eb88f by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Add and setup a header label for playlist sidebar
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
7161131d by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: When no chapters available, hide segmented view control and show playlists label
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3df7338a by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Ensure top constraint of playlist header is adjusted when main video mode enabled
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
aece2906 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Ensure playlist sidebar header does not get crushed
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
34e4b08c by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Increase spacing between leading edge of sidebar root view and superview
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1b1eb6af by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Ensure playlist title is set up before setting main video view mode
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f40bcc70 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Separate updating of top constraints after setting main video view mode from main video view mode setter
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
686e83b5 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Fix setting of active state of top internal constraint for sidebar root view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
55cf993e by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Re-instantiate top internal constraint if it has been dealloced
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
d06d1f73 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Simply use strong property type for top internal constraint
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
edd7e35a by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Fix position of playlist count label
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4978ef3d by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Move initial view selector setup to own method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
eb399d18 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Ensure correct init of rounded corner text field if initing with init
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
80e9d3aa by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Set expected state of reounded corner text field customisation properties in internal setup
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
85ad9e3c by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Add and set up a counter label in the sidebar root view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
218c5b53 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Adjust constraint to use when deciding which header type to use in root sidebar view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
af5a9ad7 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Add sidebar child view controller protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
7e9504bb by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Employ sidebar child view controller protocol in abstract sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
00910ddd by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Implement child view controller protocol property getters in chapters sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
c194f595 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Implement child view controller protocol property getters in playlist sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4a55ce31 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Modify existing child view setter method to apply child view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ad7c2010 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Add optional counter label to sidebar child view controller protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2a32b7a2 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Synthesize supportsItemCount in abstract sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
d29b7c70 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Implement counterLabel handling in chapters sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
68aafeaa by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Implement counterLabel handling in playlist sidebar view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
62a8f1e8 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Adapt counterTextField handling in playlist data source to new counterLabel UI
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ccedfba1 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Remove old counter text field within playlist sidebar view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
fe92a5dc by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Adapt counter label handling in sidebar root view controller to change in child vc protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
6f2516f0 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Remove now unused itemCount from sidebar child view controller protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1abfbaec by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Remove unnecessary custom setter in rounded corner text field
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
52cf6eee by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Fix background drawing in rounded corner text field
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
456d7c92 by Claudio Cambra at 2024-10-28T11:34:23+00:00
macosx: Provide titles for sidebar child view controllers via protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
15 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCLibraryWindowPlaylistView.xib
- modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.h
- modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.m
- modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.h
- modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.m
- modules/gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.h
- modules/gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.m
- + modules/gui/macosx/library/VLCLibraryWindowSidebarChildViewController.h
- modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.h
- modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.m
- modules/gui/macosx/playlist/VLCPlaylistDataSource.h
- modules/gui/macosx/playlist/VLCPlaylistDataSource.m
- modules/gui/macosx/views/VLCRoundedCornerTextField.m
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -310,6 +310,7 @@
5317FE02294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryCollectionViewDelegate.h; sourceTree = "<group>"; };
5317FE03294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryCollectionViewDelegate.m; sourceTree = "<group>"; };
5317FE05294E8D1A001702F0 /* VLCLibraryCollectionViewDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryCollectionViewDataSource.h; sourceTree = "<group>"; };
+ 53222C002CBBDBEE00CB9FA2 /* VLCLibraryWindowSidebarChildViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowSidebarChildViewController.h; sourceTree = "<group>"; };
532572012C3D79D80068DEC3 /* VLCLibrarySegmentBookmarkedLocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibrarySegmentBookmarkedLocation.h; sourceTree = "<group>"; };
532572022C3D79D80068DEC3 /* VLCLibrarySegmentBookmarkedLocation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibrarySegmentBookmarkedLocation.m; sourceTree = "<group>"; };
532572042C3EF3710068DEC3 /* VLCLibraryWindowNavigationSidebarOutlineView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowNavigationSidebarOutlineView.h; sourceTree = "<group>"; };
@@ -1404,6 +1405,7 @@
5352B37529E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m */,
53D21A1D2BB465600085C71B /* VLCLibraryWindowPlaylistSidebarViewController.h */,
53D21A1E2BB465600085C71B /* VLCLibraryWindowPlaylistSidebarViewController.m */,
+ 53222C002CBBDBEE00CB9FA2 /* VLCLibraryWindowSidebarChildViewController.h */,
5341F1512C9865DD003BDF0A /* VLCLibraryWindowSidebarRootViewController.h */,
5341F1522C9865DD003BDF0A /* VLCLibraryWindowSidebarRootViewController.m */,
53F0209F2A91115D00E79705 /* VLCLibraryWindowSplitViewController.h */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -180,6 +180,7 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/library/VLCLibraryWindowPersistentPreferences.m \
gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.h \
gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.m \
+ gui/macosx/library/VLCLibraryWindowSidebarChildViewController.h \
gui/macosx/library/VLCLibraryWindowSidebarRootViewController.h \
gui/macosx/library/VLCLibraryWindowSidebarRootViewController.m \
gui/macosx/library/VLCLibraryWindowSplitViewController.h \
=====================================
modules/gui/macosx/UI/VLCLibraryWindowPlaylistView.xib
=====================================
@@ -9,7 +9,6 @@
<customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryWindowPlaylistSidebarViewController">
<connections>
<outlet property="bottomButtonsSeparator" destination="ew3-Pn-diG" id="N5L-cw-953"/>
- <outlet property="counterTextField" destination="jFQ-fK-HXk" id="3wU-kI-MJU"/>
<outlet property="dragDropImageBackgroundBox" destination="aUB-Ld-N2o" id="9xc-5h-uRF"/>
<outlet property="dragDropView" destination="grx-kk-1X1" id="b1W-Zw-a7Z"/>
<outlet property="openMediaButton" destination="ghp-DI-YmZ" id="30J-m7-gLb"/>
@@ -213,14 +212,6 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
- <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jFQ-fK-HXk" customClass="VLCRoundedCornerTextField">
- <rect key="frame" x="455" y="245" width="37" height="16"/>
- <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="tb3-x5-A5U">
- <font key="font" metaFont="message"/>
- <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
- <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
- </textFieldCell>
- </textField>
</subviews>
<constraints>
<constraint firstItem="ik5-L4-VLw" firstAttribute="top" secondItem="NJR-gf-yTs" secondAttribute="top" id="1za-9j-6sD"/>
@@ -228,7 +219,6 @@
<constraint firstItem="grx-kk-1X1" firstAttribute="top" secondItem="ik5-L4-VLw" secondAttribute="bottom" id="AoR-Q7-XYJ"/>
<constraint firstItem="ik5-L4-VLw" firstAttribute="leading" secondItem="NJR-gf-yTs" secondAttribute="leading" constant="20" id="CW2-KK-Z5t"/>
<constraint firstItem="EIb-Is-vco" firstAttribute="top" secondItem="ik5-L4-VLw" secondAttribute="bottom" id="Cyw-MK-W8n"/>
- <constraint firstItem="jFQ-fK-HXk" firstAttribute="trailing" secondItem="ik5-L4-VLw" secondAttribute="trailing" id="DEp-cT-Pdg"/>
<constraint firstAttribute="trailing" secondItem="ew3-Pn-diG" secondAttribute="trailing" constant="20" id="Hwc-K8-2WQ"/>
<constraint firstAttribute="bottom" secondItem="ew3-Pn-diG" secondAttribute="bottom" constant="54" id="OnX-TC-nMG"/>
<constraint firstAttribute="trailing" secondItem="EIb-Is-vco" secondAttribute="trailing" id="UAJ-gH-fWy"/>
=====================================
modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.h
=====================================
@@ -22,11 +22,13 @@
#import <Cocoa/Cocoa.h>
+#import "library/VLCLibraryWindowSidebarChildViewController.h"
+
NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryWindow;
- at interface VLCLibraryWindowAbstractSidebarViewController : NSViewController
+ at interface VLCLibraryWindowAbstractSidebarViewController : NSViewController<VLCLibraryWindowSidebarChildViewController>
@property (readonly, weak) VLCLibraryWindow *libraryWindow;
@property (readwrite, weak) IBOutlet NSBox *titleSeparator;
=====================================
modules/gui/macosx/library/VLCLibraryWindowAbstractSidebarViewController.m
=====================================
@@ -30,6 +30,8 @@
@implementation VLCLibraryWindowAbstractSidebarViewController
+ at synthesize supportsItemCount = _supportsItemCount;
+
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
nibName:(NSString *)nibName
{
=====================================
modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.h
=====================================
@@ -33,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, weak) IBOutlet NSTableView *tableView;
@property (readonly) NSArrayController *chaptersArrayController;
+ at property (readwrite, nonatomic) NSTextField *counterLabel;
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow;
=====================================
modules/gui/macosx/library/VLCLibraryWindowChaptersSidebarViewController.m
=====================================
@@ -22,14 +22,23 @@
#import "VLCLibraryWindowChaptersSidebarViewController.h"
+#import "extensions/NSString+Helpers.h"
#import "library/VLCLibraryDataTypes.h"
#import "main/VLCMain.h"
#import "playlist/VLCPlayerChapter.h"
#import "playlist/VLCPlayerController.h"
#import "playlist/VLCPlaylistController.h"
+ at interface VLCLibraryWindowChaptersSidebarViewController ()
+
+ at property (readwrite) NSUInteger internalItemCount;
+
+ at end
+
@implementation VLCLibraryWindowChaptersSidebarViewController
+ at synthesize counterLabel = _counterLabel;
+
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
{
return [super initWithLibraryWindow:libraryWindow
@@ -65,6 +74,22 @@
object:nil];
}
+- (NSString *)title
+{
+ return _NS("Chapters");
+}
+
+- (BOOL)supportsItemCount
+{
+ return YES;
+}
+
+- (void)setCounterLabel:(NSTextField *)counterLabel
+{
+ _counterLabel = counterLabel;
+ self.counterLabel.stringValue = [NSString stringWithFormat:@"%lu", self.internalItemCount];
+}
+
- (void)titleListChanged:(NSNotification *)notification
{
[self updateChapterList];
@@ -83,6 +108,7 @@
const struct vlc_player_chapter * const pp_chapters = title->chapters;
const size_t chapterCount = title->chapter_count;
+ self.internalItemCount = chapterCount;
NSMutableArray * const chapters = [NSMutableArray arrayWithCapacity:chapterCount];
for (size_t i = 0; i < chapterCount; i++) {
struct vlc_player_chapter p_chapter = pp_chapters[i];
@@ -90,6 +116,7 @@
[chapters addObject:chapter];
}
self.chaptersArrayController.content = chapters.copy;
+ self.counterLabel.stringValue = [NSString stringWithFormat:@"%lu", chapterCount];
}
# pragma mark - NSTableView delegation
=====================================
modules/gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.h
=====================================
@@ -34,7 +34,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCLibraryWindowPlaylistSidebarViewController : VLCLibraryWindowAbstractSidebarViewController
- at property (readwrite, weak) IBOutlet VLCRoundedCornerTextField *counterTextField;
@property (readwrite, weak) IBOutlet NSTableView *tableView;
@property (readwrite, weak) IBOutlet VLCDragDropView *dragDropView;
@property (readwrite, weak) IBOutlet NSBox *dragDropImageBackgroundBox;
@@ -43,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, weak) IBOutlet NSButton *repeatButton;
@property (readwrite, weak) IBOutlet NSButton *shuffleButton;
+ at property (readwrite, nonatomic) NSTextField *counterLabel;
+
@property (readonly) VLCPlaylistController *playlistController;
@property (readonly) VLCPlaylistDataSource *dataSource;
@property (readonly) VLCPlaylistSortingMenuController *sortingMenuController;
=====================================
modules/gui/macosx/library/VLCLibraryWindowPlaylistSidebarViewController.m
=====================================
@@ -39,6 +39,8 @@
@implementation VLCLibraryWindowPlaylistSidebarViewController
+ at synthesize counterLabel = _counterLabel;
+
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
{
return [super initWithLibraryWindow:libraryWindow
@@ -50,17 +52,13 @@
[super viewDidLoad];
self.dragDropView.dropTarget = self.libraryWindow;
- self.counterTextField.useStrongRounding = YES;
- self.counterTextField.font = [NSFont boldSystemFontOfSize:NSFont.systemFontSize];
- self.counterTextField.textColor = NSColor.VLClibraryAnnotationColor;
- self.counterTextField.hidden = YES;
_playlistController = VLCMain.sharedInstance.playlistController;
_dataSource = [[VLCPlaylistDataSource alloc] init];
self.dataSource.playlistController = self.playlistController;
self.dataSource.tableView = self.tableView;
self.dataSource.dragDropView = self.dragDropView;
- self.dataSource.counterTextField = self.counterTextField;
+ self.dataSource.counterTextField = self.counterLabel;
[self.dataSource prepareForUse];
self.playlistController.playlistDataSource = self.dataSource;
@@ -86,6 +84,22 @@
object:nil];
}
+- (NSString *)title
+{
+ return _NS("Playlist");
+}
+
+- (BOOL)supportsItemCount
+{
+ return YES;
+}
+
+- (void)setCounterLabel:(NSTextField *)counterLabel
+{
+ _counterLabel = counterLabel;
+ self.dataSource.counterTextField = counterLabel;
+}
+
#pragma mark - appearance setters
- (void)updateColorsBasedOnAppearance:(NSAppearance *)appearance
=====================================
modules/gui/macosx/library/VLCLibraryWindowSidebarChildViewController.h
=====================================
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * VLCLibraryWindowSidebarRootViewController.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2024 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at protocol VLCLibraryWindowSidebarChildViewController <NSObject>
+
+ at property (readonly) NSString *title;
+ at property (readonly) BOOL supportsItemCount;
+
+ at optional
+
+ at property (readwrite, nonatomic, nullable) NSTextField *counterLabel;
+
+ at end
+
+NS_ASSUME_NONNULL_END
+
=====================================
modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.h
=====================================
@@ -22,6 +22,7 @@
#import <Cocoa/Cocoa.h>
+ at class VLCRoundedCornerTextField;
@class VLCLibraryWindow;
@class VLCLibraryWindowChaptersSidebarViewController;
@class VLCLibraryWindowPlaylistSidebarViewController;
@@ -36,10 +37,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, weak) IBOutlet NSSegmentedControl *viewSelector;
@property (readwrite, weak) IBOutlet NSView *targetView;
- at property (readwrite, weak) IBOutlet NSLayoutConstraint *topInternalConstraint;
+
+// Retain strongly as when showing/hiding the view selector this can get deallocated otherwise
+ at property (readwrite, strong) IBOutlet NSLayoutConstraint *topInternalConstraint;
@property (readwrite, nonatomic) BOOL mainVideoModeEnabled;
+ at property (readonly) VLCRoundedCornerTextField *counterLabel;
+ at property (readonly) NSLayoutConstraint *counterLabelInHeaderConstraint;
+ at property (readonly) NSLayoutConstraint *counterLabelInChildViewConstraint;
+ at property (readonly) NSLayoutConstraint *playlistHeaderTopConstraint;
+ at property (readonly) NSTextField *playlistHeaderLabel;
+
@property (readonly) VLCLibraryWindowPlaylistSidebarViewController *playlistSidebarViewController;
@property (readonly) VLCLibraryWindowChaptersSidebarViewController *chaptersSidebarViewController;
=====================================
modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.m
=====================================
@@ -22,6 +22,7 @@
#import "VLCLibraryWindowSidebarRootViewController.h"
+#import "extensions/NSFont+VLCAdditions.h"
#import "extensions/NSString+Helpers.h"
#import "extensions/NSWindow+VLCAdditions.h"
@@ -31,13 +32,22 @@
#import "library/VLCLibraryWindow.h"
#import "library/VLCLibraryWindowChaptersSidebarViewController.h"
#import "library/VLCLibraryWindowPlaylistSidebarViewController.h"
+#import "library/VLCLibraryWindowSidebarChildViewController.h"
#import "playlist/VLCPlayerController.h"
#import "playlist/VLCPlaylistController.h"
+#include "views/VLCRoundedCornerTextField.h"
+
const NSInteger VLCLibraryWindowSidebarViewPlaylistSegment = 0;
const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
+ at interface VLCLibraryWindowSidebarRootViewController ()
+
+ at property (readwrite) NSViewController<VLCLibraryWindowSidebarChildViewController> *currentChildVc;
+
+ at end
+
@implementation VLCLibraryWindowSidebarRootViewController
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
@@ -52,6 +62,9 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
- (void)viewDidLoad
{
[super viewDidLoad];
+ [self setupPlaylistTitle];
+ [self setupCounterLabel];
+ [self setupViewSelector];
self.mainVideoModeEnabled = NO;
@@ -62,13 +75,6 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
self.targetView.translatesAutoresizingMaskIntoConstraints = NO;
- self.viewSelector.segmentCount = 2;
- [self.viewSelector setLabel:_NS("Playlist")
- forSegment:VLCLibraryWindowSidebarViewPlaylistSegment];
- [self.viewSelector setLabel:_NS("Chapters")
- forSegment:VLCLibraryWindowSidebarViewChaptersSegment];
- self.viewSelector.selectedSegment = VLCLibraryWindowSidebarViewPlaylistSegment;
-
[self updateViewSelectorState];
[self viewSelectorAction:self.viewSelector];
@@ -79,6 +85,65 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
object:nil];
}
+- (void)setupPlaylistTitle
+{
+ _playlistHeaderLabel = [[NSTextField alloc] init];
+ self.playlistHeaderLabel.translatesAutoresizingMaskIntoConstraints = NO;
+ self.playlistHeaderLabel.font = NSFont.VLClibrarySectionHeaderFont;
+ self.playlistHeaderLabel.stringValue = _NS("Playlist");
+ self.playlistHeaderLabel.editable = NO;
+ self.playlistHeaderLabel.bezeled = NO;
+ self.playlistHeaderLabel.drawsBackground = NO;
+ self.playlistHeaderLabel.textColor = NSColor.headerTextColor;
+
+ [self.view addSubview:self.playlistHeaderLabel];
+ _playlistHeaderTopConstraint =
+ [self.playlistHeaderLabel.topAnchor constraintEqualToAnchor:self.view.topAnchor
+ constant:VLCLibraryUIUnits.smallSpacing];
+ [NSLayoutConstraint activateConstraints:@[
+ self.playlistHeaderTopConstraint,
+ [self.playlistHeaderLabel.bottomAnchor constraintEqualToAnchor:self.targetView.topAnchor
+ constant:-VLCLibraryUIUnits.smallSpacing],
+ [self.playlistHeaderLabel.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor
+ constant:VLCLibraryUIUnits.largeSpacing]
+ ]];
+}
+
+- (void)setupViewSelector
+{
+ self.viewSelector.segmentCount = 2;
+ [self.viewSelector setLabel:_NS("Playlist")
+ forSegment:VLCLibraryWindowSidebarViewPlaylistSegment];
+ [self.viewSelector setLabel:_NS("Chapters")
+ forSegment:VLCLibraryWindowSidebarViewChaptersSegment];
+ self.viewSelector.selectedSegment = VLCLibraryWindowSidebarViewPlaylistSegment;
+}
+
+- (void)setupCounterLabel
+{
+ _counterLabel = [[VLCRoundedCornerTextField alloc] init];
+ self.counterLabel.useStrongRounding = YES;
+ self.counterLabel.translatesAutoresizingMaskIntoConstraints = NO;
+ [self.counterLabel setContentCompressionResistancePriority:NSLayoutPriorityRequired
+ forOrientation:NSLayoutConstraintOrientationHorizontal];
+ [self.counterLabel setContentCompressionResistancePriority:NSLayoutPriorityRequired
+ forOrientation:NSLayoutConstraintOrientationVertical];
+
+ [self.view addSubview:self.counterLabel];
+
+ _counterLabelInHeaderConstraint =
+ [self.counterLabel.centerYAnchor constraintEqualToAnchor:self.playlistHeaderLabel.centerYAnchor];
+ _counterLabelInChildViewConstraint =
+ [self.counterLabel.topAnchor constraintEqualToAnchor:self.targetView.topAnchor
+ constant:VLCLibraryUIUnits.smallSpacing];
+
+ [NSLayoutConstraint activateConstraints:@[
+ self.counterLabelInHeaderConstraint,
+ [self.counterLabel.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor
+ constant:-VLCLibraryUIUnits.largeSpacing]
+ ]];
+}
+
- (void)titleListChanged:(NSNotification *)notification
{
[self updateViewSelectorState];
@@ -89,8 +154,28 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
VLCPlaylistController * const playlistController = VLCMain.sharedInstance.playlistController;
VLCPlayerController * const playerController = playlistController.playerController;
const BOOL chaptersEnabled = playerController.numberOfChaptersForCurrentTitle > 0;
+
[self.viewSelector setEnabled:chaptersEnabled
forSegment:VLCLibraryWindowSidebarViewChaptersSegment];
+ self.viewSelector.hidden = !chaptersEnabled;
+ self.topInternalConstraint.active = !self.viewSelector.hidden;
+
+ const NSLayoutPriority priority =
+ chaptersEnabled ? NSLayoutPriorityDefaultLow : NSLayoutPriorityRequired;
+ self.playlistHeaderLabel.hidden = chaptersEnabled;
+ [self.playlistHeaderLabel setContentCompressionResistancePriority:priority
+ forOrientation:NSLayoutConstraintOrientationVertical];
+ self.playlistHeaderTopConstraint.active = !self.playlistHeaderLabel.hidden;
+
+ NSLayoutConstraint * const counterLabelConstraintToActivate = self.viewSelector.hidden
+ ? self.counterLabelInHeaderConstraint
+ : self.counterLabelInChildViewConstraint;
+ NSLayoutConstraint * const counterLabelConstraintToDeactivate = self.viewSelector.hidden
+ ? self.counterLabelInChildViewConstraint
+ : self.counterLabelInHeaderConstraint;
+ counterLabelConstraintToActivate.active = YES;
+ counterLabelConstraintToDeactivate.active = NO;
+
if (!chaptersEnabled &&
self.viewSelector.selectedSegment == VLCLibraryWindowSidebarViewChaptersSegment) {
self.viewSelector.selectedSegment = VLCLibraryWindowSidebarViewPlaylistSegment;
@@ -103,16 +188,25 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
NSParameterAssert(sender == self.viewSelector);
const NSInteger selectedSegment = self.viewSelector.selectedSegment;
if (selectedSegment == VLCLibraryWindowSidebarViewPlaylistSegment) {
- [self setViewOnSidebarTargetView:self.playlistSidebarViewController.view];
+ [self setChildViewController:self.playlistSidebarViewController];
} else if (selectedSegment == VLCLibraryWindowSidebarViewChaptersSegment) {
- [self setViewOnSidebarTargetView:self.chaptersSidebarViewController.view];
+ [self setChildViewController:self.chaptersSidebarViewController];
} else {
NSAssert(NO, @"Invalid or unknown segment selected for sidebar!");
}
}
-- (void)setViewOnSidebarTargetView:(NSView *)view
+- (void)setChildViewController:(NSViewController<VLCLibraryWindowSidebarChildViewController> *)viewController
{
+ self.currentChildVc.counterLabel = nil; // Stop old vc manipulating the counter label
+ self.currentChildVc = viewController;
+
+ self.counterLabel.hidden = !viewController.supportsItemCount;
+ if (viewController.supportsItemCount) {
+ viewController.counterLabel = self.counterLabel;
+ }
+
+ NSView * const view = viewController.view;
self.targetView.subviews = @[view];
view.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
@@ -126,12 +220,18 @@ const NSInteger VLCLibraryWindowSidebarViewChaptersSegment = 1;
- (void)setMainVideoModeEnabled:(BOOL)mainVideoModeEnabled
{
_mainVideoModeEnabled = mainVideoModeEnabled;
+ [self updateTopConstraints];
+}
+
+- (void)updateTopConstraints
+{
CGFloat internalTopConstraintConstant = VLCLibraryUIUnits.smallSpacing;
- if (!mainVideoModeEnabled && self.libraryWindow.styleMask & NSFullSizeContentViewWindowMask) {
+ if (!self.mainVideoModeEnabled && self.libraryWindow.styleMask & NSFullSizeContentViewWindowMask) {
// Compensate for full content view window's titlebar height, prevent top being cut off
internalTopConstraintConstant += self.libraryWindow.titlebarHeight;
}
self.topInternalConstraint.constant = internalTopConstraintConstant;
+ self.playlistHeaderTopConstraint.constant = internalTopConstraintConstant;
}
@end
=====================================
modules/gui/macosx/playlist/VLCPlaylistDataSource.h
=====================================
@@ -32,7 +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;
+ at property (readwrite, nonatomic) NSTextField *counterTextField;
- (void)prepareForUse;
- (void)playlistUpdated;
=====================================
modules/gui/macosx/playlist/VLCPlaylistDataSource.m
=====================================
@@ -48,6 +48,13 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
_playlistModel = _playlistController.playlistModel;
}
+- (void)setCounterTextField:(NSTextField *)counterTextField
+{
+ _counterTextField = counterTextField;
+ self.counterTextField.stringValue =
+ [NSString stringWithFormat:@"%lu", _playlistModel.numberOfPlaylistItems];
+}
+
- (void)prepareForUse
{
[_tableView registerForDraggedTypes:@[VLCMediaLibraryMediaItemPasteboardType, VLCMediaLibraryMediaItemUTI, VLCPlaylistItemPasteboardType, NSFilenamesPboardType]];
@@ -96,9 +103,7 @@ static NSString *VLCPlaylistCellIdentifier = @"VLCPlaylistCellIdentifier";
{
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];
}
=====================================
modules/gui/macosx/views/VLCRoundedCornerTextField.m
=====================================
@@ -22,6 +22,7 @@
#import "VLCRoundedCornerTextField.h"
#import "extensions/NSColor+VLCAdditions.h"
+#import "extensions/NSFont+VLCAdditions.h"
const CGFloat VLCRoundedCornerTextFieldLightCornerRadius = 3.;
const CGFloat VLCRoundedCornerTextFieldStrongCornerRadius = 10.;
@@ -46,12 +47,27 @@ const CGFloat VLCRoundedCornerTextFieldStrongCornerRadius = 10.;
return self;
}
+- (instancetype)init
+{
+ self = [super init];
+ if (self) {
+ [self setupCustomAppearance];
+ }
+ return self;
+}
+
- (void)setupCustomAppearance
{
+ self.drawsBackground = NO;
self.wantsLayer = YES;
self.layer.cornerRadius = VLCRoundedCornerTextFieldLightCornerRadius;
self.layer.masksToBounds = YES;
self.layer.backgroundColor = NSColor.VLClibraryAnnotationBackgroundColor.CGColor;
+ self.font = NSFont.VLCLibraryItemAnnotationFont;
+ self.textColor = NSColor.VLClibraryAnnotationColor;
+ self.alignment = NSTextAlignmentCenter;
+ self.bezeled = NO;
+ self.editable = NO;
}
- (void)setBackgroundColor:(NSColor *)backgroundColor
@@ -69,13 +85,4 @@ const CGFloat VLCRoundedCornerTextFieldStrongCornerRadius = 10.;
}
}
-- (void)setStringValue:(NSString *)stringValue
-{
- if (stringValue != nil) {
- [super setStringValue:[NSString stringWithFormat:@" %@ ", stringValue]];
- } else {
- [super setStringValue:@""];
- }
-}
-
@end
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e4895f39c5e33b65abd1656758babe8612919ef...456d7c92575dd226c8b967d312d5a67b4fa8fb55
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e4895f39c5e33b65abd1656758babe8612919ef...456d7c92575dd226c8b967d312d5a67b4fa8fb55
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