Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
856e27a4 by Claudio Cambra at 2022-11-05T08:46:48+00:00
macosx: Move video library view setup to VLCLibraryVideoDataSource, matching 
VLCLibraryAudioDataSource

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
f554b28f by Claudio Cambra at 2022-11-05T08:46:48+00:00
macosx: Use VLCLibraryCollectionViewFlowLayout in video library

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
d136a63e by Claudio Cambra at 2022-11-05T08:46:48+00:00
macosx: Add supplementary detail view for video library view

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -


4 changed files:

- modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
- modules/gui/macosx/library/VLCLibraryVideoDataSource.h
- modules/gui/macosx/library/VLCLibraryVideoDataSource.m
- modules/gui/macosx/library/VLCLibraryWindow.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
=====================================
@@ -23,6 +23,7 @@
 #import "VLCLibraryCollectionViewFlowLayout.h"
 
 #import "VLCLibraryAudioDataSource.h"
+#import "VLCLibraryVideoDataSource.h"
 #import "VLCLibraryCollectionViewAlbumSupplementaryDetailView.h"
 #import "VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h"
 #import "VLCLibraryCollectionViewMediaItemSupplementaryDetailView.h"
@@ -176,6 +177,9 @@ static CVReturn 
detailViewAnimationCallback(CVDisplayLinkRef displayLink,
                 [layoutAttributesArray addObject:[self 
layoutAttributesForSupplementaryViewOfKind:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind
 atIndexPath:self.selectedIndexPath]];
                 break;
         }
+    } else if([self.collectionView.dataSource 
isKindOfClass:[VLCLibraryVideoDataSource class]]) {
+        VLCLibraryVideoDataSource *videoDataSource = 
(VLCLibraryVideoDataSource *)self.collectionView.dataSource;
+        [layoutAttributesArray addObject:[self 
layoutAttributesForSupplementaryViewOfKind:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind
 atIndexPath:self.selectedIndexPath]];
     }
     
     return layoutAttributesArray;


=====================================
modules/gui/macosx/library/VLCLibraryVideoDataSource.h
=====================================
@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, assign) VLCLibraryModel *libraryModel;
 @property (readwrite, assign) NSCollectionView *libraryMediaCollectionView;
 
+- (void)setupAppearance;
 - (void)reloadData;
 
 @end


=====================================
modules/gui/macosx/library/VLCLibraryVideoDataSource.m
=====================================
@@ -22,7 +22,9 @@
 
 #import "VLCLibraryVideoDataSource.h"
 
+#import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewItem.h"
+#import "library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryDataTypes.h"
@@ -34,6 +36,7 @@
 {
     NSArray *_recentsArray;
     NSArray *_libraryArray;
+    VLCLibraryCollectionViewFlowLayout *_collectionViewFlowLayout;
 }
 
 @end
@@ -68,6 +71,8 @@
         return;
     }
     
+    [_collectionViewFlowLayout resetLayout];
+    
     dispatch_async(dispatch_get_main_queue(), ^{
         _recentsArray = [_libraryModel listOfRecentMedia];
         _libraryArray = [_libraryModel listOfVideoMedia];
@@ -75,6 +80,26 @@
     });
 }
 
+- (void)setupAppearance
+{
+    _libraryMediaCollectionView.dataSource = self;
+    _libraryMediaCollectionView.delegate = self;
+    
+    [_libraryMediaCollectionView registerClass:[VLCLibraryCollectionViewItem 
class] forItemWithIdentifier:VLCLibraryCellIdentifier];
+    [_libraryMediaCollectionView 
registerClass:[VLCLibraryCollectionViewSupplementaryElementView class]
+                    
forSupplementaryViewOfKind:NSCollectionElementKindSectionHeader
+                                
withIdentifier:VLCLibrarySupplementaryElementViewIdentifier];
+    
+    NSNib *mediaItemSupplementaryDetailView = [[NSNib alloc] 
initWithNibNamed:@"VLCLibraryCollectionViewMediaItemSupplementaryDetailView" 
bundle:nil];
+    [_libraryMediaCollectionView registerNib:mediaItemSupplementaryDetailView
+                  
forSupplementaryViewOfKind:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind
+                              
withIdentifier:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewIdentifier];
+
+    _collectionViewFlowLayout = [[VLCLibraryCollectionViewFlowLayout alloc] 
init];
+    _collectionViewFlowLayout.headerReferenceSize = 
[VLCLibraryCollectionViewSupplementaryElementView defaultHeaderSize];
+    _libraryMediaCollectionView.collectionViewLayout = 
_collectionViewFlowLayout;
+}
+
 - (NSInteger)collectionView:(NSCollectionView *)collectionView
      numberOfItemsInSection:(NSInteger)section
 {
@@ -114,25 +139,65 @@
     return viewItem;
 }
 
