[vlc-commits] [Git][videolan/vlc][master] 12 commits: macosx: Add private hideAllViews method in VLCLibraryAudioViewController

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jan 18 02:47:41 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
bdb33c78 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Add private hideAllViews method in VLCLibraryAudioViewController

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

- - - - -
e73bc29c by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Simplify view presentation in VLCLibraryAudioViewController, hide all views and unhide selectively

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

- - - - -
80330e63 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Simplify initial audio library view presentation

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

- - - - -
5e54c29a by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Fix initial presentation of video library view

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

- - - - -
aca35fc6 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Don't iterate over subviews for library target view, replace in bulk in VLCLibraryAudioViewController

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

- - - - -
768428d5 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Don't iterate over subviews for library target view, replace in bulk in VLCLibraryMediaSourceViewController

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

- - - - -
ab0694cf by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Ensure audio library view is correctly set up before presenting correct view

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

- - - - -
2648412d by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Only restore audio library segement positioning if audio library is going to be opened

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

- - - - -
6657b6a7 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Ensure audio library view is updated when the library model audio count changes

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

- - - - -
841f0040 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Respond to library audio media list changes more granularly in VLCLibraryAudioViewController

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

- - - - -
d33c3508 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Prevent audio library model change detection from override any other view in library window

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

- - - - -
4d4f0f41 by Claudio Cambra at 2023-01-17T22:24:55+00:00
macosx: Ensure video library view is updated when the library model video count changes

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

- - - - -


6 changed files:

- modules/gui/macosx/library/VLCLibraryWindowController.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryWindowController.m
=====================================
@@ -76,8 +76,10 @@
     [libraryWindow.audioSegmentedControl setSelectedSegment:rememberedSelectedLibraryViewAudioSegment];
 
     // We don't want to add these to the navigation stack...
-    [libraryWindow.libraryAudioViewController segmentedControlAction:libraryWindow.navigationStack];
     [libraryWindow segmentedControlAction:libraryWindow.navigationStack];
+    if (rememberedSelectedLibrarySegment == VLCLibraryMusicSegment) {
+        [libraryWindow.libraryAudioViewController segmentedControlAction:libraryWindow.navigationStack];
+    }
 
     // But we do want the "final" initial position to be added. So we manually invoke the navigation stack
     [libraryWindow.navigationStack appendCurrentLibraryState];


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
=====================================
@@ -49,6 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSCollectionView *audioLibraryGridModeSplitViewListSelectionCollectionView;
 @property (readonly) NSSegmentedControl *audioSegmentedControl;
 @property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
+ at property (readonly) NSSegmentedControl *segmentedTitleControl;
 @property (readonly) NSButton *librarySortButton;
 @property (readonly) NSSearchField *librarySearchField;
 @property (readonly) NSVisualEffectView *optionBarView;


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -38,6 +38,8 @@
 
 #import "main/VLCMain.h"
 
+NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudioViewIdentifier";
+
 @interface VLCLibraryAudioViewController()
 {
     NSArray<NSString *> *_placeholderImageNames;
@@ -65,6 +67,12 @@
         [self setupGridModeSplitView];
         [self setupAudioTableViews];
         [self setupAudioSegmentedControl];
+
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelUpdated:)
+                                   name:VLCLibraryModelAudioMediaListUpdated
+                                 object:nil];
     }
 
     return self;
@@ -94,6 +102,7 @@
 
     _audioSegmentedControl = libraryWindow.audioSegmentedControl;
     _gridVsListSegmentedControl = libraryWindow.gridVsListSegmentedControl;
+    _segmentedTitleControl = libraryWindow.segmentedTitleControl;
     _optionBarView = libraryWindow.optionBarView;
     _librarySortButton = libraryWindow.librarySortButton;
     _librarySearchField = libraryWindow.librarySearchField;
@@ -209,15 +218,10 @@
 
 - (void)presentAudioView
 {
-    for (NSView *subview in _libraryTargetView.subviews) {
-        [subview removeFromSuperview];
-    }
+    _libraryTargetView.subviews = @[];
 
-    if (_audioDataSource.libraryModel.numberOfAudioMedia == 0) { // empty library
-        [self presentPlaceholderAudioView];
-    } else {
-        [self presentAudioLibraryView];
-    }
+    [self configureAudioSegmentedControl];
+    [self segmentedControlAction:VLCMain.sharedInstance.libraryWindow.navigationStack];
 
     _librarySortButton.hidden = NO;
     _librarySearchField.enabled = YES;
@@ -245,77 +249,75 @@
     }
 
     _emptyLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
