mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Dragging song view resizes to fit contents
This commit is contained in:
parent
f687e89f9d
commit
fa0816ce7c
25
Persephone/Assets.xcassets/songIcon.imageset/Contents.json
vendored
Normal file
25
Persephone/Assets.xcassets/songIcon.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "songIcon.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "songIcon@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "template"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Persephone/Assets.xcassets/songIcon.imageset/songIcon.png
vendored
Normal file
BIN
Persephone/Assets.xcassets/songIcon.imageset/songIcon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 309 B |
BIN
Persephone/Assets.xcassets/songIcon.imageset/songIcon@2x.png
vendored
Normal file
BIN
Persephone/Assets.xcassets/songIcon.imageset/songIcon@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 547 B |
@ -104,8 +104,6 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
App.store.dispatch(MPDAddSongToQueue(songUri: uri, queuePos: newQueuePos))
|
App.store.dispatch(MPDAddSongToQueue(songUri: uri, queuePos: newQueuePos))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forItems draggedItems: [Any]) {
|
func outlineView(_ outlineView: NSOutlineView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forItems draggedItems: [Any]) {
|
||||||
@ -125,8 +123,10 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
let component = NSDraggingImageComponent(key: NSDraggingItem.ImageComponentKey.icon)
|
let component = NSDraggingImageComponent(key: NSDraggingItem.ImageComponentKey.icon)
|
||||||
let draggedSongView = DraggedSongView(title: title, artist: artist)
|
let draggedSongView = DraggedSongView(title: title, artist: artist)
|
||||||
|
|
||||||
component.contents = draggedSongView.view.image()
|
let view = draggedSongView.view
|
||||||
component.frame = NSRect(origin: CGPoint(), size: draggedSongView.view.image().size)
|
let image = view.image()
|
||||||
|
component.contents = image
|
||||||
|
component.frame = NSRect(origin: CGPoint(), size: view.frame.size)
|
||||||
return [component]
|
return [component]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,9 @@ import AppKit
|
|||||||
|
|
||||||
extension NSView {
|
extension NSView {
|
||||||
func image() -> NSImage {
|
func image() -> NSImage {
|
||||||
let imageRepresentation = bitmapImageRepForCachingDisplay(in: bounds)!
|
layoutSubtreeIfNeeded()
|
||||||
cacheDisplay(in: bounds, to: imageRepresentation)
|
let imageRepresentation = bitmapImageRepForCachingDisplay(in: frame)!
|
||||||
return NSImage(cgImage: imageRepresentation.cgImage!, size: bounds.size)
|
cacheDisplay(in: frame, to: imageRepresentation)
|
||||||
|
return NSImage(cgImage: imageRepresentation.cgImage!, size: frame.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,50 +3,90 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||||
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
|
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="DraggedSongView" customModule="Persephone" customModuleProvider="target">
|
<customObject id="-2" userLabel="File's Owner" customClass="DraggedSongView" customModule="Persephone" customModuleProvider="target">
|
||||||
<connections>
|
<connections>
|
||||||
|
<outlet property="artistLabel" destination="egC-YO-gnV" id="g0f-FI-cGF"/>
|
||||||
<outlet property="titleLabel" destination="tsD-ub-h7I" id="EVO-Z7-tZY"/>
|
<outlet property="titleLabel" destination="tsD-ub-h7I" id="EVO-Z7-tZY"/>
|
||||||
<outlet property="view" destination="Hz6-mo-xeY" id="Wf9-hm-E7M"/>
|
<outlet property="view" destination="Hz6-mo-xeY" id="Wf9-hm-E7M"/>
|
||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
<customView id="Hz6-mo-xeY">
|
<customView misplaced="YES" id="Hz6-mo-xeY">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="181" height="27"/>
|
<rect key="frame" x="0.0" y="0.0" width="121" height="22"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<box boxType="custom" borderType="line" cornerRadius="4" translatesAutoresizingMaskIntoConstraints="NO" id="G2x-p5-RM6">
|
<box boxType="custom" borderType="line" cornerRadius="4" translatesAutoresizingMaskIntoConstraints="NO" id="G2x-p5-RM6">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="181" height="27"/>
|
<rect key="frame" x="0.0" y="0.0" width="121" height="22"/>
|
||||||
<view key="contentView" id="qbG-wn-N4h">
|
<view key="contentView" id="qbG-wn-N4h">
|
||||||
<rect key="frame" x="1" y="1" width="179" height="25"/>
|
<rect key="frame" x="1" y="1" width="119" height="20"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tsD-ub-h7I">
|
<stackView distribution="fillProportionally" orientation="horizontal" alignment="centerY" spacing="12" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rlT-HP-okZ">
|
||||||
<rect key="frame" x="11" y="4" width="156" height="17"/>
|
<rect key="frame" x="0.0" y="0.0" width="119" height="20"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<subviews>
|
||||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Title" id="rMn-D0-PG7">
|
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Go5-Lk-qgA">
|
||||||
<font key="font" usesAppearanceFont="YES"/>
|
<rect key="frame" x="8" y="2" width="17" height="17"/>
|
||||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
<constraints>
|
||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<constraint firstAttribute="height" constant="17" id="DKw-m3-Lne"/>
|
||||||
</textFieldCell>
|
<constraint firstAttribute="width" constant="17" id="k19-kI-PmI"/>
|
||||||
</textField>
|
</constraints>
|
||||||
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="songIcon" id="KDX-a9-N4B"/>
|
||||||
|
</imageView>
|
||||||
|
<textField horizontalHuggingPriority="1000" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tsD-ub-h7I">
|
||||||
|
<rect key="frame" x="35" y="2" width="32" height="17"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" title="Title" usesSingleLineMode="YES" id="rMn-D0-PG7">
|
||||||
|
<font key="font" metaFont="systemMedium" size="13"/>
|
||||||
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
<textField horizontalHuggingPriority="1000" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="egC-YO-gnV">
|
||||||
|
<rect key="frame" x="75" y="2" width="38" height="17"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" alignment="left" title="Artist" usesSingleLineMode="YES" id="m15-pn-bdW">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
</subviews>
|
||||||
|
<edgeInsets key="edgeInsets" left="8" right="8" top="1" bottom="1"/>
|
||||||
|
<visibilityPriorities>
|
||||||
|
<real value="1000"/>
|
||||||
|
<integer value="1000"/>
|
||||||
|
<integer value="1000"/>
|
||||||
|
</visibilityPriorities>
|
||||||
|
<customSpacing>
|
||||||
|
<real value="3.4028234663852886e+38"/>
|
||||||
|
<real value="3.4028234663852886e+38"/>
|
||||||
|
<real value="3.4028234663852886e+38"/>
|
||||||
|
</customSpacing>
|
||||||
|
</stackView>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="rlT-HP-okZ" secondAttribute="trailing" id="3dK-4q-G3z"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="rlT-HP-okZ" secondAttribute="bottom" id="6bV-EI-Qk5"/>
|
||||||
|
<constraint firstItem="rlT-HP-okZ" firstAttribute="leading" secondItem="qbG-wn-N4h" secondAttribute="leading" id="d0B-7v-cmT"/>
|
||||||
|
<constraint firstItem="rlT-HP-okZ" firstAttribute="top" secondItem="qbG-wn-N4h" secondAttribute="top" id="mvZ-UP-tHf"/>
|
||||||
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<color key="borderColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
|
<color key="borderColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||||
<color key="fillColor" name="unemphasizedSelectedContentBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<color key="fillColor" red="0.27450980392156865" green="0.27450980392156865" blue="0.27450980392156865" alpha="0.65297645246478875" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
</box>
|
</box>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="G2x-p5-RM6" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="Gcj-M0-oDt"/>
|
<constraint firstItem="G2x-p5-RM6" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="A72-wi-zNE"/>
|
||||||
<constraint firstAttribute="bottom" secondItem="G2x-p5-RM6" secondAttribute="bottom" id="Tmu-AD-yFM"/>
|
<constraint firstItem="G2x-p5-RM6" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="ENp-3t-AXT"/>
|
||||||
<constraint firstItem="G2x-p5-RM6" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="gF3-y6-cc5"/>
|
<constraint firstAttribute="trailing" secondItem="G2x-p5-RM6" secondAttribute="trailing" id="MbJ-MP-4HG"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="G2x-p5-RM6" secondAttribute="trailing" id="rax-yO-zz2"/>
|
<constraint firstAttribute="bottom" secondItem="G2x-p5-RM6" secondAttribute="bottom" id="Nzd-OC-f1V"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<point key="canvasLocation" x="-10.5" y="31.5"/>
|
<point key="canvasLocation" x="50.5" y="14"/>
|
||||||
</customView>
|
</customView>
|
||||||
</objects>
|
</objects>
|
||||||
|
<resources>
|
||||||
|
<image name="songIcon" width="17" height="17"/>
|
||||||
|
</resources>
|
||||||
</document>
|
</document>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Cocoa
|
|||||||
|
|
||||||
class DraggedSongView: NSViewController {
|
class DraggedSongView: NSViewController {
|
||||||
@IBOutlet var titleLabel: NSTextField!
|
@IBOutlet var titleLabel: NSTextField!
|
||||||
|
@IBOutlet var artistLabel: NSTextField!
|
||||||
|
|
||||||
private let songTitle: String
|
private let songTitle: String
|
||||||
private let songArtist: String
|
private let songArtist: String
|
||||||
@ -27,5 +28,6 @@ class DraggedSongView: NSViewController {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
titleLabel.stringValue = songTitle
|
titleLabel.stringValue = songTitle
|
||||||
|
artistLabel.stringValue = songArtist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/export/songIcon.png
Normal file
BIN
Resources/export/songIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 309 B |
BIN
Resources/export/songIcon@2x.png
Normal file
BIN
Resources/export/songIcon@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 547 B |
Binary file not shown.
Loading…
Reference in New Issue
Block a user