[vlc-commits] [Git][videolan/vlc][master] 20 commits: macosx: Be more generous with nav sidebar width

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Apr 21 07:08:38 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
9b061f93 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Be more generous with nav sidebar width

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
402ef4c4 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Move toolbar item handling to VLCLibraryWindowToolbarDelegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
a657bdfb by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Use clearFilterString when toggling search bar view in toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
b9cd84c8 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Instantiate toolbar delegate directly from XIB

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
51f765cd by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Use toolbar outlet directly rather than accessing libraryWindow in toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
f5c4fe8e by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Move IBOutlets for toolbar items to toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
66ed5eee by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Fix action for renderers toolbar item

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
9abf6074 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Remove unimplemented segmentedControlAction in VLCLibraryAudioViewController

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
0558902c by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Move toolbar initialisation routines to library window toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
7dbfe6bc by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Move renderers update for toolbar item handling to toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
710b53a1 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Reorganise toolbar delegate implementation

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
d4b1fd8e by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Remove unneeded toolbar handling in library window when triggering video viewing mode

No longer needed now that we use the full video view and we hide the window's real toolbar anyway

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
e49b6c20 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Make insert and hide methods for toolbar items private in toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
3dd181ef by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Refactor tooltip configuration into toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
85e8f0db by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Remove unneeded configuration of toolbar items in library window

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
b6bb4694 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Handle specific hiding/showing of given toolbar items directly within toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
65583709 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Fix trackingSeparatorToolbarItem being deallocated

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
950b3d82 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Fix positioning of view mode toolbar item

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
4ae6cdb3 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Improve formatting in VLCLibraryWindowToolbarDelegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
a4940344 by Claudio Cambra at 2024-04-21T06:47:57+00:00
macosx: Split up asserts for insert item in toolbar delegate

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


7 changed files:

- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryUIUnits.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.h
- modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -391,6 +391,9 @@
                                 <action selector="rendererControlAction:" target="QvC-M9-y7g" id="M1O-u2-5FO"/>
                             </connections>
                         </button>
+                        <connections>
+                            <action selector="rendererControlAction:" target="xXj-E8-b8X" id="k28-mg-4Hy"/>
+                        </connections>
                     </toolbarItem>
                     <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="89f-AL-zuU"/>
                     <toolbarItem implicitItemIdentifier="85037E27-D263-490C-B4B2-0EFE5B5837AA" label="Library View Type" paletteLabel="Library View Type" sizingBehavior="auto" id="kBa-MC-Mdq">
@@ -480,6 +483,9 @@
                     <searchToolbarItem reference="dv4-Il-y8X"/>
                     <toolbarItem reference="Lf2-ec-tHh"/>
                 </defaultToolbarItems>
+                <connections>
+                    <outlet property="delegate" destination="xXj-E8-b8X" id="I0j-5P-oSw"/>
+                </connections>
             </toolbar>
             <connections>
                 <outlet property="audioCollectionSelectionTableView" destination="LNt-ot-2wU" id="aim-ER-CpD"/>
@@ -498,21 +504,16 @@
                 <outlet property="audioLibrarySplitView" destination="llh-BF-BEJ" id="gvt-K1-cGw"/>
                 <outlet property="audioLibraryView" destination="lpg-UW-pTq" id="FYD-PV-Ce2"/>
                 <outlet property="backwardsNavigationButton" destination="Bzq-ZV-i8j" id="Bac-Kb-ut"/>
-                <outlet property="backwardsToolbarItem" destination="6Ie-eu-GDn" id="q3s-rt-8gy"/>
                 <outlet property="controlsBar" destination="Uzf-Tf-H8x" id="n0G-92-F2Q"/>
                 <outlet property="controlsBarHeightConstraint" destination="Fps-hR-AFq" id="E4g-JQ-fgx"/>
                 <outlet property="emptyLibraryView" destination="YJf-1r-vaC" id="AJB-eN-4u6"/>
-                <outlet property="flexibleSpaceToolbarItem" destination="89f-AL-zuU" id="3p9-t8-79g"/>
                 <outlet property="forwardsNavigationButton" destination="jzy-je-h2k" id="for-Wa-rd"/>
-                <outlet property="forwardsToolbarItem" destination="g2e-7o-Qet" id="3qp-rg-t2P"/>
                 <outlet property="gridVsListSegmentedControl" destination="lIg-5J-C5F" id="u6B-Zx-4mX"/>
                 <outlet property="homeLibraryStackView" destination="p8n-RC-fWF" id="jcF-ny-9D7"/>
                 <outlet property="homeLibraryStackViewScrollView" destination="HXH-MZ-tkf" id="fzR-fb-nyS"/>
                 <outlet property="homeLibraryView" destination="mMj-Qb-bS1" id="WeM-ZY-knV"/>
                 <outlet property="librarySearchField" destination="ab6-kR-8Io" id="Qf7-UM-lol"/>
