[vlc-commits] [Git][videolan/vlc][master] macosx: Make library navigation buttons functional

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Fri Jul 29 06:18:58 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
728ab28a by Claudio Cambra at 2022-07-29T06:07:25+00:00
macosx: Make library navigation buttons functional

Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>

- - - - -


12 changed files:

- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryAudioDataSource.h
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- + modules/gui/macosx/library/VLCLibraryNavigationStack.h
- + modules/gui/macosx/library/VLCLibraryNavigationStack.m
- + modules/gui/macosx/library/VLCLibraryNavigationState.h
- + modules/gui/macosx/library/VLCLibraryNavigationState.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
- modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m


Changes:

=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -80,6 +80,10 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/library/VLCLibraryMenuController.m \
 	gui/macosx/library/VLCLibraryModel.h \
 	gui/macosx/library/VLCLibraryModel.m \
+	gui/macosx/library/VLCLibraryNavigationStack.h \
+	gui/macosx/library/VLCLibraryNavigationStack.m \
+	gui/macosx/library/VLCLibraryNavigationState.h \
+	gui/macosx/library/VLCLibraryNavigationState.m \
 	gui/macosx/library/VLCLibrarySortingMenuController.h \
 	gui/macosx/library/VLCLibrarySortingMenuController.m \
 	gui/macosx/library/VLCLibraryTableCellView.h \


=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -565,22 +565,6 @@
                             </connections>
                         </button>
                     </toolbarItem>
-                    <toolbarItem implicitItemIdentifier="82C1CE3D-FCE3-49CB-B910-14456BAA94A2" label="Navigation Controls" paletteLabel="Navigation Controls" sizingBehavior="auto" navigational="YES" id="SXj-w1-2e4">
-                        <nil key="toolTip"/>
-                        <segmentedControl key="view" verticalHuggingPriority="750" id="Cd4-7b-wi1">
-                            <rect key="frame" x="25" y="14" width="61" height="24"/>
-                            <autoresizingMask key="autoresizingMask"/>
-                            <segmentedCell key="cell" continuous="YES" refusesFirstResponder="YES" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="F1b-F8-QA5">
-                                <font key="font" metaFont="system"/>
-                                <segments>
-                                    <segment image="NSLeftFacingTriangleTemplate" width="32"/>
-                                    <segment image="NSRightFacingTriangleTemplate" enabled="NO">
-                                        <nil key="label"/>
-                                    </segment>
-                                </segments>
-                            </segmentedCell>
-                        </segmentedControl>
-                    </toolbarItem>
                     <toolbarItem implicitItemIdentifier="C6B452D8-BAA7-4410-A942-3096C5EBF6F7" label="Custom View" paletteLabel="Segmented Title Control" visibilityPriority="10" sizingBehavior="auto" id="KnW-Lr-R1d">
                         <nil key="toolTip"/>
                         <segmentedControl key="view" verticalHuggingPriority="750" id="W1M-0o-qYG">
@@ -595,6 +579,9 @@
                                     <segment label="Streams"/>
                                 </segments>
                             </segmentedCell>
+                            <connections>
+                                <action selector="segmentedControlAction:" target="QvC-M9-y7g" id="seg-Me-t1n"/>
+                            </connections>
                         </segmentedControl>
                     </toolbarItem>
                     <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="89f-AL-zuU"/>
@@ -632,10 +619,39 @@
                             </connections>
                         </searchField>
                     </searchToolbarItem>
