[vlc-commits] [Git][videolan/vlc][master] macosx: Redesign the selected group album table view

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Mon Aug 8 07:51:50 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
957c2d6a by Claudio Cambra at 2022-08-08T06:24:57+00:00
macosx: Redesign the selected group album table view

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

- - - - -


6 changed files:

- modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
- modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/VLCLibraryWindow.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
=====================================
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<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="14490.70"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -14,26 +14,49 @@
             <subviews>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="cAS-FG-otl" customClass="VLCTrackingView">
                     <rect key="frame" x="0.0" y="0.0" width="640" height="450"/>
+                    <subviews>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lyR-U9-HKd">
+                            <rect key="frame" x="18" y="279" width="108" height="16"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Year" id="7gz-CN-9ab">
+                                <numberFormatter key="formatter" formatterBehavior="default10_4" localizesFormat="NO" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="O17-O0-cUq">
+                                    <real key="minimum" value="0.0"/>
+                                </numberFormatter>
+                                <font key="font" usesAppearanceFont="YES"/>
+                                <color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dd9-b1-XEf">
+                            <rect key="frame" x="18" y="300" width="108" height="16"/>
+                            <textFieldCell key="cell" title="Summary" id="sx3-rr-j2L">
+                                <font key="font" usesAppearanceFont="YES"/>
+                                <color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="U23-gv-Pf6">
+                            <rect key="frame" x="142" y="393" width="74" height="16"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Artist name" id="3Ae-qv-Wyy">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="lyR-U9-HKd" firstAttribute="top" secondItem="dd9-b1-XEf" secondAttribute="bottom" constant="5" id="36N-Cq-Zjf"/>
+                        <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="lyR-U9-HKd" secondAttribute="trailing" constant="20" id="dzL-hG-1nc"/>
+                        <constraint firstItem="U23-gv-Pf6" firstAttribute="trailing" relation="lessThanOrEqual" secondItem="cAS-FG-otl" secondAttribute="trailing" constant="-20" id="gAZ-If-sHJ"/>
+                    </constraints>
                 </customView>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xJW-ps-ycn">
-                    <rect key="frame" x="146" y="395" width="80" height="17"/>
+                    <rect key="frame" x="142" y="414" width="80" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Album name" id="aCe-ia-0Ww">
                         <font key="font" usesAppearanceFont="YES"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lyR-U9-HKd">
-                    <rect key="frame" x="146" y="370" width="31" height="17"/>
-                    <textFieldCell key="cell" lineBreakMode="clipping" title="Year" id="7gz-CN-9ab">
-                        <numberFormatter key="formatter" formatterBehavior="default10_4" localizesFormat="NO" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="O17-O0-cUq">
-                            <real key="minimum" value="0.0"/>
-                        </numberFormatter>
-                        <font key="font" usesAppearanceFont="YES"/>
-                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
-                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                    </textFieldCell>
-                </textField>
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="Ydb-7n-5Cd" customClass="VLCImageView">
                     <rect key="frame" x="20" y="326" width="104" height="104"/>
                     <constraints>
@@ -41,14 +64,6 @@
                         <constraint firstAttribute="width" constant="104" id="m0o-Ct-VQF"/>
                     </constraints>
                 </customView>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dd9-b1-XEf">
-                    <rect key="frame" x="146" y="345" width="62" height="17"/>
-                    <textFieldCell key="cell" lineBreakMode="clipping" title="Summary" id="sx3-rr-j2L">
-                        <font key="font" usesAppearanceFont="YES"/>
-                        <color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
-                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                    </textFieldCell>
-                </textField>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KVh-Zn-l7I">
                     <rect key="frame" x="40" y="346" width="64" height="64"/>
                     <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="libraryPlay" imagePosition="only" alignment="center" inset="2" id="oLK-Ll-w7g">
@@ -61,26 +76,28 @@
                 </button>
             </subviews>
             <constraints>
-                <constraint firstItem="dd9-b1-XEf" firstAttribute="leading" secondItem="lyR-U9-HKd" secondAttribute="leading" id="1rt-8d-FYu"/>
+                <constraint firstItem="dd9-b1-XEf" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="leading" id="5Gn-ze-Gf7"/>
                 <constraint firstItem="KVh-Zn-l7I" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="AZI-Eo-9so"/>