-                <outlet property="librarySearchToolbarItem" destination="dv4-Il-y8X" id="Um3-s4-Ax4"/>
                 <outlet property="librarySortButton" destination="Rja-6g-wNZ" id="FQ7-MU-hsk"/>
-                <outlet property="libraryViewModeToolbarItem" destination="kBa-MC-Mdq" id="q39-28-tyf"/>
                 <outlet property="mainSplitView" destination="u8g-jy-S4e" id="lI5-wR-kef"/>
                 <outlet property="mediaSourceCollectionView" destination="r7v-GI-W1U" id="3JJ-GU-o5o"/>
                 <outlet property="mediaSourceCollectionViewScrollView" destination="cFG-c9-cI9" id="QQq-Ql-uQ7"/>
@@ -530,13 +531,10 @@
                 <outlet property="placeholderLabel" destination="adK-Pc-tnU" id="6Zw-IF-czx"/>
                 <outlet property="playQueueToggle" destination="IaO-se-D0g" id="tqY-YM-KQC"/>
                 <outlet property="renderersButton" destination="ffS-QP-Om3" id="rOM-No-rd0"/>
-                <outlet property="renderersToolbarItem" destination="YEO-08-Qzi" id="mwx-8t-5o7"/>
-                <outlet property="sortOrderToolbarItem" destination="Tbc-Ik-FaO" id="098-yp-97f"/>
                 <outlet property="splitViewBottomConstraintToBottomBar" destination="QH8-mU-6ZP" id="b0t-C0-N5t"/>
                 <outlet property="splitViewBottomConstraintToSuperView" destination="DQQ-ji-YSy" id="b0t-C0-5uP"/>
                 <outlet property="splitViewController" destination="Kkr-kI-gpb" id="9aZ-xw-zrl"/>
-                <outlet property="toggleNavSidebarToolbarItem" destination="5oK-0W-JJh" id="To1-7k-AJF"/>
-                <outlet property="togglePlaylistToolbarItem" destination="Lf2-ec-tHh" id="gtf-cd-765"/>
+                <outlet property="toolbarDelegate" destination="xXj-E8-b8X" id="VsJ-ky-NJg"/>
                 <outlet property="videoLibraryCollectionView" destination="neh-e5-MUa" id="bmc-HF-k9s"/>
                 <outlet property="videoLibraryCollectionViewScrollView" destination="9bN-bM-RVu" id="iLf-ff-boW"/>
                 <outlet property="videoLibraryGroupSelectionTableView" destination="8M4-Y1-r6Z" id="5e1-v1-eW3"/>
@@ -1519,6 +1517,21 @@
             </constraints>
             <point key="canvasLocation" x="58" y="-261"/>
         </customView>
+        <customObject id="xXj-E8-b8X" customClass="VLCLibraryWindowToolbarDelegate">
+            <connections>
+                <outlet property="backwardsToolbarItem" destination="6Ie-eu-GDn" id="nqO-Tg-a1S"/>
+                <outlet property="flexibleSpaceToolbarItem" destination="89f-AL-zuU" id="rza-T3-EQq"/>
+                <outlet property="forwardsToolbarItem" destination="g2e-7o-Qet" id="4ex-8c-aSO"/>
+                <outlet property="librarySearchToolbarItem" destination="dv4-Il-y8X" id="iip-l7-TuF"/>
+                <outlet property="libraryViewModeToolbarItem" destination="kBa-MC-Mdq" id="e5b-Hd-Qha"/>
+                <outlet property="libraryWindow" destination="QvC-M9-y7g" id="YT5-2G-VJ2"/>
+                <outlet property="renderersToolbarItem" destination="YEO-08-Qzi" id="pXm-Aj-4Qg"/>
+                <outlet property="sortOrderToolbarItem" destination="Tbc-Ik-FaO" id="MFb-EI-Dsa"/>
+                <outlet property="toggleNavSidebarToolbarItem" destination="5oK-0W-JJh" id="xoK-Zo-nwh"/>
+                <outlet property="togglePlaylistToolbarItem" destination="Lf2-ec-tHh" id="PX9-gs-T5Z"/>
+                <outlet property="toolbar" destination="pr3-TD-J2z" id="0bl-3Z-WiA"/>
+            </connections>
+        </customObject>
         <viewController id="Kkr-kI-gpb" customClass="VLCLibraryWindowSplitViewController">
             <connections>
                 <outlet property="libraryWindow" destination="QvC-M9-y7g" id="wFD-Rc-i8w"/>


=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.m
=====================================
@@ -218,7 +218,7 @@
 
 + (const CGFloat)libraryWindowNavSidebarMaxWidth
 {
-    return 200.;
+    return 300.;
 }
 
 + (const CGFloat)libraryWindowPlaylistSidebarMaxWidth


=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -107,17 +107,7 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 @property (readwrite, weak) IBOutlet NSButton *backwardsNavigationButton;
 @property (readwrite, weak) IBOutlet NSButton *forwardsNavigationButton;
 @property (readwrite, weak) IBOutlet NSButton *artworkButton;
