[vlc-commits] [Git][videolan/vlc][master] macosx: Add a supplementary view for genres and artists collection views

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Aug 16 23:43:47 UTC 2022



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


Commits:
a36e0faa by Claudio Cambra at 2022-08-16T23:28:54+00:00
macosx: Add a supplementary view for genres and artists collection views

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

- - - - -


9 changed files:

- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/UI/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.xib
- modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- + modules/gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h
- + modules/gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.m
- modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m


Changes:

=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -66,6 +66,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/library/VLCLibraryCollectionViewItem.m \
 	gui/macosx/library/VLCLibraryCollectionViewAlbumSupplementaryDetailView.h \
 	gui/macosx/library/VLCLibraryCollectionViewAlbumSupplementaryDetailView.m \
+	gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h \
+	gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.m \
 	gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.h \
 	gui/macosx/library/VLCLibraryCollectionViewSupplementaryElementView.m \
 	gui/macosx/library/VLCLibraryController.h \
@@ -310,6 +312,7 @@ libmacosx_plugin_la_XIB_SOURCES = \
 	gui/macosx/UI/VLCPlaylistTableCellView.xib \
 	gui/macosx/UI/VLCLibraryCollectionViewItem.xib \
 	gui/macosx/UI/VLCLibraryCollectionViewAlbumSupplementaryDetailView.xib \
+	gui/macosx/UI/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.xib \
 	gui/macosx/UI/VLCLibrarySongTableCellView.xib \
 	gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib \
 	gui/macosx/UI/VLCMediaSourceDeviceCollectionViewItem.xib \