+- (void)collectionView:(NSCollectionView *)collectionView 
didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
+{
+    NSIndexPath *indexPath = indexPaths.anyObject;
+    if (!indexPath) {
+        return;
+    }
+
+    [_collectionViewFlowLayout expandDetailSectionAtIndex:indexPath];
+}
+
+- (void)collectionView:(NSCollectionView *)collectionView 
didDeselectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
+{
+    NSIndexPath *indexPath = indexPaths.anyObject;
+    if (!indexPath) {
+        return;
+    }
+
+    [_collectionViewFlowLayout collapseDetailSectionAtIndex:indexPath];
+}
+
 - (NSView *)collectionView:(NSCollectionView *)collectionView
 
viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
                atIndexPath:(NSIndexPath *)indexPath
 {
-    VLCLibraryCollectionViewSupplementaryElementView *view = [collectionView 
makeSupplementaryViewOfKind:kind
-                                                                               
           withIdentifier:VLCLibrarySupplementaryElementViewIdentifier
-                                                                               
             forIndexPath:indexPath];
-
-    switch(indexPath.section) {
-        case VLCVideoLibraryRecentsSection:
-            view.stringValue = _NS("Recent");
-            break;
-        case VLCVideoLibraryLibrarySection:
-        default:
-            view.stringValue = _NS("Library");
-            break;
+    if([kind isEqualToString:NSCollectionElementKindSectionHeader]) {
+        VLCLibraryCollectionViewSupplementaryElementView *sectionHeadingView = 
[collectionView makeSupplementaryViewOfKind:kind
+                                                                               
                             
withIdentifier:VLCLibrarySupplementaryElementViewIdentifier
+                                                                               
                               forIndexPath:indexPath];
+        
+        switch(indexPath.section) {
+            case VLCVideoLibraryRecentsSection:
+                sectionHeadingView.stringValue = _NS("Recent");
+                break;
+            case VLCVideoLibraryLibrarySection:
+            default:
+                sectionHeadingView.stringValue = _NS("Library");
+                break;
+        }
+                
+        return sectionHeadingView;
+        
+    } else if ([kind 
isEqualToString:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind]) {
+        VLCLibraryCollectionViewMediaItemSupplementaryDetailView* 
mediaItemSupplementaryDetailView = [collectionView 
makeSupplementaryViewOfKind:kind 
withIdentifier:VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind 
forIndexPath:indexPath];
+        
+        switch(indexPath.section) {
+            case VLCVideoLibraryRecentsSection:
+                mediaItemSupplementaryDetailView.representedMediaItem = 
_recentsArray[indexPath.item];
+                break;
+            case VLCVideoLibraryLibrarySection:
+            default:
+                mediaItemSupplementaryDetailView.representedMediaItem = 
_libraryArray[indexPath.item];
+                break;
+        }
+        
+        mediaItemSupplementaryDetailView.selectedItem = [collectionView 
itemAtIndexPath:indexPath];
+        return mediaItemSupplementaryDetailView;
     }
 
-    return view;
+    return nil;
 }
 
 #pragma mark - drag and drop support


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -292,14 +292,7 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
     _libraryVideoDataSource = [[VLCLibraryVideoDataSource alloc] init];
     _libraryVideoDataSource.libraryModel = 
mainInstance.libraryController.libraryModel;
     _libraryVideoDataSource.libraryMediaCollectionView = 
_videoLibraryCollectionView;
-    _videoLibraryCollectionView.dataSource = _libraryVideoDataSource;
-    _videoLibraryCollectionView.delegate = _libraryVideoDataSource;
-    [_videoLibraryCollectionView registerClass:[VLCLibraryCollectionViewItem 
class] forItemWithIdentifier:VLCLibraryCellIdentifier];
-    [_videoLibraryCollectionView 
registerClass:[VLCLibraryCollectionViewSupplementaryElementView class]
-               forSupplementaryViewOfKind:NSCollectionElementKindSectionHeader
-                           
withIdentifier:VLCLibrarySupplementaryElementViewIdentifier];
-    [(NSCollectionViewFlowLayout 
*)_videoLibraryCollectionView.collectionViewLayout 
setHeaderReferenceSize:[VLCLibraryCollectionViewSupplementaryElementView 
defaultHeaderSize]];
-    [_libraryVideoDataSource reloadData];
+    [_libraryVideoDataSource setupAppearance];
 
     _libraryAudioDataSource = [[VLCLibraryAudioDataSource alloc] init];
     _libraryAudioDataSource.libraryModel = 
mainInstance.libraryController.libraryModel;



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/244a76a900d5877857bdd85bc566a21307ae0caf...d136a63eac85315937fd6437b787bcba50e1962f

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/244a76a900d5877857bdd85bc566a21307ae0caf...d136a63eac85315937fd6437b787bcba50e1962f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to