- at property (readwrite, weak) IBOutlet NSToolbarItem *toggleNavSidebarToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *trackingSeparatorToolbarItem;
- at property (readwrite, weak) IBOutlet NSButton *renderersButton;
- at property (readwrite, weak) IBOutlet NSToolbarItem *backwardsToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *forwardsToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *libraryViewModeToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *sortOrderToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *flexibleSpaceToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *librarySearchToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *togglePlaylistToolbarItem;
- at property (readwrite, weak) IBOutlet NSToolbarItem *renderersToolbarItem;
+ at property (readwrite, weak) IBOutlet VLCLibraryWindowToolbarDelegate *toolbarDelegate;
 @property (readwrite, weak) IBOutlet NSLayoutConstraint *splitViewBottomConstraintToBottomBar;
 
 @property (nonatomic, readwrite, strong) IBOutlet NSView *emptyLibraryView;
@@ -129,7 +119,6 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 @property (readwrite) BOOL nonembedded;
 
 @property (readwrite, weak) IBOutlet VLCLibraryWindowSplitViewController *splitViewController;
- at property (readonly) VLCLibraryWindowToolbarDelegate *toolbarDelegate;
 @property (readwrite) VLCLibraryNavigationStack *navigationStack;
 @property (readonly) VLCLibraryAudioViewController *libraryAudioViewController;
 @property (readonly) VLCLibraryMediaSourceViewController *libraryMediaSourceViewController;
@@ -143,6 +132,8 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 - (void)hideControlsBar;
 - (void)showControlsBar;
 - (void)updateGridVsListViewModeSegmentedControl;
+- (void)updateFilterString;
+- (void)clearFilterString;
 
 - (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
 
@@ -152,7 +143,6 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 - (IBAction)backwardsNavigationAction:(id)sender;
 - (IBAction)forwardsNavigationAction:(id)sender;
 - (IBAction)gridVsListSegmentedControlAction:(id)sender;
-- (IBAction)rendererControlAction:(id)sender;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -63,8 +63,6 @@
 #import "media-source/VLCMediaSourceBaseDataSource.h"
 #import "media-source/VLCLibraryMediaSourceViewController.h"
 
-#import "menus/renderers/VLCRendererMenuController.h"
-
 #import "views/VLCBottomBarView.h"
 #import "views/VLCCustomWindowButton.h"
 #import "views/VLCDragDropView.h"
@@ -147,21 +145,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
         self.tabbingMode = NSWindowTabbingModeDisallowed;
     }
 
-    _toolbarDelegate = [[VLCLibraryWindowToolbarDelegate alloc] initWithLibraryWindow:self];
-    self.toolbar.delegate = _toolbarDelegate;
-    self.toolbar.allowsUserCustomization = NO;
-
-    if (@available(macOS 11.0, *)) {
-        const NSInteger navSidebarToggleToolbarItemIndex = [self.toolbar.items indexOfObject:self.toggleNavSidebarToolbarItem];
-        NSAssert(navSidebarToggleToolbarItemIndex != NSNotFound, @"Could not find navigation sidebar toggle toolbar item!");
-
-        const NSInteger trackingSeparatorItemIndex = navSidebarToggleToolbarItemIndex + 1;
-        [self.toolbar insertItemWithItemIdentifier:VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier
-                                           atIndex:trackingSeparatorItemIndex];
-        self.trackingSeparatorToolbarItem = [self.toolbar.items objectAtIndex:trackingSeparatorItemIndex];
-    }
-
-
     VLCMain *mainInstance = VLCMain.sharedInstance;
     _playlistController = [mainInstance playlistController];
 
@@ -179,14 +162,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     self.videoViewController.displayLibraryControls = YES;
     [self hideControlsBarImmediately];
 
-    [self.gridVsListSegmentedControl setToolTip: _NS("Grid View or List View")];
-    [self.librarySortButton setToolTip: _NS("Select Sorting Mode")];
-    [self.playQueueToggle setToolTip: _NS("Toggle Playqueue")];
-
-    [self.gridVsListSegmentedControl setHidden:NO];
-    [self.librarySortButton setHidden:NO];
-    [self.librarySearchField setEnabled:YES];
-
     NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
     [notificationCenter addObserver:self
                            selector:@selector(shouldShowController:)
@@ -200,14 +175,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
                            selector:@selector(playerStateChanged:)
                                name:VLCPlayerStateChanged
                              object:nil];
-    [notificationCenter addObserver:self
-                           selector:@selector(renderersChanged:)
-                               name:VLCRendererAddedNotification
-                             object:nil];
-    [notificationCenter addObserver:self
-                           selector:@selector(renderersChanged:)
-                               name:VLCRendererRemovedNotification
-                             object:nil];
 
     _libraryHomeViewController = [[VLCLibraryHomeViewController alloc] initWithLibraryWindow:self];
     _libraryVideoViewController = [[VLCLibraryVideoViewController alloc] initWithLibraryWindow:self];