=====================================
modules/gui/macosx/UI/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.xib
=====================================
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="20037" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
+        <capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryCollectionViewAudioGroupSupplementaryDetailView"/>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <view id="HAc-or-XD8" customClass="VLCLibraryCollectionViewAudioGroupSupplementaryDetailView">
+            <rect key="frame" x="0.0" y="0.0" width="1071" height="322"/>
+            <autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
+            <subviews>
+                <box boxType="custom" borderType="none" cornerRadius="4" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="TDx-ys-0hc">
+                    <rect key="frame" x="0.0" y="0.0" width="1071" height="302"/>
+                    <view key="contentView" id="l4M-qd-E0u">
+                        <rect key="frame" x="0.0" y="0.0" width="1071" height="302"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                    </view>
+                    <color key="borderColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    <color key="fillColor" name="separatorColor" catalog="System" colorSpace="catalog"/>
+                </box>
+                <stackView distribution="fill" orientation="vertical" alignment="leading" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bw7-QB-Ssc">
+                    <rect key="frame" x="10" y="10" width="1051" height="282"/>
+                    <subviews>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nCe-dY-YMM">
+                            <rect key="frame" x="-2" y="203" width="178" height="79"/>
+                            <textFieldCell key="cell" lineBreakMode="truncatingTail" title="Audio group name" id="6RM-x8-Y4y">
+                                <font key="font" textStyle="title1" name=".SFNS-Regular"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                        <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" id="9ZS-oy-iP9">
+                            <rect key="frame" x="0.0" y="0.0" width="701" height="198"/>
+                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+                            <clipView key="contentView" drawsBackground="NO" id="3V4-tX-owM">
+                                <rect key="frame" x="0.0" y="0.0" width="701" height="198"/>
+                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                <subviews>
+                                    <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowSizeStyle="automatic" viewBased="YES" id="eEJ-WA-0aM" customClass="VLCLibraryTableView">
+                                        <rect key="frame" x="0.0" y="0.0" width="701" height="188"/>
+                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                                        <size key="intercellSpacing" width="3" height="2"/>
+                                        <color key="backgroundColor" red="0" green="0" blue="0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
+                                        <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+                                        <tableColumns>
+                                            <tableColumn width="689" minWidth="10" maxWidth="3.4028234663852886e+38" id="fqq-am-CS8">
+                                                <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
+                                                    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                                </tableHeaderCell>
+                                                <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="1js-Fu-KuW">
+                                                    <font key="font" metaFont="system"/>
+                                                    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                    <color key="backgroundColor" red="1" green="1" blue="1" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
+                                                </textFieldCell>
+                                                <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+                                            </tableColumn>
+                                        </tableColumns>
+                                    </tableView>
+                                </subviews>
+                                <nil key="backgroundColor"/>
+                            </clipView>
+                            <edgeInsets key="contentInsets" left="0.0" right="0.0" top="0.0" bottom="10"/>
+                            <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="ZBY-pE-E7T">
+                                <rect key="frame" x="-100" y="-100" width="701" height="15"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                            </scroller>
+                            <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="WRE-VM-L7s">
+                                <rect key="frame" x="224" y="17" width="15" height="102"/>
+                                <autoresizingMask key="autoresizingMask"/>
+                            </scroller>
+                        </scrollView>
+                    </subviews>
+                    <visibilityPriorities>
+                        <integer value="1000"/>
+                        <integer value="1000"/>
+                    </visibilityPriorities>
+                    <customSpacing>
+                        <real value="3.4028234663852886e+38"/>
+                        <real value="3.4028234663852886e+38"/>
+                    </customSpacing>
+                </stackView>
+            </subviews>
+            <constraints>
+                <constraint firstItem="bw7-QB-Ssc" firstAttribute="leading" secondItem="TDx-ys-0hc" secondAttribute="leading" constant="10" id="8h8-eA-iuE"/>
+                <constraint firstItem="TDx-ys-0hc" firstAttribute="trailing" secondItem="bw7-QB-Ssc" secondAttribute="trailing" constant="10" id="HSf-Hj-QAZ"/>
+                <constraint firstItem="TDx-ys-0hc" firstAttribute="top" secondItem="HAc-or-XD8" secondAttribute="top" constant="20" id="Wob-l9-MuU"/>
+                <constraint firstItem="TDx-ys-0hc" firstAttribute="leading" secondItem="HAc-or-XD8" secondAttribute="leading" id="adT-vN-en1"/>
+                <constraint firstAttribute="bottom" secondItem="TDx-ys-0hc" secondAttribute="bottom" id="aub-cX-QrF"/>
+                <constraint firstItem="TDx-ys-0hc" firstAttribute="bottom" secondItem="bw7-QB-Ssc" secondAttribute="bottom" constant="10" id="ezO-kW-CQH"/>
+                <constraint firstAttribute="trailing" secondItem="TDx-ys-0hc" secondAttribute="trailing" id="g3s-Ri-jQ5"/>
+                <constraint firstItem="bw7-QB-Ssc" firstAttribute="top" secondItem="TDx-ys-0hc" secondAttribute="top" constant="10" id="xKr-cT-vGa"/>
+            </constraints>
+            <connections>
+                <outlet property="audioGroupAlbumsTableView" destination="eEJ-WA-0aM" id="l8k-M9-a8e"/>
+                <outlet property="audioGroupNameTextField" destination="nCe-dY-YMM" id="h3l-p0-w3e"/>
+                <outlet property="tableClipView" destination="3V4-tX-owM" id="t4b-1e-Cl1"/>
+                <outlet property="tableScrollView" destination="9ZS-oy-iP9" id="tab-L3-Scr"/>
+            </connections>
+            <point key="canvasLocation" x="-237.5" y="-284"/>
+        </view>
+    </objects>
+</document>


=====================================
modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -129,6 +129,7 @@ const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
     }
     _tracksTableView.gridStyleMask = NSTableViewSolidHorizontalGridLineMask;
     _tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
+    _tracksTableView.backgroundColor = [NSColor clearColor];
 
     _tracksDataSource = [[VLCLibraryAlbumTracksDataSource alloc] init];
     _tracksTableView.dataSource = _tracksDataSource;


=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -35,6 +35,7 @@
 #import "library/VLCLibraryCollectionViewItem.h"
 #import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewAlbumSupplementaryDetailView.h"
+#import "library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h"
 
 #import "extensions/NSString+Helpers.h"
 #import "views/VLCImageView.h"
@@ -134,6 +135,10 @@
     [_collectionView registerNib:albumSupplementaryDetailView
       forSupplementaryViewOfKind:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind 
                   withIdentifier:VLCLibraryCollectionViewAlbumSupplementaryDetailViewIdentifier];
+    NSNib *audioGroupSupplementaryDetailView = [[NSNib alloc] initWithNibNamed:@"VLCLibraryCollectionViewAudioGroupSupplementaryDetailView" bundle:nil];
+    [_collectionView registerNib:audioGroupSupplementaryDetailView
+      forSupplementaryViewOfKind:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind 
+                  withIdentifier:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewIdentifier];
 
     _collectionViewFlowLayout = [[VLCLibraryCollectionViewFlowLayout alloc] init];
     _collectionView.collectionViewLayout = _collectionViewFlowLayout;