-    [_libraryTargetView addSubview:_emptyLibraryView];
+    _libraryTargetView.subviews = @[_emptyLibraryView];
     NSDictionary *dict = NSDictionaryOfVariableBindings(_emptyLibraryView);
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_emptyLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_emptyLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
+
+    _emptyLibraryView.identifier = VLCLibraryPlaceholderAudioViewIdentifier;
 }
 
-- (void)presentAudioLibraryView
+- (void)prepareAudioLibraryView
 {
     _audioLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
-    [_libraryTargetView addSubview:_audioLibraryView];
+    _libraryTargetView.subviews = @[_audioLibraryView];
     NSDictionary *dict = NSDictionaryOfVariableBindings(_audioLibraryView);
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_audioLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_audioLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
-
-    if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
-        [self presentAudioGridModeView];
-    } else {
-        [self presentAudioTableView];
-    }
-
-    [self configureAudioSegmentedControl];
-    [self segmentedControlAction:VLCMain.sharedInstance.libraryWindow.navigationStack];
 }
 
-- (void)presentAudioGridModeView
+- (void)hideAllViews
 {
     _audioLibrarySplitView.hidden = YES;
+    _audioLibraryGridModeSplitView.hidden = YES;
     _audioSongTableViewScrollView.hidden = YES;
+    _audioCollectionViewScrollView.hidden = YES;
+}
 
+- (void)presentAudioGridModeView
+{
     if (_audioSegmentedControl.selectedSegment == VLCAudioLibrarySongsSegment ||
         _audioSegmentedControl.selectedSegment == VLCAudioLibraryAlbumsSegment) {
 
         [_audioLibraryCollectionView deselectAll:self];
         [(VLCLibraryCollectionViewFlowLayout *)_audioLibraryCollectionView.collectionViewLayout resetLayout];
-        
+
         _audioCollectionViewScrollView.hidden = NO;
-        _audioLibraryGridModeSplitView.hidden = YES;
-        return;
+    } else {
+        _audioLibraryGridModeSplitView.hidden = NO;
     }
-
-    _audioCollectionViewScrollView.hidden = YES;
-    _audioLibraryGridModeSplitView.hidden = NO;
 }
 
 - (void)presentAudioTableView
 {
-    _audioCollectionViewScrollView.hidden = YES;
-    _audioLibraryGridModeSplitView.hidden = YES;
-
     if (_audioSegmentedControl.selectedSegment == VLCAudioLibrarySongsSegment) {
-        _audioLibrarySplitView.hidden = YES;
         _audioSongTableViewScrollView.hidden = NO;
-        return;
+    } else {
+        _audioLibrarySplitView.hidden = NO;
     }
-    _audioSongTableViewScrollView.hidden = YES;
-    _audioLibrarySplitView.hidden = NO;
 }
 
-- (IBAction)segmentedControlAction:(id)sender
+- (void)updatePresentedView
 {
     _audioDataSource.audioLibrarySegment = _audioSegmentedControl.selectedSegment;
 
     if (_audioDataSource.libraryModel.listOfAudioMedia.count == 0) {
-        return;
+        [self presentPlaceholderAudioView];
+    } else {
+        [self prepareAudioLibraryView];
+        [self hideAllViews];
+
+        if (self.gridVsListSegmentedControl.selectedSegment == VLCListViewModeSegment) {
+            [self presentAudioTableView];
+        } else if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
+            [self presentAudioGridModeView];
+        }
     }
+}
 