-                <constraint firstItem="lyR-U9-HKd" firstAttribute="top" secondItem="xJW-ps-ycn" secondAttribute="bottom" constant="8" id="CsN-uw-2Hn"/>
                 <constraint firstItem="Ydb-7n-5Cd" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" id="IWI-9l-HnJ"/>
-                <constraint firstItem="lyR-U9-HKd" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" constant="24" id="JgT-WX-XIH"/>
+                <constraint firstItem="lyR-U9-HKd" firstAttribute="trailing" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" id="MCe-hU-gES"/>
                 <constraint firstItem="KVh-Zn-l7I" firstAttribute="centerX" secondItem="Ydb-7n-5Cd" secondAttribute="centerX" id="Mnq-he-JXh"/>
                 <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="20" id="NhG-8C-EDX"/>
                 <constraint firstItem="cAS-FG-otl" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="O89-IU-nIf"/>
-                <constraint firstItem="xJW-ps-ycn" firstAttribute="leading" secondItem="lyR-U9-HKd" secondAttribute="leading" id="Vcg-3v-ITc"/>
-                <constraint firstItem="dd9-b1-XEf" firstAttribute="top" secondItem="lyR-U9-HKd" secondAttribute="bottom" constant="8" id="YgV-8H-R46"/>
-                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="dd9-b1-XEf" secondAttribute="trailing" constant="20" id="bTQ-FM-Uy8"/>
+                <constraint firstItem="U23-gv-Pf6" firstAttribute="top" secondItem="xJW-ps-ycn" secondAttribute="bottom" constant="5" id="a6g-MU-jOX"/>
+                <constraint firstItem="xJW-ps-ycn" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" constant="20" id="dai-Pj-DEx"/>
                 <constraint firstItem="Ydb-7n-5Cd" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="20" id="gVW-Rd-TA5"/>
                 <constraint firstAttribute="bottom" secondItem="cAS-FG-otl" secondAttribute="bottom" id="hr4-VR-MQ0"/>
-                <constraint firstItem="Ydb-7n-5Cd" firstAttribute="centerY" secondItem="lyR-U9-HKd" secondAttribute="centerY" id="oSI-FB-2nA"/>
+                <constraint firstItem="dd9-b1-XEf" firstAttribute="top" secondItem="Ydb-7n-5Cd" secondAttribute="bottom" constant="10" id="it4-Lt-wSE"/>
+                <constraint firstItem="lyR-U9-HKd" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="leading" id="nyg-Ve-PdR"/>
+                <constraint firstItem="dd9-b1-XEf" firstAttribute="trailing" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" id="sFl-F3-GQN"/>
                 <constraint firstAttribute="trailing" secondItem="cAS-FG-otl" secondAttribute="trailing" id="w5r-Yv-oeN"/>
+                <constraint firstItem="xJW-ps-ycn" firstAttribute="top" secondItem="Ydb-7n-5Cd" secondAttribute="top" id="xQf-rb-J0b"/>
+                <constraint firstItem="U23-gv-Pf6" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" constant="20" id="xp8-bi-OAa"/>
                 <constraint firstItem="cAS-FG-otl" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="zdo-e5-cek"/>
-                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="lyR-U9-HKd" secondAttribute="trailing" constant="20" id="zmX-17-AFR"/>
             </constraints>
             <connections>
                 <outlet property="albumNameTextField" destination="xJW-ps-ycn" id="nX9-SH-RZA"/>
+                <outlet property="artistNameTextField" destination="U23-gv-Pf6" id="n1x-05-ZAR"/>
                 <outlet property="playInstantlyButton" destination="KVh-Zn-l7I" id="Ri1-YF-Fe2"/>
                 <outlet property="representedImageView" destination="Ydb-7n-5Cd" id="qBu-r5-jIY"/>
                 <outlet property="summaryTextField" destination="dd9-b1-XEf" id="ne9-oA-zPw"/>


=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -709,8 +709,8 @@
                 <outlet property="upNextLabel" destination="TET-5r-zHx" id="3oI-LK-NDP"/>
                 <outlet property="upNextSeparator" destination="qmL-Ar-cj1" id="GRX-ZE-2UG"/>
                 <outlet property="videoLibraryCollectionView" destination="B8x-e8-7zp" id="u1I-gn-IU1"/>
-                <outlet property="videoLibraryView" destination="vak-Gp-ljo" id="ulu-pc-ctF"/>
                 <outlet property="videoLibraryScrollView" destination="nXS-11-7iK" id="v1d-30-scr"/>
