Skip to content

Commit 2c57e34

Browse files
committed
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
1 parent 51450a0 commit 2c57e34

File tree

4 files changed

+26
-77
lines changed

4 files changed

+26
-77
lines changed

modules/gui/macosx/UI/VLCLibraryAlbumTableCellView.xib

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -49,65 +49,6 @@
4949
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
5050
</textFieldCell>
5151
</textField>
52-
<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">
53-
<rect key="frame" x="20" y="14" width="600" height="303"/>
54-
<clipView key="contentView" id="Mw1-Z3-rfh">
55-
<rect key="frame" x="0.0" y="0.0" width="600" height="303"/>
56-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
57-
<subviews>
58-
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="3Uj-1y-jNN">
59-
<rect key="frame" x="0.0" y="0.0" width="600" height="303"/>
60-
<autoresizingMask key="autoresizingMask"/>
61-
<size key="intercellSpacing" width="3" height="2"/>
62-
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
63-
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
64-
<tableColumns>
65-
<tableColumn editable="NO" width="597" minWidth="40" maxWidth="1000" id="uk8-7Y-PH4">
66-
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
67-
<font key="font" metaFont="smallSystem"/>
68-
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
69-
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
70-
</tableHeaderCell>
71-
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="5BF-Dw-feh">
72-
<font key="font" metaFont="system"/>
73-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
74-
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
75-
</textFieldCell>
76-
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
77-
<prototypeCellViews>
78-
<tableCellView id="DeP-kQ-X4h">
79-
<rect key="frame" x="1" y="1" width="597" height="17"/>
80-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
81-
<subviews>
82-
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="w77-Dx-5e6">
83-
<rect key="frame" x="0.0" y="0.0" width="597" height="17"/>
84-
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
85-
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="pqd-by-fVz">
86-
<font key="font" metaFont="system"/>
87-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
88-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
89-
</textFieldCell>
90-
</textField>
91-
</subviews>
92-
<connections>
93-
<outlet property="textField" destination="w77-Dx-5e6" id="Nb9-7L-0IE"/>
94-
</connections>
95-
</tableCellView>
96-
</prototypeCellViews>
97-
</tableColumn>
98-
</tableColumns>
99-
</tableView>
100-
</subviews>
101-
</clipView>
102-
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="wFZ-8V-ntY">
103-
<rect key="frame" x="-100" y="-100" width="223" height="15"/>
104-
<autoresizingMask key="autoresizingMask"/>
105-
</scroller>
106-
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="A0h-zT-v1o">
107-
<rect key="frame" x="-100" y="-100" width="15" height="102"/>
108-
<autoresizingMask key="autoresizingMask"/>
109-
</scroller>
110-
</scrollView>
11152
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KVh-Zn-l7I">
11253
<rect key="frame" x="40" y="346" width="64" height="64"/>
11354
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="libraryPlay" imagePosition="only" alignment="center" inset="2" id="oLK-Ll-w7g">
@@ -122,11 +63,9 @@
12263
<constraints>
12364
<constraint firstItem="dd9-b1-XEf" firstAttribute="leading" secondItem="lyR-U9-HKd" secondAttribute="leading" id="1rt-8d-FYu"/>
12465
<constraint firstItem="KVh-Zn-l7I" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="AZI-Eo-9so"/>
125-
<constraint firstItem="3Uj-1y-jNN" firstAttribute="top" secondItem="Ydb-7n-5Cd" secondAttribute="bottom" constant="9" id="CJ3-50-Sn9"/>
12666
<constraint firstItem="lyR-U9-HKd" firstAttribute="top" secondItem="xJW-ps-ycn" secondAttribute="bottom" constant="8" id="CsN-uw-2Hn"/>
12767
<constraint firstItem="Ydb-7n-5Cd" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" id="IWI-9l-HnJ"/>
12868
<constraint firstItem="lyR-U9-HKd" firstAttribute="leading" secondItem="Ydb-7n-5Cd" secondAttribute="trailing" constant="24" id="JgT-WX-XIH"/>
129-
<constraint firstAttribute="trailing" secondItem="Xp8-b8-BMe" secondAttribute="trailing" constant="20" id="KbL-qd-5m6"/>
13069
<constraint firstItem="KVh-Zn-l7I" firstAttribute="centerX" secondItem="Ydb-7n-5Cd" secondAttribute="centerX" id="Mnq-he-JXh"/>
13170
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="20" id="NhG-8C-EDX"/>
13271
<constraint firstItem="cAS-FG-otl" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="O89-IU-nIf"/>
@@ -135,9 +74,7 @@
13574
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="dd9-b1-XEf" secondAttribute="trailing" constant="20" id="bTQ-FM-Uy8"/>
13675
<constraint firstItem="Ydb-7n-5Cd" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="20" id="gVW-Rd-TA5"/>
13776
<constraint firstAttribute="bottom" secondItem="cAS-FG-otl" secondAttribute="bottom" id="hr4-VR-MQ0"/>
138-
<constraint firstItem="Xp8-b8-BMe" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" id="l8l-PX-NFe"/>
13977
<constraint firstItem="Ydb-7n-5Cd" firstAttribute="centerY" secondItem="lyR-U9-HKd" secondAttribute="centerY" id="oSI-FB-2nA"/>
140-
<constraint firstAttribute="bottom" secondItem="Xp8-b8-BMe" secondAttribute="bottom" constant="14" id="qne-TO-lMs"/>
14178
<constraint firstAttribute="trailing" secondItem="cAS-FG-otl" secondAttribute="trailing" id="w5r-Yv-oeN"/>
14279
<constraint firstItem="cAS-FG-otl" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="zdo-e5-cek"/>
14380
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="lyR-U9-HKd" secondAttribute="trailing" constant="20" id="zmX-17-AFR"/>
@@ -148,10 +85,9 @@
14885
<outlet property="representedImageView" destination="Ydb-7n-5Cd" id="qBu-r5-jIY"/>
14986
<outlet property="summaryTextField" destination="dd9-b1-XEf" id="ne9-oA-zPw"/>
15087
<outlet property="trackingView" destination="cAS-FG-otl" id="9xY-EB-D5j"/>
151-
<outlet property="tracksTableView" destination="3Uj-1y-jNN" id="zIn-tV-FZG"/>
15288
<outlet property="yearTextField" destination="lyR-U9-HKd" id="3Ps-CJ-pI5"/>
15389
</connections>
154-
<point key="canvasLocation" x="219" y="217.5"/>
90+
<point key="canvasLocation" x="219" y="217"/>
15591
</customView>
15692
</objects>
15793
<resources>