@@ -215,13 +182,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _libraryMediaSourceViewController = [[VLCLibraryMediaSourceViewController alloc] initWithLibraryWindow:self];
 
     [self setViewForSelectedSegment];
-
-    // Hide renderers toolbar item at first. Start discoveries and wait for notifications about
-    // renderers being added or removed to keep hidden or show depending on outcome
-    [self hideToolbarItem:_renderersToolbarItem];
-    [VLCMain.sharedInstance.mainMenu.rendererMenuController startRendererDiscoveries];
-
-    [self updatePlayqueueToggleState];
 }
 
 - (void)dealloc
@@ -361,158 +321,31 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [self setViewForSelectedSegment];
 }
 
-- (void)hideToolbarItem:(NSToolbarItem *)toolbarItem
-{
-    NSInteger toolbarItemIndex = [[self.toolbar items] indexOfObject:toolbarItem];
-    if (toolbarItemIndex != NSNotFound) {
-        [self.toolbar removeItemAtIndex:toolbarItemIndex];
-    }
-}
-
-/*
- * Try to insert the toolbar item ahead of a group of possible toolbar items.
- * "items" should contain items sorted from the trailing edge of the toolbar to leading edge.
- * "toolbarItem" will be inserted as close to the trailing edge as possible.
- *
- * If you have: | item1 | item2 | item3 | item4 |
- * and the "items" parameter is an array containing @[item6, item5, item2, item1]
- * then the "toolbarItem" provided to this function will place toolbarItem thus:
- * | item1 | item2 | toolbarItem | item3 | item4 |
-*/
-
-- (void)insertToolbarItem:(NSToolbarItem *)toolbarItem inFrontOf:(NSArray<NSToolbarItem *> *)items
-{
-    NSParameterAssert(toolbarItem != nil && items != nil && toolbarItem.itemIdentifier.length > 0);
-
-    NSInteger toolbarItemIndex = [[self.toolbar items] indexOfObject:toolbarItem];
-    if (toolbarItemIndex != NSNotFound) {
-        return;
-    }
-
-    for (NSToolbarItem *item in items) {
-        NSInteger itemIndex = [[self.toolbar items] indexOfObject:item];
-
-        if (itemIndex != NSNotFound) {
-            [self.toolbar insertItemWithItemIdentifier:toolbarItem.itemIdentifier atIndex:itemIndex + 1];
-            return;
-        }
-    }
-
-    [self.toolbar insertItemWithItemIdentifier:toolbarItem.itemIdentifier atIndex:0];
-}
-
-- (void)setForwardsBackwardsToolbarItemsVisible:(BOOL)visible
-{
-    if (!visible) {
-        [self hideToolbarItem:_forwardsToolbarItem];
-        [self hideToolbarItem:_backwardsToolbarItem];
-        return;
-    }
-
-    [self insertToolbarItem:_backwardsToolbarItem inFrontOf:@[_trackingSeparatorToolbarItem,
-                                                              _toggleNavSidebarToolbarItem]];
-    [self insertToolbarItem:_forwardsToolbarItem inFrontOf:@[_backwardsToolbarItem,
-                                                             _trackingSeparatorToolbarItem,
-                                                             _toggleNavSidebarToolbarItem]];
-}
-
-- (void)setSortOrderToolbarItemVisible:(BOOL)visible
-{
-    if (!visible) {
-        [self hideToolbarItem:_sortOrderToolbarItem];
-        return;
-    }
-
-    [self insertToolbarItem:_sortOrderToolbarItem
-                  inFrontOf:@[_libraryViewModeToolbarItem,
-                              _forwardsToolbarItem,
-                              _backwardsToolbarItem,
-                              _trackingSeparatorToolbarItem,
-                              _toggleNavSidebarToolbarItem]];
-}
-
-- (void)setLibrarySearchToolbarItemVisible:(BOOL)visible
-{
-    if (!visible) {
-        [self hideToolbarItem:_librarySearchToolbarItem];
-        [self stopSearchTimer];
-        _librarySearchField.stringValue = @"";
-        [self updateFilterString];
-        return;
-    }
-
-    // Display as far to the right as possible, but not in front of the playlist toggle button
-    NSMutableArray<NSToolbarItem *> *currentToolbarItems = [NSMutableArray arrayWithArray:self.toolbar.items];
-    if (currentToolbarItems.lastObject == _togglePlaylistToolbarItem) {
-        [currentToolbarItems removeLastObject];
-    }
-
-    NSArray *reversedCurrentToolbarItems = [[currentToolbarItems reverseObjectEnumerator] allObjects];
-    [self insertToolbarItem:_librarySearchToolbarItem inFrontOf:reversedCurrentToolbarItems];
-}
-
-- (void)setViewModeToolbarItemVisible:(BOOL)visible
-{
-    if (!visible) {
-        [self hideToolbarItem:self.libraryViewModeToolbarItem];
-        return;
-    }
-
-    [self insertToolbarItem:self.libraryViewModeToolbarItem inFrontOf:@[
-        self.toggleNavSidebarToolbarItem,
-        self.trackingSeparatorToolbarItem,
-        self.forwardsToolbarItem,
-        self.backwardsToolbarItem
-    ]];
-}
-
-- (void)updatePlayqueueToggleState
-{
-    NSView * const playlistView = self.splitViewController.playlistSidebarViewController.view;
-    _playQueueToggle.state = [self.mainSplitView isSubviewCollapsed:playlistView] ?
-        NSControlStateValueOff : NSControlStateValueOn;
-}
-
 - (void)showHomeLibrary
 {
     // Only collection view mode
-    [self setForwardsBackwardsToolbarItemsVisible:NO];
-    [self setSortOrderToolbarItemVisible:YES];
-    [self setLibrarySearchToolbarItemVisible:YES];
-    [self setViewModeToolbarItemVisible:NO];
-
+    [self.toolbarDelegate layoutForSegment:VLCLibraryHomeSegment];
     [_libraryHomeViewController presentHomeView];
 }
 
 - (void)showVideoLibrary
 {
-    [self setForwardsBackwardsToolbarItemsVisible:NO];
-    [self setSortOrderToolbarItemVisible:YES];
-    [self setLibrarySearchToolbarItemVisible:YES];
-    [self setViewModeToolbarItemVisible:YES];
-
+    [self.toolbarDelegate layoutForSegment:VLCLibraryVideoSegment];
     [_libraryVideoViewController presentVideoView];
 }
 
 - (void)showAudioLibrary
 {
-    [self setForwardsBackwardsToolbarItemsVisible:NO];
-    [self setSortOrderToolbarItemVisible:YES];
-    [self setLibrarySearchToolbarItemVisible:YES];
-    [self setViewModeToolbarItemVisible:YES];
-
+    [self.toolbarDelegate layoutForSegment:VLCLibraryMusicSegment];
     self.libraryAudioViewController.currentSegmentType = self.librarySegmentType;
 }
 
 - (void)showMediaSourceLibrary
 {
     [self.navigationStack clear];
-    [self setForwardsBackwardsToolbarItemsVisible:YES];
-    [self setSortOrderToolbarItemVisible:NO];
-    [self setLibrarySearchToolbarItemVisible:NO];
-    [self setViewModeToolbarItemVisible:YES];
 
     const VLCLibrarySegmentType segmentType = self.librarySegmentType;
+    [self.toolbarDelegate layoutForSegment:segmentType];
     if (segmentType == VLCLibraryBrowseSegment) {
         [_libraryMediaSourceViewController presentBrowseView];
     } else if (segmentType == VLCLibraryStreamsSegment) {
@@ -585,7 +418,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [VLCMain.sharedInstance.libraryController filterByString:_librarySearchField.stringValue];
 }
 
-- (void)clearLibraryFilterString
+- (void)clearFilterString
 {
     [self stopSearchTimer];
     _librarySearchField.stringValue = @"";
@@ -767,18 +600,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     }
 
     [self presentVideoView];
-
-    [self.forwardsNavigationButton setHidden:YES];
-    [self.gridVsListSegmentedControl setHidden:YES];
-    [self.librarySortButton setHidden:YES];
-    [self.librarySearchField setEnabled:NO];
-    [self clearLibraryFilterString];
-
-    // Make sure the back button is visible...
-    [self insertToolbarItem:_backwardsToolbarItem inFrontOf:@[_trackingSeparatorToolbarItem, _toggleNavSidebarToolbarItem]];
-    // And repurpose it to hide the video view
-    [self.backwardsNavigationButton setEnabled:YES];
-
     [self enableVideoTitleBarMode];
     [self hideControlsBarImmediately];
     [self.videoViewController showControls];
@@ -792,19 +613,9 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [VLCMain.sharedInstance.voutProvider updateWindowLevelForHelperWindows: NSNormalWindowLevel];
 
     // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
-    [self setAlphaValue:1.0];
+    self.alphaValue = 1.0;
     self.videoViewController.view.hidden = YES;
-
-    [self.forwardsNavigationButton setHidden:NO];
-    [self.gridVsListSegmentedControl setHidden:NO];
-    [self.librarySortButton setHidden:NO];
-    [self.librarySearchField setEnabled:YES];
-
-    // Reset the back button to navigation state
-    [self.backwardsNavigationButton setEnabled:_navigationStack.backwardsAvailable];
-
     [self setViewForSelectedSegment];
-
     [self disableVideoTitleBarMode];
     [self showControlsBarImmediately];
     self.splitViewController.playlistSidebarViewController.mainVideoModeEnabled = NO;
@@ -857,27 +668,4 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     }
 }
 
