1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Split title and artist into their own columns

This commit is contained in:
Daniel Barber 2019-02-03 18:39:33 -05:00
parent 27449cbb21
commit b56e2a0a53
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 76 additions and 45 deletions

View File

@ -736,7 +736,7 @@
<objects>
<splitViewController id="fnD-7K-pHK" sceneMemberID="viewController">
<splitViewItems>
<splitViewItem canCollapse="YES" holdingPriority="260" behavior="sidebar" id="CWo-v7-gd2"/>
<splitViewItem holdingPriority="260" behavior="sidebar" id="CWo-v7-gd2"/>
<splitViewItem id="y8g-4F-czS"/>
</splitViewItems>
<splitView key="splitView" dividerStyle="thin" vertical="YES" id="g34-ef-XN0">
@ -777,7 +777,7 @@
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="447" minWidth="16" maxWidth="1000" id="0Co-uF-CCB">
<tableColumn identifier="songTitleColumn" width="222" minWidth="128" maxWidth="1000" id="0Co-uF-CCB">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -788,43 +788,21 @@
<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"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
<prototypeCellViews>
<tableCellView identifier="queueHeaderCell" id="GOd-cg-juD">
<rect key="frame" x="1" y="1" width="447" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xgd-Cz-np3">
<rect key="frame" x="0.0" y="1" width="447" height="14"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="QUEUE" id="Mqf-uh-ibl">
<font key="font" metaFont="smallSystemBold"/>
<color key="textColor" name="headerColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="xgd-Cz-np3" firstAttribute="centerX" secondItem="GOd-cg-juD" secondAttribute="centerX" id="4dM-W2-waV"/>
<constraint firstItem="xgd-Cz-np3" firstAttribute="centerY" secondItem="GOd-cg-juD" secondAttribute="centerY" id="fPI-6q-Pe7"/>
<constraint firstItem="xgd-Cz-np3" firstAttribute="leading" secondItem="GOd-cg-juD" secondAttribute="leading" constant="2" id="pYr-es-UVy"/>
</constraints>
<connections>
<outlet property="textField" destination="xgd-Cz-np3" id="5jx-ag-Xoc"/>
</connections>
</tableCellView>
<tableCellView identifier="songItemCell" id="5rR-Gz-AcP">
<rect key="frame" x="1" y="20" width="447" height="17"/>
<tableCellView identifier="songTitleCell" id="5rR-Gz-AcP">
<rect key="frame" x="1" y="1" width="222" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="o8i-cz-hIP">
<rect key="frame" x="3" y="0.0" width="17" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="17" id="A6O-zM-Pm6"/>
<constraint firstAttribute="width" constant="17" id="UFf-Fg-9Qg"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" imageScaling="proportionallyDown" image="NSActionTemplate" id="ckK-gW-Vhx"/>
</imageView>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i0h-bn-auJ">
<rect key="frame" x="25" y="0.0" width="422" height="17"/>
<rect key="frame" x="25" y="0.0" width="197" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="ei8-1e-ErK">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -833,12 +811,12 @@
</textField>
</subviews>
<constraints>
<constraint firstItem="i0h-bn-auJ" firstAttribute="leading" secondItem="o8i-cz-hIP" secondAttribute="trailing" constant="7" id="45Q-xe-DuE"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="centerY" secondItem="5rR-Gz-AcP" secondAttribute="centerY" id="7Yp-6t-YQL"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="bottom" secondItem="i0h-bn-auJ" secondAttribute="bottom" id="Bvi-9s-G9a"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="leading" secondItem="5rR-Gz-AcP" secondAttribute="leading" constant="3" id="HAp-O4-OTM"/>
<constraint firstAttribute="trailing" secondItem="i0h-bn-auJ" secondAttribute="trailing" constant="2" id="hkb-Nh-Mlv"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="top" secondItem="i0h-bn-auJ" secondAttribute="top" id="mit-hq-r61"/>
<constraint firstAttribute="trailing" secondItem="i0h-bn-auJ" secondAttribute="trailing" constant="2" id="0bp-mw-2mz"/>
<constraint firstItem="i0h-bn-auJ" firstAttribute="leading" secondItem="o8i-cz-hIP" secondAttribute="trailing" constant="7" id="GUh-cd-QQx"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="centerY" secondItem="5rR-Gz-AcP" secondAttribute="centerY" id="QT8-Zj-AGK"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="leading" secondItem="5rR-Gz-AcP" secondAttribute="leading" constant="3" id="VCd-sT-dmS"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="bottom" secondItem="i0h-bn-auJ" secondAttribute="bottom" id="ud8-g2-OYn"/>
<constraint firstItem="o8i-cz-hIP" firstAttribute="top" secondItem="i0h-bn-auJ" secondAttribute="top" id="yN0-Pp-adE"/>
</constraints>
<connections>
<outlet property="imageView" destination="o8i-cz-hIP" id="4In-Lr-QcL"/>
@ -847,6 +825,43 @@
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="songArtistColumn" width="222" minWidth="128" maxWidth="1000" id="SPM-QP-DX8">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/>
<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="alT-Kq-P4B">
<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"/>
<prototypeCellViews>
<tableCellView identifier="songArtistCell" id="JSk-Vc-Y7e">
<rect key="frame" x="226" y="1" width="222" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="tBe-Q9-3Rw">
<rect key="frame" x="0.0" y="0.0" width="222" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="Ceb-ec-ydU">
<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>
<constraints>
<constraint firstItem="tBe-Q9-3Rw" firstAttribute="leading" secondItem="JSk-Vc-Y7e" secondAttribute="leading" constant="2" id="BOs-0C-qCf"/>
<constraint firstItem="tBe-Q9-3Rw" firstAttribute="centerX" secondItem="JSk-Vc-Y7e" secondAttribute="centerX" id="MUL-DZ-5vL"/>
<constraint firstItem="tBe-Q9-3Rw" firstAttribute="centerY" secondItem="JSk-Vc-Y7e" secondAttribute="centerY" id="V5l-bF-vkW"/>
</constraints>
<connections>
<outlet property="textField" destination="tBe-Q9-3Rw" id="2e6-zi-tKj"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="KIP-rq-4dM" id="pQO-Qh-B3D"/>
@ -867,10 +882,10 @@
</scrollView>
</subviews>
<constraints>
<constraint firstItem="S3o-nF-NN7" firstAttribute="top" secondItem="2su-YT-hba" secondAttribute="top" id="LU5-98-ybV"/>
<constraint firstItem="S3o-nF-NN7" firstAttribute="leading" secondItem="2su-YT-hba" secondAttribute="leading" id="Pju-f0-dJ1"/>
<constraint firstAttribute="trailing" secondItem="S3o-nF-NN7" secondAttribute="trailing" id="eEr-RJ-jkj"/>
<constraint firstAttribute="bottom" secondItem="S3o-nF-NN7" secondAttribute="bottom" id="hJz-ZT-b1Q"/>
<constraint firstItem="S3o-nF-NN7" firstAttribute="leading" secondItem="2su-YT-hba" secondAttribute="leading" id="B7i-Su-Rgr"/>
<constraint firstItem="S3o-nF-NN7" firstAttribute="top" secondItem="2su-YT-hba" secondAttribute="top" id="EZN-ac-0xk"/>
<constraint firstAttribute="bottom" secondItem="S3o-nF-NN7" secondAttribute="bottom" id="OTS-yj-4am"/>
<constraint firstAttribute="trailing" secondItem="S3o-nF-NN7" secondAttribute="trailing" id="Yis-ZS-y2w"/>
</constraints>
</view>
<connections>