+                <outlet property="videoLibraryView" destination="vak-Gp-ljo" id="ulu-pc-ctF"/>
             </connections>
             <point key="canvasLocation" x="-609" y="325"/>
         </window>
@@ -971,14 +971,13 @@
                                 <rect key="frame" x="0.0" y="0.0" width="401" height="390"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <subviews>
-                                    <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="4ll-T2-J16">
+                                    <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="4ll-T2-J16">
                                         <rect key="frame" x="0.0" y="0.0" width="401" height="390"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                        <size key="intercellSpacing" width="3" height="2"/>
                                         <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                         <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
                                         <tableColumns>
-                                            <tableColumn width="369" minWidth="40" maxWidth="1000" id="WLd-Pi-bR4">
+                                            <tableColumn width="389" minWidth="40" maxWidth="1000000000" id="WLd-Pi-bR4">
                                                 <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
                                                     <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
                                                     <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>


=====================================
modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
=====================================
@@ -31,17 +31,19 @@ NS_ASSUME_NONNULL_BEGIN
 @interface VLCLibraryAlbumTableCellView : NSTableCellView
 
 extern NSString *VLCAudioLibraryCellIdentifier;
+extern NSString *VLCLibraryAlbumTableCellTableViewColumnIdentifier;
 
 + (CGFloat)defaultHeight;
-+ (CGFloat)heightForAlbum:(VLCMediaLibraryAlbum *)album;
 
 @property (readwrite, assign) IBOutlet VLCTrackingView *trackingView;
 @property (readwrite, assign) IBOutlet VLCImageView *representedImageView;
 @property (readwrite, assign) IBOutlet NSTextField *albumNameTextField;
+ at property (readwrite, assign) IBOutlet NSTextField *artistNameTextField;
 @property (readwrite, assign) IBOutlet NSTextField *summaryTextField;
 @property (readwrite, assign) IBOutlet NSTextField *yearTextField;
 @property (readwrite, assign) IBOutlet NSButton *playInstantlyButton;
 
+ at property (readonly) CGFloat height;
 @property (readwrite, assign, nonatomic) VLCMediaLibraryAlbum *representedAlbum;
 
 - (IBAction)playInstantly:(id)sender;


=====================================
modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #import "VLCLibraryAlbumTableCellView.h"
+#import "extensions/NSColor+VLCAdditions.h"
 #import "extensions/NSFont+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
 #import "views/VLCImageView.h"
@@ -32,14 +33,21 @@
 #import "library/VLCLibraryAlbumTracksDataSource.h"
 
 NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier";
+NSString *VLCLibraryAlbumTableCellTableViewColumnIdentifier = @"VLCLibraryAlbumTableCellTableViewColumnIdentifier";
 const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
-const CGFloat LayoutSpacer;
+
+// Note that these values are not necessarily linked to the layout defined in the .xib files.
+// If the spacing in the layout is changed you will want to change these values too.
+const CGFloat VLCLibraryAlbumTableCellViewLargeSpacing = 20;
+const CGFloat VLCLibraryAlbumTableCellViewMediumSpacing = 10;
+const CGFloat VLCLibraryAlbumTableCellViewSmallSpacing = 5;
 
 @interface VLCLibraryAlbumTableCellView ()
 {
     VLCLibraryController *_libraryController;
     VLCLibraryAlbumTracksDataSource *_tracksDataSource;
     NSTableView *_tracksTableView;
+    NSTableColumn *_column;
 }
 @end
 
@@ -50,50 +58,128 @@ const CGFloat LayoutSpacer;
     return VLCLibraryAlbumTableCellViewDefaultHeight;
 }
 