+                    <toolbarItem implicitItemIdentifier="6FF10B75-9BCD-4E38-BBD1-FC28CD0651F8" label="Back" paletteLabel="Back" image="NSLeftFacingTriangleTemplate" sizingBehavior="auto" navigational="YES" id="6Ie-eu-GDn">
+                        <nil key="toolTip"/>
+                        <button key="view" verticalHuggingPriority="750" id="Bzq-ZV-i8j">
+                            <rect key="frame" x="7" y="14" width="20" height="19"/>
+                            <autoresizingMask key="autoresizingMask"/>
+                            <buttonCell key="cell" type="recessed" bezelStyle="recessed" image="NSLeftFacingTriangleTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="geC-DJ-rRh">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="systemBold" size="12"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="backwardsNavigationAction:" target="QvC-M9-y7g" id="for-Ac-t1n"/>
+                            </connections>
+                        </button>
+                    </toolbarItem>
+                    <toolbarItem implicitItemIdentifier="8EEF1426-308A-446D-AD89-6E8C7A2327AB" label="Forward" paletteLabel="Forward" image="NSRightFacingTriangleTemplate" sizingBehavior="auto" navigational="YES" id="g2e-7o-Qet">
+                        <nil key="toolTip"/>
+                        <button key="view" verticalHuggingPriority="750" id="jzy-je-h2k">
+                            <rect key="frame" x="15" y="14" width="20" height="19"/>
+                            <autoresizingMask key="autoresizingMask"/>
+                            <buttonCell key="cell" type="recessed" bezelStyle="recessed" image="NSRightFacingTriangleTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="dAm-oA-OAD">
+                                <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+                                <font key="font" metaFont="systemBold" size="12"/>
+                            </buttonCell>
+                            <connections>
+                                <action selector="forwardsNavigationAction:" target="QvC-M9-y7g" id="bac-Ac-t1n"/>
+                            </connections>
+                        </button>
+                    </toolbarItem>
                 </allowedToolbarItems>
                 <defaultToolbarItems>
                     <toolbarItem reference="L28-Xw-ydE"/>
-                    <toolbarItem reference="SXj-w1-2e4"/>
+                    <toolbarItem reference="6Ie-eu-GDn"/>
+                    <toolbarItem reference="g2e-7o-Qet"/>
                     <toolbarItem reference="kBa-MC-Mdq"/>
                     <toolbarItem reference="Tbc-Ik-FaO"/>
                     <toolbarItem reference="89f-AL-zuU"/>
@@ -653,11 +669,13 @@
                 <outlet property="audioLibrarySplitView" destination="llh-BF-BEJ" id="gvt-K1-cGw"/>
                 <outlet property="audioLibraryView" destination="lpg-UW-pTq" id="FYD-PV-Ce2"/>
                 <outlet property="audioSegmentedControl" destination="8iI-b7-Eag" id="ERG-nc-ziq"/>
+                <outlet property="backwardsNavigationButton" destination="Bzq-ZV-i8j" id="Bac-Kb-ut"/>
                 <outlet property="clearPlaylistButton" destination="cih-xp-HmY" id="PoU-co-0kn"/>
                 <outlet property="clearPlaylistSeparator" destination="nAW-KH-ipk" id="Af9-fg-u7m"/>
                 <outlet property="controlsBar" destination="Uzf-Tf-H8x" id="n0G-92-F2Q"/>
                 <outlet property="dragDropImageBackgroundBox" destination="AXk-h7-dZ0" id="h3h-Wh-0op"/>
                 <outlet property="emptyLibraryView" destination="YJf-1r-vaC" id="AJB-eN-4u6"/>
+                <outlet property="forwardsNavigationButton" destination="jzy-je-h2k" id="for-Wa-rd"/>
                 <outlet property="gridVsListSegmentedControl" destination="lIg-5J-C5F" id="u6B-Zx-4mX"/>
                 <outlet property="librarySearchField" destination="ab6-kR-8Io" id="Qf7-UM-lol"/>
                 <outlet property="librarySearchToolbarItem" destination="dv4-Il-y8X" id="Um3-s4-Ax4"/>


=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.h
=====================================
@@ -40,6 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, readwrite, assign) NSTextField *placeholderLabel;
 @property (nonatomic, readonly, strong) NSString *imageNameForCurrentSegment;
 