modules/gui/macosx/UI/VLCLibraryTableCellView.xib

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
<rect key="frame" x="0.0" y="0.0" width="398" height="71"/>
1717
</customView>
1818
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ohB-P0-nCv">
19-
<rect key="frame" x="76" y="27" width="37" height="17"/>
19+
<rect key="frame" x="76" y="27" width="321" height="17"/>
2020
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="ZPw-XO-XD1">
2121
<font key="font" usesAppearanceFont="YES"/>
2222
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
2323
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
2424
</textFieldCell>
2525
</textField>
2626
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xJW-ps-ycn">
27-
<rect key="frame" x="76" y="39" width="37" height="17"/>
27+
<rect key="frame" x="76" y="39" width="321" height="17"/>
2828
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="aCe-ia-0Ww">
2929
<font key="font" usesAppearanceFont="YES"/>
3030
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -39,7 +39,7 @@
3939
</constraints>
4040
</customView>
4141
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TPv-k2-6XS">
42-
<rect key="frame" x="76" y="16" width="37" height="17"/>
42+
<rect key="frame" x="76" y="16" width="321" height="17"/>
4343
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="jZ4-pa-K3T">
4444
<font key="font" usesAppearanceFont="YES"/>
4545
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -71,13 +71,13 @@
7171
<constraint firstItem="TPv-k2-6XS" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="4qb-9H-TVg"/>
7272
<constraint firstItem="Ydb-7n-5Cd" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="3" id="8hv-Qt-uAI"/>
7373
<constraint firstItem="9U4-xB-uBz" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="BrT-ZR-zAc"/>
74-
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="3" id="DYW-KQ-pre"/>
74+
<constraint firstAttribute="trailing" secondItem="xJW-ps-ycn" secondAttribute="trailing" constant="3" id="DYW-KQ-pre"/>
7575
<constraint firstItem="xJW-ps-ycn" firstAttribute="leading" secondItem="ohB-P0-nCv" secondAttribute="leading" id="DYk-9g-adD"/>
7676
<constraint firstItem="ffE-px-l0g" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="EMs-It-nUH"/>
7777
<constraint firstAttribute="bottom" secondItem="ffE-px-l0g" secondAttribute="bottom" id="I7D-8N-oA1"/>
7878
<constraint firstItem="ffE-px-l0g" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="M01-2i-CLZ"/>
79-
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="TPv-k2-6XS" secondAttribute="trailing" constant="3" id="PQV-7d-ldF"/>
80-
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ohB-P0-nCv" secondAttribute="trailing" constant="3" id="Sm0-L4-7aP"/>
79+
<constraint firstAttribute="trailing" secondItem="TPv-k2-6XS" secondAttribute="trailing" constant="3" id="PQV-7d-ldF"/>
80+
<constraint firstAttribute="trailing" secondItem="ohB-P0-nCv" secondAttribute="trailing" constant="3" id="Sm0-L4-7aP"/>
8181
<constraint firstAttribute="bottom" secondItem="Ydb-7n-5Cd" secondAttribute="bottom" constant="3" id="aVd-Ld-lUH"/>
8282
<constraint firstItem="TPv-k2-6XS" firstAttribute="top" secondItem="9U4-xB-uBz" secondAttribute="bottom" constant="2" id="bpM-Qh-hOY"/>
8383
<constraint firstItem="NFZ-x0-t5c" firstAttribute="centerY" secondItem="Ydb-7n-5Cd" secondAttribute="centerY" id="dRw-WH-Y00"/>