-+ (CGFloat)heightForAlbum:(VLCMediaLibraryAlbum *)album
+- (CGFloat)height
 {
-    if (!album) {
-        return [VLCLibraryAlbumTableCellView defaultHeight];
+    if (_representedAlbum == nil) {
+        return -1;
+    }
+
+    const CGFloat artworkAndSecondaryLabelsHeight = VLCLibraryAlbumTableCellViewLargeSpacing + 
+                                                    _representedImageView.frame.size.height + 
+                                                    VLCLibraryAlbumTableCellViewMediumSpacing + 
+                                                    _summaryTextField.frame.size.height + 
+                                                    VLCLibraryAlbumTableCellViewSmallSpacing +
+                                                    _yearTextField.frame.size.height + 
+                                                    VLCLibraryAlbumTableCellViewLargeSpacing;
+    
+    if(_tracksTableView == nil) {
+        return artworkAndSecondaryLabelsHeight;
     }
 
-    size_t numberOfTracks = album.numberOfTracks;
-    return [VLCLibraryAlbumTableCellView defaultHeight] + numberOfTracks * VLCLibraryTracksRowHeight + numberOfTracks * 0.5;
+    const CGFloat titleAndTableViewHeight = VLCLibraryAlbumTableCellViewLargeSpacing +
+                                            _albumNameTextField.frame.size.height +
+                                            VLCLibraryAlbumTableCellViewSmallSpacing +
+                                            _artistNameTextField.frame.size.height + 
+                                            VLCLibraryAlbumTableCellViewSmallSpacing +
+                                            [self expectedTableViewHeight] +
+                                            VLCLibraryAlbumTableCellViewLargeSpacing;
+
+    return titleAndTableViewHeight > artworkAndSecondaryLabelsHeight ? titleAndTableViewHeight : artworkAndSecondaryLabelsHeight;
+}
+
+- (CGFloat)expectedTableViewWidth
+{
+    // We are positioning the table view to the right of the album art, which means we need
+    // to take into account the album's left spacing, right spacing, and the table view's
+    // right spacing. In this case we are using large spacing for all of these. We also
+    // throw in a little bit extra spacing to compensate for some mysterious internal spacing.
+    return self.frame.size.width - _representedImageView.frame.size.width - VLCLibraryAlbumTableCellViewLargeSpacing * 3.75;
+}
+
+- (CGFloat)expectedTableViewHeight
+{
+    const NSUInteger numberOfTracks = _representedAlbum.numberOfTracks;
+    const CGFloat intercellSpacing = numberOfTracks > 1 ? (numberOfTracks - 1) * _tracksTableView.intercellSpacing.height : 0;
+    return numberOfTracks * VLCLibraryTracksRowHeight + intercellSpacing + VLCLibraryAlbumTableCellViewMediumSpacing;
 }
 
 - (void)awakeFromNib
 {
-    CGRect frame = self.frame;
-    NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"theOnlyColumn"];
-    column.width = frame.size.width - LayoutSpacer * 2.;
-    _tracksTableView = [[NSTableView alloc] initWithFrame:CGRectMake(LayoutSpacer, 14., frame.size.width - LayoutSpacer * 2., 0.)];
+    [self setupTracksTableView];
+    self.albumNameTextField.font = [NSFont VLClibraryLargeCellTitleFont];
+    self.artistNameTextField.font = [NSFont VLClibraryLargeCellSubtitleFont];
+    self.artistNameTextField.textColor = [NSColor VLCOrangeElementColor];
+    self.yearTextField.font = [NSFont VLClibrarySmallCellTitleFont];
+    self.summaryTextField.font = [NSFont VLClibrarySmallCellTitleFont];
+    self.trackingView.viewToHide = self.playInstantlyButton;
+    [self prepareForReuse];
+}
+
+- (void)setupTracksTableView
+{
+    _tracksTableView = [[NSTableView alloc] initWithFrame:NSZeroRect];
+    _column = [[NSTableColumn alloc] initWithIdentifier:VLCLibraryAlbumTableCellTableViewColumnIdentifier];
+    _column.width = [self expectedTableViewWidth];
+    _column.maxWidth = MAXFLOAT;
+    [_tracksTableView addTableColumn:_column];
+
+    if(@available(macOS 11.0, *)) {
+        _tracksTableView.style = NSTableViewStyleFullWidth;
+    }
+    _tracksTableView.gridStyleMask = NSTableViewSolidHorizontalGridLineMask;
     _tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
-    [_tracksTableView addTableColumn:column];
-    _tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
+
     _tracksDataSource = [[VLCLibraryAlbumTracksDataSource alloc] init];
     _tracksTableView.dataSource = _tracksDataSource;
     _tracksTableView.delegate = _tracksDataSource;
     _tracksTableView.doubleAction = @selector(tracksTableViewDoubleClickAction:);
     _tracksTableView.target = self;
-    [self addSubview:_tracksTableView];
-    NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksTableView, _representedImageView);
-    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-20-[_tracksTableView]-20-|" options:0 metrics:0 views:dict]];
-    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-20-[_representedImageView]-14-[_tracksTableView]-14-|" options:0 metrics:0 views:dict]];
 
