[vlc-commits] macosx/library: create album track listing table view in code

Felix Paul Kühne git at videolan.org
Thu Aug 15 14:01:19 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Aug 14 14:19:13 2019 +0200| [2c57e347bcf70002a5e7fd4d0df0dfc7b5c9f0a0] | committer: Felix Paul Kühne

macosx/library: create album track listing table view in code

this way, we can create it without a surrounding scroll view allowing user interaction with the wrapping parent scroll view

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

 .../gui/macosx/UI/VLCLibraryAlbumTableCellView.xib | 66 +---------------------
 modules/gui/macosx/UI/VLCLibraryTableCellView.xib  | 12 ++--
 .../macosx/library/VLCLibraryAlbumTableCellView.h  |  1 -
 .../macosx/library/VLCLibraryAlbumTableCellView.m  | 24 ++++++--
 4 files changed, 26 insertions(+), 77 deletions(-)

diff --git a/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib b/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
index 240de8859f..73baaede84 100644
--- a/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
+++ b/modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib
@@ -49,65 +49,6 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <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"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <subviews>
-                            <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="3Uj-1y-jNN">
-                                <rect key="frame" x="0.0" y="0.0" width="600" height="303"/>
-                                <autoresizingMask key="autoresizingMask"/>
-                                <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 editable="NO" width="597" minWidth="40" maxWidth="1000" id="uk8-7Y-PH4">
-                                        <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
-                                            <font key="font" metaFont="smallSystem"/>
-                                            <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
-                                            <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
-                                        </tableHeaderCell>
-                                        <textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="5BF-Dw-feh">
-                                            <font key="font" metaFont="system"/>
-                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                            <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                        </textFieldCell>
-                                        <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
-                                        <prototypeCellViews>
-                                            <tableCellView id="DeP-kQ-X4h">
-                                                <rect key="frame" x="1" y="1" width="597" height="17"/>
-                                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                                <subviews>
-                                                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w77-Dx-5e6">
-                                                        <rect key="frame" x="0.0" y="0.0" width="597" height="17"/>
-                                                        <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
-                                                        <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="pqd-by-fVz">
-                                                            <font key="font" metaFont="system"/>
-                                                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                                                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                                                        </textFieldCell>
-                                                    </textField>
-                                                </subviews>
-                                                <connections>
-                                                    <outlet property="textField" destination="w77-Dx-5e6" id="Nb9-7L-0IE"/>
-                                                </connections>
-                                            </tableCellView>
-                                        </prototypeCellViews>
-                                    </tableColumn>
-                                </tableColumns>
-                            </tableView>
-                        </subviews>
-                    </clipView>
-                    <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="wFZ-8V-ntY">
-                        <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="-100" y="-100" width="15" height="102"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </scroller>
-                </scrollView>
                 <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">
@@ -122,11 +63,9 @@
             <constraints>
                 <constraint firstItem="dd9-b1-XEf" firstAttribute="leading" secondItem="lyR-U9-HKd" secondAttribute="leading" id="1rt-8d-FYu"/>
                 <constraint firstItem="KVh-Zn-l7I" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="AZI-Eo-9so"/>
-                <constraint firstItem="3Uj-1y-jNN" firstAttribute="top" secondItem="Ydb-7n-5Cd" secondAttribute="bottom" constant="9" id="CJ3-50-Sn9"/>
                 <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 firstAttribute="trailing" secondItem="Xp8-b8-BMe" secondAttribute="trailing" constant="20" id="KbL-qd-5m6"/>
                 <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"/>
@@ -135,9 +74,7 @@
                 <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="dd9-b1-XEf" secondAttribute="trailing" constant="20" id="bTQ-FM-Uy8"/>
                 <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="Xp8-b8-BMe" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" id="l8l-PX-NFe"/>
                 <constraint firstItem="Ydb-7n-5Cd" firstAttribute="centerY" secondItem="lyR-U9-HKd" secondAttribute="centerY" id="oSI-FB-2nA"/>
-                <constraint firstAttribute="bottom" secondItem="Xp8-b8-BMe" secondAttribute="bottom" constant="14" id="qne-TO-lMs"/>
                 <constraint firstAttribute="trailing" secondItem="cAS-FG-otl" secondAttribute="trailing" id="w5r-Yv-oeN"/>
                 <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"/>
@@ -148,10 +85,9 @@
                 <outlet property="representedImageView" destination="Ydb-7n-5Cd" id="qBu-r5-jIY"/>
                 <outlet property="summaryTextField" destination="dd9-b1-XEf" id="ne9-oA-zPw"/>
                 <outlet property="trackingView" destination="cAS-FG-otl" id="9xY-EB-D5j"/>
-                <outlet property="tracksTableView" destination="3Uj-1y-jNN" id="zIn-tV-FZG"/>
                 <outlet property="yearTextField" destination="lyR-U9-HKd" id="3Ps-CJ-pI5"/>
             </connections>
-            <point key="canvasLocation" x="219" y="217.5"/>
+            <point key="canvasLocation" x="219" y="217"/>
         </customView>
     </objects>
     <resources>
diff --git a/modules/gui/macosx/UI/VLCLibraryTableCellView.xib b/modules/gui/macosx/UI/VLCLibraryTableCellView.xib
index 542c6976fc..cda18ab13d 100644
--- a/modules/gui/macosx/UI/VLCLibraryTableCellView.xib
+++ b/modules/gui/macosx/UI/VLCLibraryTableCellView.xib
@@ -16,7 +16,7 @@
                     <rect key="frame" x="0.0" y="0.0" width="398" height="71"/>
                 </customView>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ohB-P0-nCv">