modules/gui/macosx/library/VLCLibraryAlbumTableCellView.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
3939
@property (readwrite, assign) IBOutlet NSTextField *albumNameTextField;
4040
@property (readwrite, assign) IBOutlet NSTextField *summaryTextField;
4141
@property (readwrite, assign) IBOutlet NSTextField *yearTextField;
42-
@property (readwrite, assign) IBOutlet NSTableView *tracksTableView;
4342
@property (readwrite, assign) IBOutlet NSButton *playInstantlyButton;
4443

4544
@property (readwrite, assign, nonatomic) VLCMediaLibraryAlbum *representedAlbum;

modules/gui/macosx/library/VLCLibraryAlbumTableCellView.m

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
* VLCLibraryAlbumTableself.m: MacOS X interface module
2+
* VLCLibraryAlbumTableCellView.m: MacOS X interface module
33
*****************************************************************************
44
* Copyright (C) 2019 VLC authors and VideoLAN
55
*
@@ -33,6 +33,7 @@
3333
NSString *VLCAudioLibraryCellIdentifier = @"VLCAudioLibraryCellIdentifier";
3434
const CGFloat VLCLibraryTracksRowHeight = 50.;
3535
const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
36+
const CGFloat LayoutSpacer;
3637

3738
@interface VLCLibraryTracksDataSource : NSObject <NSTableViewDataSource, NSTableViewDelegate>
3839

@@ -44,6 +45,7 @@ @interface VLCLibraryAlbumTableCellView ()
4445
{
4546
VLCLibraryController *_libraryController;
4647
VLCLibraryTracksDataSource *_tracksDataSource;
48+
NSTableView *_tracksTableView;
4749
}
4850
@end
4951

@@ -66,6 +68,21 @@ + (CGFloat)heightForAlbum:(VLCMediaLibraryAlbum *)album
6668

6769
- (void)awakeFromNib
6870
{
71+
CGRect frame = self.frame;
72+
NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"theOnlyColumn"];
73+
column.width = frame.size.width - LayoutSpacer * 2.;
74+
_tracksTableView = [[NSTableView alloc] initWithFrame:CGRectMake(LayoutSpacer, 14., frame.size.width - LayoutSpacer * 2., 0.)];
75+
_tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
76+
[_tracksTableView addTableColumn:column];
77+
_tracksTableView.translatesAutoresizingMaskIntoConstraints = NO;
78+
_tracksDataSource = [[VLCLibraryTracksDataSource alloc] init];
79+
_tracksTableView.dataSource = _tracksDataSource;
80+
_tracksTableView.delegate = _tracksDataSource;
81+
[self addSubview:_tracksTableView];
82+
NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksTableView, _representedImageView);
83+
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-20-[_tracksTableView]-20-|" options:0 metrics:0 views:dict]];
84+
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-20-[_representedImageView]-14-[_tracksTableView]-14-|" options:0 metrics:0 views:dict]];
85+
6986
self.albumNameTextField.font = [NSFont VLClibraryLargeCellTitleFont];
7087
self.yearTextField.font = [NSFont VLClibraryLargeCellTitleFont];
7188
self.summaryTextField.font = [NSFont VLClibraryLargeCellSubtitleFont];
@@ -118,11 +135,8 @@ - (void)setRepresentedAlbum:(VLCMediaLibraryAlbum *)representedAlbum
118135
}
119136
self.representedImageView.image = image;
120137

121-
self.tracksTableView.rowHeight = VLCLibraryTracksRowHeight;
122-
_tracksDataSource = [[VLCLibraryTracksDataSource alloc] init];
123138
_tracksDataSource.representedAlbum = _representedAlbum;
124-
self.tracksTableView.dataSource = _tracksDataSource;
125-
self.tracksTableView.delegate = _tracksDataSource;
139+
[_tracksTableView reloadData];
126140
}
127141

128142
@end

0 commit comments

Comments
 (0)