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


Commits:
47a6e95a by Claudio Cambra at 2022-07-01T09:37:13+00:00
macosx: Fix the grid vs list view switching in the library

Prior to this PR, the buttons would not work in the video or audio
views and the selection made in these views would not be respected
when switching to the media source views.

Signed-off-by: Claudio Cambra <claudio.cam...@gmail.com>

- - - - -


2 changed files:

- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -86,6 +86,7 @@ static NSArray<NSLayoutConstraint *> 
*audioPlaceholderImageViewSizeConstraints;
     VLCFSPanelController *_fspanel;
     
     NSInteger _currentSelectedSegment;
+    NSInteger _currentSelectedViewModeSegment;
 }
 
 @property (nonatomic, readwrite, strong) IBOutlet NSView *emptyLibraryView;
@@ -463,11 +464,14 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
 
 - (void)segmentedControlAction:(id)sender
 {
-    if (_segmentedTitleControl.selectedSegment == _currentSelectedSegment) {
+    if (_segmentedTitleControl.selectedSegment == _currentSelectedSegment && 
+        _gridVsListSegmentedControl.selectedSegment == 
_currentSelectedViewModeSegment) {
         return;
     }
     
     _currentSelectedSegment = _segmentedTitleControl.selectedSegment;
+    _currentSelectedViewModeSegment = 
_gridVsListSegmentedControl.selectedSegment;
+
     switch (_currentSelectedSegment) {
         case 0:
             [self showVideoLibrary];
@@ -522,6 +526,8 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
     _optionBarView.hidden = YES;
     _audioSegmentedControl.hidden = YES;
 
+    self.gridVsListSegmentedControl.target = self;
+    self.gridVsListSegmentedControl.action = 
@selector(segmentedControlAction:);
 }
 
 - (void)showAudioLibrary


=====================================
modules/gui/macosx/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -114,7 +114,14 @@ NSString *VLCMediaSourceTableViewCellIdentifier = 
@"VLCMediaSourceTableViewCellI
 {
     self.gridVsListSegmentedControl.action = @selector(switchGridOrListMode:);
     self.gridVsListSegmentedControl.target = self;
-    self.gridVsListSegmentedControl.selectedSegment = _gridViewMode ? 0 : 1;
+
+    // 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];
 }
 
 - (void)loadMediaSources
@@ -430,10 +437,12 @@ referenceSizeForHeaderInSection:(NSInteger)section
     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];
     }
 }



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/47a6e95a74af2c36d120db37ae53c7e3684a77c6

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/commit/47a6e95a74af2c36d120db37ae53c7e3684a77c6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to