[vlc-commits] macosx/library: add variable row heights for albums

Felix Paul Kühne git at videolan.org
Wed Aug 14 13:42:24 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Aug 14 13:39:32 2019 +0200| [192787cc02984fc07411e164e3903d241bdb567d] | committer: Felix Paul Kühne

macosx/library: add variable row heights for albums

Depending on the number of tracks per albums, the list will now increase respectively and no longer scroll

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=192787cc02984fc07411e164e3903d241bdb567d
---

 modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib   |  6 +++---
 .../gui/macosx/library/VLCLibraryAlbumTableCellView.h    |  6 +++++-
 .../gui/macosx/library/VLCLibraryAlbumTableCellView.m    | 16 ++++++++++++++++
 modules/gui/macosx/library/VLCLibraryAudioDataSource.m   |  9 +++++++++
 modules/gui/macosx/library/VLCLibraryWindow.m            |  5 ++---
 5 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib b/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
index a9d933855b..240de8859f 100644
--- a/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
+++ b/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
@@ -49,7 +49,7 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xp8-b8-BMe">
+                <scrollView borderType="none" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="Xp8-b8-BMe">
                     <rect key="frame" x="20" y="14" width="600" height="303"/>
                     <clipView key="contentView" id="Mw1-Z3-rfh">
                         <rect key="frame" x="0.0" y="0.0" width="600" height="303"/>
@@ -100,11 +100,11 @@
                         </subviews>
                     </clipView>
                     <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="wFZ-8V-ntY">
-                        <rect key="frame" x="1" y="119" width="223" height="15"/>
+                        <rect key="frame" x="-100" y="-100" width="223" height="15"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                     <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="A0h-zT-v1o">
-                        <rect key="frame" x="224" y="17" width="15" height="102"/>
+                        <rect key="frame" x="-100" y="-100" width="15" height="102"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </scroller>
                 </scrollView>
diff --git a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
index 814011f7f8..74757f9d6f 100644
--- a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
+++ b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
@@ -31,6 +31,9 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCLibraryAlbumTableCellView : NSTableCellView
 
++ (CGFloat)defaultHeight;
++ (CGFloat)heightForAlbum:(VLCMediaLibraryAlbum *)album;
+
 @property (readwrite, assign) IBOutlet VLCTrackingView *trackingView;
 @property (readwrite, assign) IBOutlet VLCImageView *representedImageView;
 @property (readwrite, assign) IBOutlet NSTextField *albumNameTextField;
@@ -38,10 +41,11 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, assign) IBOutlet NSTextField *yearTextField;
 @property (readwrite, assign) IBOutlet NSTableView *tracksTableView;
 @property (readwrite, assign) IBOutlet NSButton *playInstantlyButton;
-- (IBAction)playInstantly:(id)sender;
 
 @property (readwrite, assign, nonatomic) VLCMediaLibraryAlbum *representedAlbum;
 
+- (IBAction)playInstantly:(id)sender;
+
 @end
 
 NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
index 5c670a119d..69efcfb4a2 100644
--- a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
+++ b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
@@ -32,6 +32,7 @@
 
 NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier";
 const CGFloat VLCLibraryTracksRowHeight = 50.;
+const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 
 @interface VLCLibraryTracksDataSource : NSObject <NSTableViewDataSource, NSTableViewDelegate>
 
@@ -48,6 +49,21 @@ const CGFloat VLCLibraryTracksRowHeight = 50.;
 
 @implementation VLCLibraryAlbumTableCellView
 
++ (CGFloat)defaultHeight
+{
+    return VLCLibraryAlbumTableCellViewDefaultHeight;
+}
+
++ (CGFloat)heightForAlbum:(VLCMediaLibraryAlbum *)album
+{
+    if (!album) {
+        return [VLCLibraryAlbumTableCellView defaultHeight];
+    }
+
+    size_t numberOfTracks = album.numberOfTracks;
+    return [VLCLibraryAlbumTableCellView defaultHeight] + numberOfTracks * VLCLibraryTracksRowHeight;
+}
+
 - (void)awakeFromNib
 {
     self.albumNameTextField.font = [NSFont VLClibraryLargeCellTitleFont];
diff --git a/modules/gui/macosx/library/VLCLibraryAudioDataSource.m b/modules/gui/macosx/library/VLCLibraryAudioDataSource.m
index 9db88f9637..e9ed995ca7 100644
--- a/modules/gui/macosx/library/VLCLibraryAudioDataSource.m
+++ b/modules/gui/macosx/library/VLCLibraryAudioDataSource.m
@@ -383,4 +383,13 @@ static NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier
     return cellView;
 }
 
+- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
+{
+    VLCMediaLibraryAlbum *album = _representedListOfAlbums[row];
+    if (!album) {
+        return -1;
+    }
+    return [VLCLibraryAlbumTableCellView heightForAlbum:album];
+}
+
 @end
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index b9990cb3bf..7898f54d33 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -39,6 +39,7 @@
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
 #import "library/VLCLibrarySortingMenuController.h"
+#import "library/VLCLibraryAlbumTableCellView.h"
 
 #import "media-source/VLCMediaSourceBaseDataSource.h"
 
@@ -231,7 +232,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     _libraryAudioDataSource.groupDataSource = _libraryAudioGroupDataSource;
     _audioGroupSelectionTableView.dataSource = _libraryAudioGroupDataSource;
     _audioGroupSelectionTableView.delegate = _libraryAudioGroupDataSource;
-    _audioGroupSelectionTableView.rowHeight = 450.;
+    _audioGroupSelectionTableView.rowHeight = [VLCLibraryAlbumTableCellView defaultHeight];
 
     _mediaSourceDataSource = [[VLCMediaSourceBaseDataSource alloc] init];
     _mediaSourceDataSource.collectionView = _mediaSourceCollectionView;
@@ -414,8 +415,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
         [_libraryAudioDataSource reloadAppearance];
     } else {
         _audioLibrarySplitView.hidden = NO;
-        _audioLibrarySplitView.wantsLayer = YES;
-        _audioLibrarySplitView.layer.backgroundColor = [NSColor redColor].CGColor;
         _audioCollectionViewScrollView.hidden = YES;
         [_libraryAudioDataSource reloadAppearance];
         [_audioCollectionSelectionTableView reloadData];



More information about the vlc-commits mailing list