+- (IBAction)segmentedControlAction:(id)sender;
 - (void)setupAppearance;
 - (void)reloadAppearance;
 - (void)reloadEmptyViewAppearance;


=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -24,6 +24,8 @@
 
 #import "main/VLCMain.h"
 
+#import "library/VLCLibraryWindow.h"
+#import "library/VLCLibraryNavigationStack.h"
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryController.h"
 #import "library/VLCLibraryDataTypes.h"
@@ -155,6 +157,10 @@
     [self.collectionView reloadData];
     [self.collectionSelectionTableView reloadData];
     [self.groupSelectionTableView reloadData];
+
+    if(sender != [[[VLCMain sharedInstance] libraryWindow] navigationStack]) {
+        [[[[VLCMain sharedInstance] libraryWindow] navigationStack] appendCurrentLibraryState];
+    }
 }
 
 - (NSString *)imageNameForCurrentSegment


=====================================
modules/gui/macosx/library/VLCLibraryNavigationStack.h
=====================================
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * VLCLibraryNavigationStack.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <claudio.cambra at gmail.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 class VLCLibraryWindow;
+
+ at interface VLCLibraryNavigationStack : NSObject
+
+ at property (readwrite, strong) VLCLibraryWindow *delegate;
+ at property (readonly) BOOL forwardsAvailable;
+ at property (readonly) BOOL backwardsAvailable;
+
+- (void)backwards;
+- (void)forwards;
+
+- (void)appendCurrentLibraryState;
+
+ at end
+
+NS_ASSUME_NONNULL_END
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryNavigationStack.m
=====================================
@@ -0,0 +1,160 @@
+/*****************************************************************************
+ * VLCLibraryNavigationStack.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <claudio.cambra at gmail.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 "VLCLibraryNavigationStack.h"
+
+#import "VLCLibraryWindow.h"
+#import "VLCLibraryAudioDataSource.h"
+#import "VLCLibraryNavigationState.h"
+#import "media-source/VLCMediaSourceBaseDataSource.h"
+
+ at interface VLCLibraryNavigationCurrentStackPosition : NSObject
+
+ at property (readonly) NSUInteger navigationStackIndex;
+ at property (readonly) VLCLibraryNavigationState *navigationState;
+
+- (instancetype)initWithStackIndex:(NSUInteger)index andState:(VLCLibraryNavigationState *)state;
+
+ at end
+
+ at implementation VLCLibraryNavigationCurrentStackPosition
+
+- (instancetype)initWithStackIndex:(NSUInteger)index andState:(VLCLibraryNavigationState *)state
+{
+    self = [super init];
+
+    if(self) {
+        _navigationStackIndex = index;
+        _navigationState = state;
+    }
+
+    return self;
+}
+
+ at end
+
+
+ at interface VLCLibraryNavigationStack ()
+{
+    NSMutableArray<VLCLibraryNavigationState *> *_navigationStates;
+    VLCLibraryNavigationCurrentStackPosition *_currentPosition;
+}
+
+ at end
+
+ at implementation VLCLibraryNavigationStack
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        _navigationStates = [[NSMutableArray alloc] init];
+    }
+    return self;
+}
+
+- (BOOL)forwardsAvailable
+{
+    NSUInteger numNavigationStates = _navigationStates.count;
+
+    return _currentPosition && 
+        _currentPosition.navigationStackIndex < numNavigationStates - 1 && 
+        numNavigationStates > 1;
+}
+
+- (BOOL)backwardsAvailable
+{
+    return _currentPosition && 
+        _currentPosition.navigationStackIndex > 0 && 
+        _navigationStates.count > 1;
+}
+
+- (void)forwards
+{
+    if(_delegate == nil || !self.forwardsAvailable) {
+        return;
+    }
+
+    NSUInteger newPositionIndex = _currentPosition.navigationStackIndex + 1;
+    _currentPosition = [[VLCLibraryNavigationCurrentStackPosition alloc] initWithStackIndex:newPositionIndex andState:_navigationStates[newPositionIndex]];
+    [self setDelegateToState:_currentPosition.navigationState];
+}
+
+- (void)backwards
+{
+    if(_delegate == nil || !self.backwardsAvailable) {
+        return;
+    }
+
+    NSUInteger newPositionIndex = _currentPosition.navigationStackIndex - 1;
+    _currentPosition = [[VLCLibraryNavigationCurrentStackPosition alloc] initWithStackIndex:newPositionIndex andState:_navigationStates[newPositionIndex]];
+    [self setDelegateToState:_currentPosition.navigationState];
+}
+
+- (void)appendCurrentLibraryState
+{
+    if(_delegate == nil) {
+        return;
+    }
+
+    if(self.forwardsAvailable) {
+        NSUInteger firstIndexToRemove = _currentPosition.navigationStackIndex + 1;
+        // -1 to account for the array count
+        NSRange rangeToRemove = NSMakeRange(firstIndexToRemove, (_navigationStates.count - 1) - _currentPosition.navigationStackIndex);
+        [_navigationStates removeObjectsInRange:rangeToRemove];
+    }
+
+    VLCLibraryNavigationState *navigationState = [[VLCLibraryNavigationState alloc] initFromLibraryWindow:_delegate];
+    _currentPosition = [[VLCLibraryNavigationCurrentStackPosition alloc] initWithStackIndex:_navigationStates.count andState:navigationState];
+    [_navigationStates addObject:navigationState];
+
+    [self updateDelegateNavigationButtons];
+}
+
+- (void)updateDelegateNavigationButtons
+{
+    if(_delegate == nil) {
+        return;
+    }
+
+    _delegate.forwardsNavigationButton.enabled = self.forwardsAvailable;
+    _delegate.backwardsNavigationButton.enabled = self.backwardsAvailable;
+}
+
+- (void)setDelegateToState:(VLCLibraryNavigationState *)state
+{
+    if(_delegate == nil) {
+        return;
+    }
+
+    [_delegate.segmentedTitleControl setSelectedSegment:state.libraryWindowSelectedSegment];
+    [_delegate.audioSegmentedControl setSelectedSegment:state.audioLibraryViewSelectedSegment];
+    [_delegate.gridVsListSegmentedControl setSelectedSegment:state.viewModeSelectedSegment];
+
+    [_delegate segmentedControlAction:self];
+    [_delegate.libraryAudioDataSource segmentedControlAction:self];
+    [_delegate.mediaSourceDataSource setGridOrListMode:self];
+
+    [self updateDelegateNavigationButtons];
+}
+
+ at end
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryNavigationState.h
=====================================
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * VLCLibraryNavigationStack.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <claudio.cambra at gmail.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 class VLCLibraryWindow;
+ at class VLCMediaSourceDataSource;
+
+ at interface VLCLibraryNavigationState : NSObject
+
+ at property (readonly) NSInteger libraryWindowSelectedSegment;
+ at property (readonly) NSInteger viewModeSelectedSegment;
+ at property (readonly) NSInteger audioLibraryViewSelectedSegment;
+
+- (instancetype)initFromLibraryWindow:(VLCLibraryWindow *)libraryWindow;
+
+ at end
+
+NS_ASSUME_NONNULL_END
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryNavigationState.m
=====================================
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * VLCLibraryNavigationStack.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2022 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <claudio.cambra at gmail.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 "VLCLibraryNavigationState.h"
+
+#import "VLCLibraryWindow.h"
+
+ at implementation VLCLibraryNavigationState
+
+- (instancetype)initFromLibraryWindow:(VLCLibraryWindow *)libraryWindow
+{
+    VLCLibraryNavigationState* navState = [super init];
+
+    if(navState) {
+        _libraryWindowSelectedSegment = libraryWindow.segmentedTitleControl.selectedSegment;
+        _viewModeSelectedSegment = libraryWindow.gridVsListSegmentedControl.selectedSegment;
+        _audioLibraryViewSelectedSegment = libraryWindow.audioSegmentedControl.selectedSegment;
+    }
+
+    return navState;
+}
+
+ at end
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -26,6 +26,16 @@ NS_ASSUME_NONNULL_BEGIN
 
 @class VLCDragDropView;
 @class VLCRoundedCornerTextField;
+ at class VLCLibraryNavigationStack;
+ at class VLCLibraryAudioDataSource;
+ at class VLCLibraryVideoDataSource;
+ at class VLCLibraryGroupDataSource;
+ at class VLCLibrarySortingMenuController;
+ at class VLCMediaSourceBaseDataSource;
+ at class VLCPlaylistDataSource;
+ at class VLCPlaylistController;
+ at class VLCPlaylistSortingMenuController;
+ at class VLCFSPanelController;
 
 @interface VLCLibraryWindowController : NSWindowController
 
@@ -75,9 +85,21 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, weak) IBOutlet NSSearchField *librarySearchField;
 @property (readwrite, weak) IBOutlet NSToolbarItem *librarySearchToolbarItem;
 @property (readwrite, weak) IBOutlet NSButton *playQueueToggle;
+ at property (readwrite, weak) IBOutlet NSButton *backwardsNavigationButton;
+ at property (readwrite, weak) IBOutlet NSButton *forwardsNavigationButton;
 
 @property (readonly) BOOL nativeFullscreenMode;
 @property (readwrite) BOOL nonembedded;
+ at property (readwrite) VLCLibraryNavigationStack *navigationStack;
+ at property (readonly) VLCLibraryAudioDataSource *libraryAudioDataSource;
+ at property (readonly) VLCLibraryVideoDataSource *libraryVideoDataSource;
+ at property (readonly) VLCLibraryGroupDataSource *libraryAudioGroupDataSource;
+ at property (readonly) VLCLibrarySortingMenuController *librarySortingMenuController;
+ at property (readonly) VLCMediaSourceBaseDataSource *mediaSourceDataSource;
+ at property (readonly) VLCPlaylistDataSource *playlistDataSource;
+ at property (readonly) VLCPlaylistSortingMenuController *playlistSortingMenuController;
+ at property (readonly) VLCPlaylistController *playlistController;
+ at property (readonly) VLCFSPanelController *fspanel;
 
 - (void)videoPlaybackWillBeStarted;
 - (void)enableVideoPlaybackAppearance;
@@ -92,7 +114,9 @@ NS_ASSUME_NONNULL_BEGIN
 - (IBAction)filterLibrary:(id)sender;
 - (IBAction)openMedia:(id)sender;
 - (IBAction)showAndHidePlaylist:(id)sender;
-
+- (IBAction)backwardsNavigationAction:(id)sender;
+- (IBAction)forwardsNavigationAction:(id)sender;
+- (IBAction)segmentedControlAction:(id)sender;
 @end
 
 NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -40,6 +40,7 @@
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibrarySortingMenuController.h"
 #import "library/VLCLibraryAlbumTableCellView.h"
+#import "library/VLCLibraryNavigationStack.h"
 
 #import "media-source/VLCMediaSourceBaseDataSource.h"
 
@@ -71,20 +72,8 @@ static NSArray<NSLayoutConstraint *> *audioPlaceholderImageViewSizeConstraints;
 
 @interface VLCLibraryWindow () <VLCDragDropTarget, NSSplitViewDelegate>
 {
-    VLCPlaylistDataSource *_playlistDataSource;
-    VLCLibraryVideoDataSource *_libraryVideoDataSource;
-    VLCLibraryAudioDataSource *_libraryAudioDataSource;
-    VLCLibraryGroupDataSource *_libraryAudioGroupDataSource;
-    VLCLibrarySortingMenuController *_librarySortingMenuController;
-    VLCMediaSourceBaseDataSource *_mediaSourceDataSource;
-    VLCPlaylistSortingMenuController *_playlistSortingMenuController;
-
-    VLCPlaylistController *_playlistController;
-
     NSRect _windowFrameBeforePlayback;
     CGFloat _lastPlaylistWidthBeforeCollaps;
-
-    VLCFSPanelController *_fspanel;
     
     NSInteger _currentSelectedSegment;
     NSInteger _currentSelectedViewModeSegment;
@@ -148,6 +137,9 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     var_AddCallback(libvlc, "intf-toggle-fscontrol", ShowFullscreenController, (__bridge void *)self);
     var_AddCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
 
+    self.navigationStack = [[VLCLibraryNavigationStack alloc] init];
+    self.navigationStack.delegate = self;
+
     self.videoView = [[VLCVoutView alloc] initWithFrame:self.mainSplitView.frame];
     self.videoView.hidden = YES;
     
@@ -260,7 +252,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _currentSelectedSegment = 5; // To enforce action on the selected segment
     _segmentedTitleControl.segmentCount = 4;
     [_segmentedTitleControl setTarget:self];
-    [_segmentedTitleControl setAction:@selector(segmentedControlAction:)];
     [_segmentedTitleControl setLabel:_NS("Video") forSegment:0];
     [_segmentedTitleControl setLabel:_NS("Music") forSegment:1];
     [_segmentedTitleControl setLabel:_NS("Browse") forSegment:2];
@@ -500,17 +491,17 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
 
 #pragma mark - misc. user interactions
 
-- (void)segmentedControlAction:(id)sender
+- (IBAction)segmentedControlAction:(id)sender
 {
     if (_segmentedTitleControl.selectedSegment == _currentSelectedSegment && 
         _gridVsListSegmentedControl.selectedSegment == _currentSelectedViewModeSegment) {
         return;
     }
-    
+
     _currentSelectedSegment = _segmentedTitleControl.selectedSegment;
     _currentSelectedViewModeSegment = _gridVsListSegmentedControl.selectedSegment;
 
-    switch (_currentSelectedSegment) {
+    switch (_segmentedTitleControl.selectedSegment) {
         case 0:
             [self showVideoLibrary];
             break;
@@ -523,6 +514,10 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
             [self showMediaSourceAppearance];
             break;
     }
+
+    if(sender != _navigationStack) {
+        [self.navigationStack appendCurrentLibraryState];
+    }
 }
 
 - (void)showVideoLibrary
@@ -794,6 +789,16 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     [self togglePlaylist];
 }
 
+- (IBAction)backwardsNavigationAction:(id)sender
+{
+    [_navigationStack backwards];
+}
+
+- (IBAction)forwardsNavigationAction:(id)sender
+{
+    [_navigationStack forwards];
+}
+
 #pragma mark - video output controlling
 
 - (void)videoPlaybackWillBeStarted


=====================================
modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.h
=====================================
@@ -29,6 +29,8 @@ typedef NS_ENUM(NSInteger, VLCMediaSourceMode) {
 
 NS_ASSUME_NONNULL_BEGIN
 
+ at class VLCMediaSourceDataSource;
+
 @interface VLCMediaSourceBaseDataSource : NSObject
 
 @property (readwrite) NSCollectionView *collectionView;
@@ -38,9 +40,12 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite) NSButton *homeButton;
 @property (readwrite) NSPathControl *pathControl;
 @property (readwrite, nonatomic) VLCMediaSourceMode mediaSourceMode;
+ at property (readonly) VLCMediaSourceDataSource *childDataSource;
 
 - (void)setupViews;
 - (void)reloadViews;
+- (void)homeButtonAction:(id)sender;
+- (void)setGridOrListMode:(id)sender;
 
 @end
 


=====================================
modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -30,6 +30,8 @@
 
 #import "main/VLCMain.h"
 #import "views/VLCImageView.h"
+#import "library/VLCLibraryWindow.h"
+#import "library/VLCLibraryNavigationStack.h"
 #import "library/VLCInputItem.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibraryTableCellView.h"
@@ -40,7 +42,6 @@ NSString *VLCMediaSourceTableViewCellIdentifier = @"VLCMediaSourceTableViewCellI
 @interface VLCMediaSourceBaseDataSource () <NSCollectionViewDataSource, NSCollectionViewDelegate, NSTableViewDelegate, NSTableViewDataSource>
 {
     NSArray<VLCMediaSource *> *_mediaSources;
-    VLCMediaSourceDataSource *_childDataSource;
     NSArray *_discoveredLANdevices;
     BOOL _gridViewMode;
 }
@@ -95,28 +96,21 @@ NSString *VLCMediaSourceTableViewCellIdentifier = @"VLCMediaSourceTableViewCellI
     self.homeButton.target = self;
     self.pathControl.URL = nil;
 
-    self.gridVsListSegmentedControl.action = @selector(switchGridOrListMode:);
+    self.gridVsListSegmentedControl.action = @selector(setGridOrListMode:);
     self.gridVsListSegmentedControl.target = self;
-    self.gridVsListSegmentedControl.selectedSegment = 0;
 
     self.tableView.dataSource = self;
     self.tableView.delegate = self;
     self.tableView.hidden = YES;
-    _gridViewMode = YES;
+    _gridViewMode = self.gridVsListSegmentedControl.selectedSegment == 0;
 }
 
 - (void)reloadViews
 {
-    self.gridVsListSegmentedControl.action = @selector(switchGridOrListMode:);
+    self.gridVsListSegmentedControl.action = @selector(setGridOrListMode:);
     self.gridVsListSegmentedControl.target = self;
 
-    // Since we call switchGridOrListMode to do the actual reloading of the views,
-    // we set the gridViewMode to exactly what the segmented control ISN'T set to,
-    // as switchGridOrListMode will switch the state
-
-    // (The segmented control has the grid view button first, list view button second)
-    _gridViewMode = self.gridVsListSegmentedControl.selectedSegment == 1;
-    [self switchGridOrListMode:self];
+    [self setCurrentViewMode];
 }
 
 - (void)loadMediaSources
@@ -411,24 +405,31 @@ referenceSizeForHeaderInSection:(NSInteger)section
     [self reloadData];
 }
 
-- (void)switchGridOrListMode:(id)sender
+- (void)setCurrentViewMode
 {
-    _gridViewMode = !_gridViewMode;
-    _childDataSource.gridViewMode = _gridViewMode;
-
     if (_gridViewMode) {
         self.collectionViewScrollView.hidden = NO;
         self.tableView.hidden = YES;
-        self.gridVsListSegmentedControl.selectedSegment = 0;
         [self.collectionView reloadData];
     } else {
         self.collectionViewScrollView.hidden = YES;
         self.tableView.hidden = NO;
-        self.gridVsListSegmentedControl.selectedSegment = 1;
         [self.tableView reloadData];
     }
 }
 
+- (void)setGridOrListMode:(id)sender
+{
+    _gridViewMode = self.gridVsListSegmentedControl.selectedSegment == 0;
+    _childDataSource.gridViewMode = _gridViewMode;
+
+    [self setCurrentViewMode];
+
+    if(sender != [[[VLCMain sharedInstance] libraryWindow] navigationStack]) {
+        [[[[VLCMain sharedInstance] libraryWindow] navigationStack] appendCurrentLibraryState];
+    }
+}
+
 #pragma mark - VLCMediaSource Delegation
 
 - (void)mediaSourceChildrenReset:(NSNotification *)aNotification



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/728ab28a0747176ef929fe87b4026996a62fbe8e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/728ab28a0747176ef929fe87b4026996a62fbe8e
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