-    self.albumNameTextField.font = [NSFont VLClibraryLargeCellTitleFont];
-    self.yearTextField.font = [NSFont VLClibraryLargeCellTitleFont];
-    self.summaryTextField.font = [NSFont VLClibraryLargeCellSubtitleFont];
-    self.trackingView.viewToHide = self.playInstantlyButton;
-    [self prepareForReuse];
+    _tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
+    [self addSubview:_tracksTableView];
+    NSString *horizontalVisualConstraints = [NSString stringWithFormat:@"H:|-%f-[_representedImageView]-%f-[_tracksTableView]-%f-|",
+        VLCLibraryAlbumTableCellViewLargeSpacing,
+        VLCLibraryAlbumTableCellViewLargeSpacing,
+        VLCLibraryAlbumTableCellViewLargeSpacing];
+    NSString *verticalVisualContraints = [NSString stringWithFormat:@"V:|-%f-[_albumNameTextField]-%f-[_artistNameTextField]-%f-[_tracksTableView]->=%f-|",
+        VLCLibraryAlbumTableCellViewLargeSpacing,
+        VLCLibraryAlbumTableCellViewSmallSpacing,
+        VLCLibraryAlbumTableCellViewMediumSpacing,
+        VLCLibraryAlbumTableCellViewLargeSpacing];
+    NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksTableView, _representedImageView, _albumNameTextField, _artistNameTextField);
+    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:horizontalVisualConstraints options:0 metrics:0 views:dict]];
+    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:verticalVisualContraints options:0 metrics:0 views:dict]];
 }
 
 - (void)prepareForReuse
 {
     [super prepareForReuse];
+
     self.representedImageView.image = nil;
     self.albumNameTextField.stringValue = @"";
+    self.artistNameTextField.stringValue = @"";
     self.yearTextField.stringValue = @"";
     self.summaryTextField.stringValue = @"";
+    self.yearTextField.hidden = NO;
     self.playInstantlyButton.hidden = YES;
+
+    _tracksDataSource.representedAlbum = nil;
+    [_tracksTableView reloadData];
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+    [super setFrameSize:size];
+
+    // As it expects a scrollview as a parent, the table view will always resize itself and
+    // we cannot directly set its size. However, it resizes itself according to its columns
+    // and rows. We can therefore implicitly set its width by resizing the single column we
+    // are using.
+    //
+    // Since a column is just an NSObject and not an actual NSView object, however, we cannot
+    // use the normal autosizing/constraint systems and must instead calculate and set its
+    // size manually.
+    _column.width = [self expectedTableViewWidth];
 }
 
 - (IBAction)playInstantly:(id)sender
@@ -115,8 +201,12 @@ const CGFloat LayoutSpacer;
 {
     _representedAlbum = representedAlbum;
     self.albumNameTextField.stringValue = _representedAlbum.title;
+    self.artistNameTextField.stringValue = _representedAlbum.artistName;
+    
     if (_representedAlbum.year > 0) {
         self.yearTextField.intValue = _representedAlbum.year;
+    } else {
+        self.yearTextField.hidden = YES;
     }
 
     if (_representedAlbum.summary.length > 0) {


=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -402,11 +402,8 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
 
 - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
 {
-    VLCMediaLibraryAlbum *album = _representedListOfAlbums[row];
-    if (!album) {
-        return -1;
-    }
-    return [VLCLibraryAlbumTableCellView heightForAlbum:album];
+    VLCLibraryAlbumTableCellView *cellView = (VLCLibraryAlbumTableCellView *)[self tableView:tableView viewForTableColumn:[[NSTableColumn alloc] initWithIdentifier:VLCLibraryAlbumTableCellTableViewColumnIdentifier] row:row];
+    return cellView == nil ? -1 : cellView.height;
 }
 
 @end


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -305,6 +305,11 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
     _audioGroupSelectionTableView.dataSource = _libraryAudioGroupDataSource;
     _audioGroupSelectionTableView.delegate = _libraryAudioGroupDataSource;
     _audioGroupSelectionTableView.rowHeight = [VLCLibraryAlbumTableCellView defaultHeight];
+
+    if(@available(macOS 11.0, *)) {
+        _audioGroupSelectionTableView.style = NSTableViewStyleFullWidth;
+    }
+
     _audioLibraryCollectionView.selectable = YES;
     _audioLibraryCollectionView.allowsMultipleSelection = NO;
     _audioLibraryCollectionView.allowsEmptySelection = YES;



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

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