-#pragma mark -
-#pragma mark respond to renderers
-
-- (void)renderersChanged:(NSNotification *)notification
-{
-    const NSUInteger rendererCount = VLCMain.sharedInstance.mainMenu.rendererMenuController.rendererItems.count;
-    const BOOL rendererToolbarItemVisible = [self.toolbar.items containsObject:_renderersToolbarItem];
-
-    if (rendererCount > 0 && !rendererToolbarItemVisible) {
-        [self insertToolbarItem:_renderersToolbarItem
-                      inFrontOf:@[_sortOrderToolbarItem, _libraryViewModeToolbarItem, _forwardsToolbarItem, _backwardsToolbarItem]];
-    } else if (rendererCount == 0 && rendererToolbarItemVisible) {
-        [self hideToolbarItem:_renderersToolbarItem];
-    }
-}
-
-- (void)rendererControlAction:(id)sender
-{
-    [NSMenu popUpContextMenu:VLCMain.sharedInstance.mainMenu.rendererMenu
-                   withEvent:NSApp.currentEvent
-                     forView:sender];
-}
-
 @end


=====================================
modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.h
=====================================
@@ -22,6 +22,8 @@
 
 #import <Cocoa/Cocoa.h>
 
+#import "library/VLCLibrarySegment.h"
+
 NS_ASSUME_NONNULL_BEGIN
 
 @class VLCLibraryWindow;