-                    <rect key="frame" x="76" y="27" width="37" height="17"/>
+                    <rect key="frame" x="76" y="27" width="321" height="17"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="ZPw-XO-XD1">
                         <font key="font" usesAppearanceFont="YES"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -24,7 +24,7 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xJW-ps-ycn">
-                    <rect key="frame" x="76" y="39" width="37" height="17"/>
+                    <rect key="frame" x="76" y="39" width="321" height="17"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="aCe-ia-0Ww">
                         <font key="font" usesAppearanceFont="YES"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -39,7 +39,7 @@
                     </constraints>
                 </customView>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TPv-k2-6XS">
-                    <rect key="frame" x="76" y="16" width="37" height="17"/>
+                    <rect key="frame" x="76" y="16" width="321" height="17"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="jZ4-pa-K3T">
                         <font key="font" usesAppearanceFont="YES"/>
                         <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -71,13 +71,13 @@
                 <constraint firstItem="TPv-k2-6XS" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="4qb-9H-TVg"/>
                 <constraint firstItem="Ydb-7n-5Cd" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="3" id="8hv-Qt-uAI"/>
                 <constraint firstItem="9U4-xB-uBz" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="BrT-ZR-zAc"/>
-                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="3" id="DYW-KQ-pre"/>
+                <constraint firstAttribute="trailing" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="3" id="DYW-KQ-pre"/>
                 <constraint firstItem="xJW-ps-ycn" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="DYk-9g-adD"/>
                 <constraint firstItem="ffE-px-l0g" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="EMs-It-nUH"/>
                 <constraint firstAttribute="bottom" secondItem="ffE-px-l0g" secondAttribute="bottom" id="I7D-8N-oA1"/>
                 <constraint firstItem="ffE-px-l0g" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="M01-2i-CLZ"/>
-                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="TPv-k2-6XS" secondAttribute="trailing" constant="3" id="PQV-7d-ldF"/>
-                <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ohB-P0-nCv" secondAttribute="trailing" constant="3" id="Sm0-L4-7aP"/>
+                <constraint firstAttribute="trailing" secondItem="TPv-k2-6XS" secondAttribute="trailing" constant="3" id="PQV-7d-ldF"/>
+                <constraint firstAttribute="trailing" secondItem="ohB-P0-nCv" secondAttribute="trailing" constant="3" id="Sm0-L4-7aP"/>
                 <constraint firstAttribute="bottom" secondItem="Ydb-7n-5Cd" secondAttribute="bottom" constant="3" id="aVd-Ld-lUH"/>
                 <constraint firstItem="TPv-k2-6XS" firstAttribute="top" secondItem="9U4-xB-uBz" secondAttribute="bottom" constant="2" id="bpM-Qh-hOY"/>
                 <constraint firstItem="NFZ-x0-t5c" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="dRw-WH-Y00"/>
diff --git a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
index 74757f9d6f..b5f91c44c9 100644
--- a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
+++ b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h
@@ -39,7 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readwrite, assign) IBOutlet NSTextField *albumNameTextField;
 @property (readwrite, assign) IBOutlet NSTextField *summaryTextField;
 @property (readwrite, assign) IBOutlet NSTextField *yearTextField;
- at property (readwrite, assign) IBOutlet NSTableView *tracksTableView;
 @property (readwrite, assign) IBOutlet NSButton *playInstantlyButton;
 
 @property (readwrite, assign, nonatomic) VLCMediaLibraryAlbum *representedAlbum;
diff --git a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
index 69efcfb4a2..0c5a93c166 100644
--- a/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
+++ b/modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * VLCLibraryAlbumTableself.m: MacOS X interface module
+ * VLCLibraryAlbumTableCellView.m: MacOS X interface module
  *****************************************************************************
  * Copyright (C) 2019 VLC authors and VideoLAN
  *
@@ -33,6 +33,7 @@
 NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier";
 const CGFloat VLCLibraryTracksRowHeight = 50.;
 const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
+const CGFloat LayoutSpacer;
 
 @interface VLCLibraryTracksDataSource : NSObject <NSTableViewDataSource, NSTableViewDelegate>
 
@@ -44,6 +45,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 {
     VLCLibraryController *_libraryController;
     VLCLibraryTracksDataSource *_tracksDataSource;
+    NSTableView *_tracksTableView;
 }
 @end
 
@@ -66,6 +68,21 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
 
 - (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.)];
+    _tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
+    [_tracksTableView addTableColumn:column];
+    _tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
+    _tracksDataSource = [[VLCLibraryTracksDataSource alloc] init];
+    _tracksTableView.dataSource = _tracksDataSource;
+    _tracksTableView.delegate = _tracksDataSource;
+    [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];
@@ -118,11 +135,8 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
     }
     self.representedImageView.image = image;
 
-    self.tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
-    _tracksDataSource = [[VLCLibraryTracksDataSource alloc] init];
     _tracksDataSource.representedAlbum = _representedAlbum;
-    self.tracksTableView.dataSource = _tracksDataSource;
-    self.tracksTableView.delegate = _tracksDataSource;
+    [_tracksTableView reloadData];
 }
 
 @end



More information about the vlc-commits mailing list