@@ -332,7 +337,7 @@
 - (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
 {
     NSIndexPath *indexPath = indexPaths.anyObject;
-    if (!indexPath || _currentParentType != VLC_ML_PARENT_ALBUM) {
+    if (!indexPath || _currentParentType == VLC_ML_PARENT_UNKNOWN) {
         return;
     }
 
@@ -342,7 +347,7 @@
 - (void)collectionView:(NSCollectionView *)collectionView didDeselectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
 {
     NSIndexPath *indexPath = indexPaths.anyObject;
-    if (!indexPath || _currentParentType != VLC_ML_PARENT_ALBUM) {
+    if (!indexPath || _currentParentType == VLC_ML_PARENT_UNKNOWN) {
         return;
     }
 
@@ -353,13 +358,23 @@
 viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
                atIndexPath:(NSIndexPath *)indexPath
 {
-    if ([kind isEqualToString:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind] && _currentParentType == VLC_ML_PARENT_ALBUM) {
+    if ([kind isEqualToString:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind]) {
+
         VLCLibraryCollectionViewAlbumSupplementaryDetailView* albumSupplementaryDetailView = [collectionView makeSupplementaryViewOfKind:kind withIdentifier:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind forIndexPath:indexPath];
 
         VLCMediaLibraryAlbum *album = _displayedCollection[indexPath.item];
         albumSupplementaryDetailView.representedAlbum = album;
 
         return albumSupplementaryDetailView;
+
+    } else if ([kind isEqualToString:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind]) {
+
+        VLCLibraryCollectionViewAudioGroupSupplementaryDetailView* audioGroupSupplementaryDetailView = [collectionView makeSupplementaryViewOfKind:kind withIdentifier:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind forIndexPath:indexPath];
+
+        id<VLCMediaLibraryAudioGroupProtocol> audioGroup = _displayedCollection[indexPath.item];
+        audioGroupSupplementaryDetailView.representedAudioGroup = audioGroup;
+
+        return audioGroupSupplementaryDetailView;
     }
 
     return nil;
@@ -417,11 +432,9 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
 
 - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex
 {
-    if(tableView == [[[VLCMain sharedInstance] libraryWindow] audioGroupSelectionTableView]) {
-        return NO;
-    }
-
-    return YES;
+    // We use this with nested table views, since the table view cell is the VLCLibraryAlbumTableCellView.
+    // We don't want to select the outer cell, only the inner cells in the album view's table.
+    return NO;
 }
 
 @end


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h
=====================================
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.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 protocol VLCMediaLibraryAudioGroupProtocol;
+ at class VLCImageView;
+
+extern NSString *const VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewIdentifier;
+extern NSCollectionViewSupplementaryElementKind const VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind;
+
+ at interface VLCLibraryCollectionViewAudioGroupSupplementaryDetailView : NSView <NSCollectionViewElement>
+
+ at property (readwrite, retain, nonatomic) id<VLCMediaLibraryAudioGroupProtocol> representedAudioGroup;
+ at property (readwrite, weak) IBOutlet NSTextField *audioGroupNameTextField;
+ at property (readwrite, weak) IBOutlet NSTableView *audioGroupAlbumsTableView;
+ at property (readwrite, weak) IBOutlet NSClipView *tableClipView;
+ at property (readwrite, weak) IBOutlet NSScrollView *tableScrollView;
+
+ at end
+
+NS_ASSUME_NONNULL_END
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.m
=====================================
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.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 "VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h"
+
+#import "library/VLCLibraryDataTypes.h"
+#import "extensions/NSFont+VLCAdditions.h"
+#import "library/VLCLibraryAudioDataSource.h"
+
+NSString *const VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewIdentifier = @"VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewIdentifier";
+NSCollectionViewSupplementaryElementKind const VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind = @"VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewIdentifier";
+
+ at interface VLCLibraryCollectionViewAudioGroupSupplementaryDetailView () 
+{
+    VLCLibraryGroupDataSource *_audioGroupAlbumsDataSource;
+}
+
+ at end
+
+ at implementation VLCLibraryCollectionViewAudioGroupSupplementaryDetailView
+
+- (void)awakeFromNib
+{
+    _audioGroupAlbumsDataSource = [[VLCLibraryGroupDataSource alloc] init];
+    _audioGroupAlbumsTableView.dataSource = _audioGroupAlbumsDataSource;
+    _audioGroupAlbumsTableView.delegate = _audioGroupAlbumsDataSource;
+    
+    _audioGroupNameTextField.font = [NSFont VLCLibrarySupplementaryDetailViewTitleFont];
+}
+
+- (void)setRepresentedAudioGroup:(id<VLCMediaLibraryAudioGroupProtocol>)representedAudioGroup
+{
+    _representedAudioGroup = representedAudioGroup;
+    [self updateRepresentation];
+}
+
+- (void)updateRepresentation
+{
+    if (_representedAudioGroup == nil) {
+        NSAssert(1, @"no media item assigned for collection view item", nil);
+        return;
+    }
+
+    _audioGroupNameTextField.stringValue = _representedAudioGroup.displayString;
+    _audioGroupAlbumsDataSource.representedListOfAlbums = _representedAudioGroup.albums;
+
+    [_audioGroupAlbumsTableView reloadData];
+}
+
+ at end
\ No newline at end of file


=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
=====================================
@@ -21,7 +21,10 @@
  *****************************************************************************/
 
 #import "VLCLibraryCollectionViewFlowLayout.h"
+
 #import "VLCLibraryCollectionViewAlbumSupplementaryDetailView.h"
+#import "VLCLibraryCollectionViewAudioGroupSupplementaryDetailView.h"
+#import "VLCLibraryAudioDataSource.h"
 
 #pragma mark - Private data
 static const NSUInteger kAnimationSteps = 32;
@@ -29,9 +32,8 @@ static const NSUInteger kWrapAroundValue = (NSUInteger)-1;
 
 static const CGFloat kDetailViewMargin = 8.;
 static const CGFloat kDetailViewCollapsedHeight = 0.;
-static const CGFloat kDetailViewExpandedHeight = 300.;
-
-static const CGFloat kAnimationHeightIncrement = kDetailViewExpandedHeight / (CGFloat)kAnimationSteps;
+static const CGFloat kDetailViewDefaultExpandedHeight = 300.;
+static const CGFloat kDetailViewLargeExpandedHeight = 500.;
 
 typedef NS_ENUM(NSUInteger, VLCDetailViewAnimationType)
 {
@@ -51,7 +53,10 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
 {
     NSUInteger _lastHeightIndex;
     CVDisplayLinkRef _displayLinkRef;
-    CGFloat _animationSteps[kAnimationSteps];
+
+    NSArray *_defaultHeightAnimationSteps;
+    NSArray *_largeHeightAnimationSteps;
+    NSArray *_animationSteps;
 }
 
 @property (nonatomic, readwrite) BOOL detailViewIsAnimating;
@@ -70,16 +75,26 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
         return nil;
     }
 
+    _defaultHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:kDetailViewDefaultExpandedHeight]];
+    _largeHeightAnimationSteps = [NSArray arrayWithArray:[self generateAnimationStepsForExpandedViewHeight:kDetailViewLargeExpandedHeight]];
+    _animationSteps = _defaultHeightAnimationSteps;
+    [self resetLayout];
+    
+    return self;
+}
+
+- (NSArray *)generateAnimationStepsForExpandedViewHeight:(NSInteger)height
+{
+    NSMutableArray *generatedAnimationSteps = [NSMutableArray arrayWithCapacity:kAnimationSteps];
+
     // Easing out cubic
     for(int i = 0; i < kAnimationSteps; ++i) {
         CGFloat progress = (CGFloat)i  / (CGFloat)kAnimationSteps;
         progress -= 1;
-        _animationSteps[i] = kDetailViewExpandedHeight * (progress * progress * progress + 1) + kDetailViewCollapsedHeight;
+        generatedAnimationSteps[i] = @(height * (progress * progress * progress + 1) + kDetailViewCollapsedHeight);
     }
-    
-    [self resetLayout];
-    
-    return self;
+
+    return [generatedAnimationSteps copy];
 }
 
 #pragma mark - Public methods
@@ -143,8 +158,23 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
         layoutAttributesArray[i] = attributes;
     }
 
-    // Add detail view to the attributes set -- detail view about to be shown
-    [layoutAttributesArray addObject:[self layoutAttributesForSupplementaryViewOfKind:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind atIndexPath:self.selectedIndexPath]];
+    if([self.collectionView.dataSource isKindOfClass:[VLCLibraryAudioDataSource class]]) {
+        VLCLibraryAudioDataSource *audioDataSource = (VLCLibraryAudioDataSource *)self.collectionView.dataSource;
+
+        // Add detail view to the attributes set -- detail view about to be shown
+        switch(audioDataSource.segmentedControl.selectedSegment) {
+            case 0:
+            case 3:
+                [layoutAttributesArray addObject:[self layoutAttributesForSupplementaryViewOfKind:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind atIndexPath:self.selectedIndexPath]];
+                break;
+            case 1:
+                [layoutAttributesArray addObject:[self layoutAttributesForSupplementaryViewOfKind:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind atIndexPath:self.selectedIndexPath]];
+                break;
+            case 2:
+            default:
+                break;
+        }
+    }
     
     return layoutAttributesArray;
 }
@@ -152,22 +182,33 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
 - (NSCollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSCollectionViewSupplementaryElementKind)elementKind
                                                                      atIndexPath:(NSIndexPath *)indexPath
 {
-    if ([elementKind isEqualToString:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind]) {
+    BOOL isLibrarySupplementaryView = NO;
+
+    if ([elementKind isEqualToString:VLCLibraryCollectionViewAudioGroupSupplementaryDetailViewKind]) {
+        isLibrarySupplementaryView = YES;
+        _animationSteps = _largeHeightAnimationSteps;
+    } else if ([elementKind isEqualToString:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind]) {
+        isLibrarySupplementaryView = YES;
+        _animationSteps = _defaultHeightAnimationSteps;
+    }
+    
+    if(isLibrarySupplementaryView) {
         NSCollectionViewLayoutAttributes *detailViewAttributes = [NSCollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:elementKind
                                                                                                                                 withIndexPath:indexPath];
         NSAssert1(detailViewAttributes != NULL,
                   @"Failed to create NSCollectionViewLayoutAttributes for view of kind %@.",
-                  VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind );
+                  elementKind);
         
         float selectedItemFrameMaxY = _selectedIndexPath == nil ? 0 : NSMaxY([[self layoutAttributesForItemAtIndexPath:_selectedIndexPath] frame]);
         detailViewAttributes.frame = NSMakeRect(NSMinX(self.collectionView.frame),
                                                 selectedItemFrameMaxY + kDetailViewMargin,
-                                                self.collectionViewContentSize.width - 16.0,
-                                                _animationSteps[_animationIndex]);
+                                                self.collectionViewContentSize.width - 20.0,
+                                                [_animationSteps[_animationIndex] floatValue]);
 
         return detailViewAttributes;
     }
-    
+
+    // Default attributes
     NSCollectionViewLayoutAttributes *attributes = [super layoutAttributesForSupplementaryViewOfKind:elementKind
                                                                                          atIndexPath:indexPath];
     [attributes setFrame:[self frameForDisplacedAttributes:attributes]];
@@ -189,7 +230,7 @@ static CVReturn detailViewAnimationCallback(CVDisplayLinkRef displayLink,
     if (self.selectedIndexPath) {
         NSRect selectedItemFrame = [[self layoutAttributesForItemAtIndexPath:_selectedIndexPath] frame];
         if (NSMinY(attributesFrame) > (NSMaxY(selectedItemFrame))) {
-            attributesFrame.origin.y += _animationSteps[_animationIndex] + kDetailViewMargin;
+            attributesFrame.origin.y += [_animationSteps[_animationIndex] floatValue] + kDetailViewMargin;
         }
     }
     return attributesFrame;


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -29,6 +29,7 @@ extern NSString *VLCMediaLibraryMediaItemPasteboardType;
 
 @class VLCMediaLibraryMediaItem;
 @class VLCMediaLibraryAlbum;
+ at class VLCMediaLibraryArtist;
 @class VLCInputItem;
 
 extern const CGFloat VLCMediaLibrary4KWidth;
@@ -112,7 +113,17 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 
 @end
 
- at interface VLCMediaLibraryArtist : NSObject<VLCMediaLibraryItemProtocol>
+ at protocol VLCMediaLibraryAudioGroupProtocol <VLCMediaLibraryItemProtocol>
+
+ at property (readonly) unsigned int numberOfAlbums;
+ at property (readonly) unsigned int numberOfTracks;
+ at property (readonly) NSArray <VLCMediaLibraryArtist *> *artists;
+ at property (readonly) NSArray <VLCMediaLibraryAlbum *> *albums;
+ at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *tracksAsMediaItems;
+
+ at end
+
+ at interface VLCMediaLibraryArtist : NSObject<VLCMediaLibraryAudioGroupProtocol>
 
 + (nullable instancetype)artistWithID:(int64_t)artistID;
 - (instancetype)initWithArtist:(struct vlc_ml_artist_t *)p_artist;
@@ -121,13 +132,10 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 @property (readonly) NSString *shortBiography;
 @property (readonly) NSString *musicBrainzID;
 @property (readonly) unsigned int numberOfAlbums;
- at property (readonly) unsigned int numberOfTracks;
- at property (readonly) NSArray <VLCMediaLibraryAlbum *> *albums;
- at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *tracksAsMediaItems;
 
 @end
 
- at interface VLCMediaLibraryAlbum : NSObject<VLCMediaLibraryItemProtocol>
+ at interface VLCMediaLibraryAlbum : NSObject<VLCMediaLibraryAudioGroupProtocol>
 
 - (instancetype)initWithAlbum:(struct vlc_ml_album_t *)p_album;
 
@@ -135,22 +143,16 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
 @property (readonly) NSString *summary;
 @property (readonly) NSString *artistName;
 @property (readonly) int64_t artistID;
- at property (readonly) size_t numberOfTracks;
 @property (readonly) unsigned int duration;
 @property (readonly) unsigned int year;
- at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *tracksAsMediaItems;
 
 @end
 
- at interface VLCMediaLibraryGenre : NSObject<VLCMediaLibraryItemProtocol>
+ at interface VLCMediaLibraryGenre : NSObject<VLCMediaLibraryAudioGroupProtocol>
 
 - (instancetype)initWithGenre:(struct vlc_ml_genre_t *)p_genre;
 
 @property (readonly) NSString *name;
- at property (readonly) size_t numberOfTracks;
- at property (readonly) NSArray <VLCMediaLibraryArtist *> *artists;
- at property (readonly) NSArray <VLCMediaLibraryAlbum *> *albums;
- at property (readonly) NSArray <VLCMediaLibraryMediaItem *> *tracksAsMediaItems;
 
 - (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock orderedBy:(int)mediaItemParentType;
 


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -258,6 +258,7 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
 @synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
+ at synthesize numberOfTracks = _numberOfTracks;
 
 + (nullable instancetype)artistWithID:(int64_t)artistID
 {
@@ -325,6 +326,11 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
     return countMetadataString;
 }
 
+- (NSArray<VLCMediaLibraryArtist *> *)artists
+{
+    return @[self];
+}
+
 - (NSArray<VLCMediaLibraryAlbum *> *)albums
 {
     return fetchAlbumsForLibraryItem(vlc_ml_list_artist_albums, _libraryID);
@@ -354,6 +360,7 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
 @synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
+ at synthesize numberOfTracks = _numberOfTracks;
 
 - (instancetype)initWithAlbum:(struct vlc_ml_album_t *)p_album
 {
@@ -397,6 +404,16 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
     return [NSString stringWithTime:_duration / VLCMediaLibraryMediaItemDurationDenominator];
 }
 
+- (NSArray<VLCMediaLibraryArtist *> *)artists
+{
+    return @[[VLCMediaLibraryArtist artistWithID:_artistID]];
+}
+
+- (NSArray<VLCMediaLibraryAlbum *> *)albums
+{
+    return @[self];
+}
+
 - (NSArray<VLCMediaLibraryMediaItem *> *)tracksAsMediaItems
 {
     return fetchMediaItemsForLibraryItem(vlc_ml_list_album_tracks, _libraryID);
@@ -421,6 +438,7 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
 @synthesize libraryID = _libraryID;
 @synthesize smallArtworkGenerated = _smallArtworkGenerated;
 @synthesize smallArtworkMRL = _smallArtworkMRL;
+ at synthesize numberOfTracks = _numberOfTracks;
 
 - (instancetype)initWithGenre:(struct vlc_ml_genre_t *)p_genre
 {



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

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