@@ -30,9 +32,24 @@ extern NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier;
 
 @interface VLCLibraryWindowToolbarDelegate : NSObject<NSToolbarDelegate>
 
- at property (readonly) VLCLibraryWindow *libraryWindow;
+ at property (readwrite, weak) IBOutlet VLCLibraryWindow *libraryWindow;
+ at property (readwrite, weak) IBOutlet NSToolbar *toolbar;
+
+ at property (readonly, strong) NSToolbarItem *trackingSeparatorToolbarItem;
+
+ at property (readwrite, weak) IBOutlet NSToolbarItem *toggleNavSidebarToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *backwardsToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *forwardsToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *libraryViewModeToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *sortOrderToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *flexibleSpaceToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *librarySearchToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *togglePlaylistToolbarItem;
+ at property (readwrite, weak) IBOutlet NSToolbarItem *renderersToolbarItem;
+
+- (IBAction)rendererControlAction:(id)sender;
 
-- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow;
+- (void)layoutForSegment:(VLCLibrarySegmentType)segment;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m
=====================================
@@ -22,33 +22,275 @@
 
 #import "VLCLibraryWindowToolbarDelegate.h"
 
+#import "extensions/NSString+Helpers.h"
+
 #import "library/VLCLibraryWindow.h"
+#import "library/VLCLibraryWindowPlaylistSidebarViewController.h"
 #import "library/VLCLibraryWindowSplitViewController.h"
 
-NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier";
+#import "main/VLCMain.h"
+
+#import "menus/VLCMainMenu.h"
+#import "menus/renderers/VLCRendererMenuController.h"
+
+NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = 
+    @"VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier";
 
 @implementation VLCLibraryWindowToolbarDelegate
 