-    if (self.gridVsListSegmentedControl.selectedSegment == VLCListViewModeSegment) {
-        [self presentAudioTableView];
-    } else if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
-        [self presentAudioGridModeView];
-    }
+- (IBAction)segmentedControlAction:(id)sender
+{
+    [self updatePresentedView];
 
     VLCLibraryNavigationStack *globalNavStack = VLCMain.sharedInstance.libraryWindow.navigationStack;
     if(sender != globalNavStack) {
@@ -328,4 +330,19 @@
     [_audioDataSource reloadData];
 }
 
+- (void)libraryModelUpdated:(NSNotification *)aNotification
+{
+    NSParameterAssert(aNotification);
+    VLCLibraryModel *model = (VLCLibraryModel *)aNotification.object;
+    NSAssert(model, @"Notification object should be a VLCLibraryModel");
+    NSArray<VLCMediaLibraryMediaItem *> * audioList = model.listOfAudioMedia;
+
+    if (_segmentedTitleControl.selectedSegment == VLCLibraryMusicSegment &&
+        ((audioList.count == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
+         (audioList.count > 0 && ![_libraryTargetView.subviews containsObject:_audioLibraryView]))) {
+
+        [self updatePresentedView];
+    }
+}
+
 @end


=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
=====================================
@@ -90,13 +90,11 @@
 
 - (void)presentMediaSourceView:(VLCLibrarySegment)viewSegment
 {
-    for (NSView *subview in _libraryTargetView.subviews) {
-        [subview removeFromSuperview];
-    }
+    _libraryTargetView.subviews = @[];
 
     if (_mediaSourceView.superview == nil) {
         _mediaSourceView.translatesAutoresizingMaskIntoConstraints = NO;
-        [_libraryTargetView addSubview:_mediaSourceView];
+        _libraryTargetView.subviews = @[_mediaSourceView];
         NSDictionary *dict = NSDictionaryOfVariableBindings(_mediaSourceView);
         [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_mediaSourceView(>=572.)]|" options:0 metrics:0 views:dict]];
         [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_mediaSourceView(>=444.)]|" options:0 metrics:0 views:dict]];


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
=====================================
@@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSScrollView *videoLibraryGroupsTableViewScrollView;
 @property (readonly) NSTableView *videoLibraryGroupsTableView;
 @property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
+ at property (readonly) NSSegmentedControl *segmentedTitleControl;
 @property (readonly) NSButton *librarySortButton;
 @property (readonly) NSSearchField *librarySearchField;
 @property (readonly) NSVisualEffectView *optionBarView;


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
=====================================
@@ -46,6 +46,12 @@
         [self setupTableViewDataSource];
         [self setupGridViewController];
         [self setupVideoPlaceholderView];
+
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelUpdated:)
+                                   name:VLCLibraryModelVideoMediaListUpdated
+                                 object:nil];
     }
 
     return self;
@@ -66,6 +72,7 @@
     _videoLibraryGroupsTableView = libraryWindow.videoLibraryGroupsTableView;
 
     _gridVsListSegmentedControl = libraryWindow.gridVsListSegmentedControl;
+    _segmentedTitleControl = libraryWindow.segmentedTitleControl;
     _optionBarView = libraryWindow.optionBarView;
     _librarySortButton = libraryWindow.librarySortButton;
     _librarySearchField = libraryWindow.librarySearchField;
@@ -114,17 +121,20 @@
 
 #pragma mark - Show the video library view
 
-- (void)presentVideoView
+- (void)updatePresentedView
 {
-    for (NSView *subview in _libraryTargetView.subviews) {
-        [subview removeFromSuperview];
-    }
-
     if (_libraryVideoTableViewDataSource.libraryModel.numberOfVideoMedia == 0) { // empty library
         [self presentPlaceholderVideoLibraryView];
     } else {
         [self presentVideoLibraryView];
     }
+}
+
+- (void)presentVideoView
+{
+    _libraryTargetView.subviews = @[];
+
+    [self updatePresentedView];
 
     _librarySortButton.hidden = NO;
     _librarySearchField.enabled = YES;
@@ -141,7 +151,7 @@
     }
 
     _emptyLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
-    [_libraryTargetView addSubview:_emptyLibraryView];
+    _libraryTargetView.subviews = @[_emptyLibraryView];
     NSDictionary *dict = NSDictionaryOfVariableBindings(_emptyLibraryView);
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_emptyLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_emptyLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
@@ -153,7 +163,8 @@
 - (void)presentVideoLibraryView
 {
     _videoLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
-    [_libraryTargetView addSubview:_videoLibraryView];
+    _libraryTargetView.subviews = @[_videoLibraryView];
+
     NSDictionary *dict = NSDictionaryOfVariableBindings(_videoLibraryView);
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_videoLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
     [_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_videoLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
@@ -169,4 +180,19 @@
     }
 }
 
+- (void)libraryModelUpdated:(NSNotification *)aNotification
+{
+    NSParameterAssert(aNotification);
+    VLCLibraryModel *model = (VLCLibraryModel *)aNotification.object;
+    NSAssert(model, @"Notification object should be a VLCLibraryModel");
+    NSArray<VLCMediaLibraryMediaItem *> * videoList = model.listOfVideoMedia;
+
+    if (_segmentedTitleControl.selectedSegment == VLCLibraryVideoSegment &&
+        ((videoList.count == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
+         (videoList.count > 0 && ![_libraryTargetView.subviews containsObject:_videoLibraryView]))) {
+
+        [self updatePresentedView];
+    }
+}
+
 @end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1183df18ae6c394097b46dd01e1b749d7251aa59...4d4f0f41efd631821b1b2ccd4574e73faeda4178

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1183df18ae6c394097b46dd01e1b749d7251aa59...4d4f0f41efd631821b1b2ccd4574e73faeda4178
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