View File

@ -15,6 +15,8 @@ class QueueController: NSViewController, NSOutlineViewDataSource, NSOutlineViewD
override func viewDidLoad() {
super.viewDidLoad()
queueView.columnAutoresizingStyle = .uniformColumnAutoresizingStyle
NotificationCenter.default.addObserver(
self,
selector: #selector(queueChanged(_:)),
@ -47,14 +49,28 @@ class QueueController: NSViewController, NSOutlineViewDataSource, NSOutlineViewD
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
guard let song = item as? MPDClient.Song else { return nil }
let tableView = outlineView.makeView(
withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "songItemCell"),
owner: self
) as! NSTableCellView
switch tableColumn?.identifier.rawValue {
case "songTitleColumn":
let cellView = outlineView.makeView(
withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "songTitleCell"),
owner: self
) as! NSTableCellView
tableView.textField?.stringValue = "\(song.getTag(MPD_TAG_TITLE)) - \(song.getTag(MPD_TAG_ARTIST))"
cellView.textField?.stringValue = song.getTag(MPD_TAG_TITLE)
return tableView
return cellView
case "songArtistColumn":
let cellView = outlineView.makeView(
withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "songArtistCell"),
owner: self
) as! NSTableCellView
cellView.textField?.stringValue = song.getTag(MPD_TAG_ARTIST)
return cellView
default:
return nil
}
}
@IBOutlet var queueView: NSOutlineView!