-- (nonnull instancetype)initWithLibraryWindow:(nonnull VLCLibraryWindow *)libraryWindow
+#pragma mark - XIB handling
+
+- (void)awakeFromNib
 {
-    self = [super init];
-    if (self) {
-        _libraryWindow = libraryWindow;
+    self.toolbar.allowsUserCustomization = NO;
+    
+    if (@available(macOS 11.0, *)) {
+        const NSInteger navSidebarToggleToolbarItemIndex = 
+            [self.toolbar.items indexOfObject:self.toggleNavSidebarToolbarItem];
+
+        NSAssert(navSidebarToggleToolbarItemIndex != NSNotFound,
+                 @"Could not find navigation sidebar toggle toolbar item!");
+
+        const NSInteger trackingSeparatorItemIndex = navSidebarToggleToolbarItemIndex + 1;
+        [self.toolbar 
+            insertItemWithItemIdentifier:VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier
+                                 atIndex:trackingSeparatorItemIndex];
+        _trackingSeparatorToolbarItem =
+            [self.toolbar.items objectAtIndex:trackingSeparatorItemIndex];
     }
-    return self;
+
+    NSNotificationCenter * const notificationCenter = NSNotificationCenter.defaultCenter;
+    [notificationCenter addObserver:self
+                           selector:@selector(renderersChanged:)
+                               name:VLCRendererAddedNotification
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(renderersChanged:)
+                               name:VLCRendererRemovedNotification
+                             object:nil];
+
+    self.libraryViewModeToolbarItem.toolTip = _NS("Grid View or List View");
+    self.sortOrderToolbarItem.toolTip = _NS("Select Sorting Mode");
+    self.togglePlaylistToolbarItem.toolTip = _NS("Toggle Playqueue");
+
+    // Hide renderers toolbar item at first. Start discoveries and wait for notifications about
+    // renderers being added or removed to keep hidden or show depending on outcome
+    [self hideToolbarItem:self.renderersToolbarItem];
+    [VLCMain.sharedInstance.mainMenu.rendererMenuController startRendererDiscoveries];
+
+    [self updatePlayqueueToggleState];
 }
 
+#pragma mark - toolbar delegate methods
+
 - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
      itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
  willBeInsertedIntoToolbar:(BOOL)flag
 {
     if ([itemIdentifier isEqualToString:VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier]) {
         if (@available(macOS 11.0, *)) {
-            return [NSTrackingSeparatorToolbarItem trackingSeparatorToolbarItemWithIdentifier:itemIdentifier splitView:_libraryWindow.mainSplitView dividerIndex:VLCLibraryWindowNavigationSidebarSplitViewDividerIndex];
+            return [NSTrackingSeparatorToolbarItem
+                    trackingSeparatorToolbarItemWithIdentifier:itemIdentifier
+                    splitView:self.libraryWindow.mainSplitView
+                    dividerIndex:VLCLibraryWindowNavigationSidebarSplitViewDividerIndex];
         }
     }
 
     return nil;
 }
 
+#pragma mark - renderers toolbar item handling
+
+- (IBAction)rendererControlAction:(id)sender
+{
+    [NSMenu popUpContextMenu:VLCMain.sharedInstance.mainMenu.rendererMenu
+                   withEvent:NSApp.currentEvent
+                     forView:sender];
+}
+
+- (void)renderersChanged:(NSNotification *)notification
+{
+    const NSUInteger rendererCount =
+        VLCMain.sharedInstance.mainMenu.rendererMenuController.rendererItems.count;
+    const BOOL rendererToolbarItemVisible =
+        [self.toolbar.items containsObject:self.renderersToolbarItem];
+
+    if (rendererCount > 0 && !rendererToolbarItemVisible) {
+        [self insertToolbarItem:self.renderersToolbarItem
+                      inFrontOf:@[self.sortOrderToolbarItem,
+                                  self.libraryViewModeToolbarItem,
+                                  self.forwardsToolbarItem,
+                                  self.backwardsToolbarItem]];
+    } else if (rendererCount == 0 && rendererToolbarItemVisible) {
+        [self hideToolbarItem:self.renderersToolbarItem];
+    }
+}
+
+#pragma mark - play queue toggle toolbar item handling
+
+- (void)updatePlayqueueToggleState
+{
+    NSView * const playlistView =
+        self.libraryWindow.splitViewController.playlistSidebarViewController.view;
+    self.libraryWindow.playQueueToggle.state =
+        [self.libraryWindow.mainSplitView isSubviewCollapsed:playlistView] ?
+            NSControlStateValueOff : NSControlStateValueOn;
+}
+
+#pragma mark - convenience method for configuration of toolbar items layout
+
+- (void)layoutForSegment:(VLCLibrarySegmentType)segment
+{
+    switch(segment) {
+        case VLCLibraryLowSentinelSegment:
+            vlc_assert_unreachable();
+        case VLCLibraryHomeSegment:
+            [self setForwardsBackwardsToolbarItemsVisible:NO];
+            [self setSortOrderToolbarItemVisible:NO];
+            [self setLibrarySearchToolbarItemVisible:NO];
+            [self setViewModeToolbarItemVisible:NO];
+            break;
+        case VLCLibraryVideoSegment:
+            [self setForwardsBackwardsToolbarItemsVisible:NO];
+            [self setSortOrderToolbarItemVisible:YES];
+            [self setLibrarySearchToolbarItemVisible:YES];
+            [self setViewModeToolbarItemVisible:YES];
+            break;
+        case VLCLibraryMusicSegment:
+        case VLCLibraryArtistsMusicSubSegment:
+        case VLCLibraryAlbumsMusicSubSegment:
+        case VLCLibrarySongsMusicSubSegment:
+        case VLCLibraryGenresMusicSubSegment:
+            [self setForwardsBackwardsToolbarItemsVisible:NO];
+            [self setSortOrderToolbarItemVisible:YES];
+            [self setLibrarySearchToolbarItemVisible:YES];
+            [self setViewModeToolbarItemVisible:YES];
+            break;
+        case VLCLibraryBrowseSegment:
+        case VLCLibraryStreamsSegment:
+            [self setForwardsBackwardsToolbarItemsVisible:YES];
+            [self setSortOrderToolbarItemVisible:NO];
+            [self setLibrarySearchToolbarItemVisible:NO];
+            [self setViewModeToolbarItemVisible:YES];
+            break;
+        case VLCLibraryHighSentinelSegment:
+            vlc_assert_unreachable();
+    }
+}
+
+#pragma mark - item visibility handling
+
+- (void)hideToolbarItem:(NSToolbarItem *)toolbarItem
+{
+    const NSInteger toolbarItemIndex = [self.toolbar.items indexOfObject:toolbarItem];
+    if (toolbarItemIndex != NSNotFound) {
+        [self.toolbar removeItemAtIndex:toolbarItemIndex];
+    }
+}
+
+/*
+ * Try to insert the toolbar item ahead of a group of possible toolbar items.
+ * "items" should contain items sorted from the trailing edge of the toolbar to leading edge.
+ * "toolbarItem" will be inserted as close to the trailing edge as possible.
+ *
+ * If you have: | item1 | item2 | item3 | item4 |
+ * and the "items" parameter is an array containing @[item6, item5, item2, item1]
+ * then the "toolbarItem" provided to this function will place toolbarItem thus:
+ * | item1 | item2 | toolbarItem | item3 | item4 |
+*/
+
+- (void)insertToolbarItem:(NSToolbarItem *)toolbarItem inFrontOf:(NSArray<NSToolbarItem *> *)items
+{
+    NSParameterAssert(toolbarItem != nil);
+    NSParameterAssert(items != nil);
+    NSParameterAssert(toolbarItem.itemIdentifier.length > 0);
+
+    const NSInteger toolbarItemIndex = [self.toolbar.items indexOfObject:toolbarItem];
+    if (toolbarItemIndex != NSNotFound) {
+        return;
+    }
+
+    for (NSToolbarItem * const item in items) {
+        const NSInteger itemIndex = [self.toolbar.items indexOfObject:item];
+
+        if (itemIndex != NSNotFound) {
+            [self.toolbar insertItemWithItemIdentifier:toolbarItem.itemIdentifier
+                                               atIndex:itemIndex + 1];
+            return;
+        }
+    }
+
+    [self.toolbar insertItemWithItemIdentifier:toolbarItem.itemIdentifier atIndex:0];
+}
+
+#pragma mark - convenience methods for hiding/showing and positioning certain toolbar items
+
+- (void)setForwardsBackwardsToolbarItemsVisible:(BOOL)visible
+{
+    if (!visible) {
+        [self hideToolbarItem:self.forwardsToolbarItem];
+        [self hideToolbarItem:self.backwardsToolbarItem];
+        return;
+    }
+
+    [self insertToolbarItem:self.backwardsToolbarItem 
+                  inFrontOf:@[self.trackingSeparatorToolbarItem,
+                              self.toggleNavSidebarToolbarItem]];
+
+    [self insertToolbarItem:self.forwardsToolbarItem
+                  inFrontOf:@[self.backwardsToolbarItem,
+                              self.trackingSeparatorToolbarItem,
+                              self.toggleNavSidebarToolbarItem]];
+}
+
+- (void)setSortOrderToolbarItemVisible:(BOOL)visible
+{
+    if (!visible) {
+        [self hideToolbarItem:self.sortOrderToolbarItem];
+        return;
+    }
+
+    [self insertToolbarItem:self.sortOrderToolbarItem
+                  inFrontOf:@[self.libraryViewModeToolbarItem,
+                              self.forwardsToolbarItem,
+                              self.backwardsToolbarItem,
+                              self.trackingSeparatorToolbarItem,
+                              self.toggleNavSidebarToolbarItem]];
+}
+
+- (void)setLibrarySearchToolbarItemVisible:(BOOL)visible
+{
+    if (!visible) {
+        [self hideToolbarItem:self.librarySearchToolbarItem];
+        [self.libraryWindow clearFilterString];
+        return;
+    }
+
+    // Display as far to the right as possible, but not in front of the playlist toggle button
+    NSMutableArray<NSToolbarItem *> * const currentToolbarItems =
+        [NSMutableArray arrayWithArray:self.toolbar.items];
+    if (currentToolbarItems.lastObject == self.togglePlaylistToolbarItem) {
+        [currentToolbarItems removeLastObject];
+    }
+
+    NSArray * const reversedCurrentToolbarItems =
+        currentToolbarItems.reverseObjectEnumerator.allObjects;
+    [self insertToolbarItem:self.librarySearchToolbarItem
+                  inFrontOf:reversedCurrentToolbarItems];
+}
+
+- (void)setViewModeToolbarItemVisible:(BOOL)visible
+{
+    if (!visible) {
+        [self hideToolbarItem:self.libraryViewModeToolbarItem];
+        return;
+    }
+
+    [self insertToolbarItem:self.libraryViewModeToolbarItem
+                  inFrontOf:@[self.forwardsToolbarItem,
+                              self.backwardsToolbarItem,
+                              self.trackingSeparatorToolbarItem,
+                              self.toggleNavSidebarToolbarItem]];
+}
+
 @end


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
=====================================
@@ -64,7 +64,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSArray<NSLayoutConstraint *> *audioPlaceholderImageViewSizeConstraints;
 
 - (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow;
-- (IBAction)segmentedControlAction:(id)sender;
+
 - (void)presentAudioView;
 - (void)reloadData;
 - (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d03bcba3d5e8b1f1b2c4943761a29c61c1b924f2...a49403442e3d98129d981366fb2c319472cd3b78

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d03bcba3d5e8b1f1b2c4943761a29c61c1b924f2...a49403442e3d98129d981366fb2c319472cd3b78
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