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

Drag and drop works with detail view

This commit is contained in:
Daniel Barber 2019-06-29 12:27:40 -04:00
parent 52718cfcd6
commit 23a1a2e8cf
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
5 changed files with 65 additions and 12 deletions

View File

@ -43,6 +43,7 @@
E43AC1F122C68E6A001E483C /* NSPasteboardItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43AC1F022C68E6A001E483C /* NSPasteboardItem.swift */; };
E43AC1F522C6A4F4001E483C /* DraggedAlbum.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43AC1F422C6A4F4001E483C /* DraggedAlbum.swift */; };
E43AC1F622C6AD0B001E483C /* AlbumViewController+NSCollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43AC1F222C6A439001E483C /* AlbumViewController+NSCollectionViewDelegate.swift */; };
E43AC1F822C7065A001E483C /* AlbumCoverButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43AC1F722C7065A001E483C /* AlbumCoverButton.swift */; };
E43B67AA22909793007DCF55 /* AlbumDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43B67A822909793007DCF55 /* AlbumDetailView.swift */; };
E43B67AB22909793007DCF55 /* AlbumDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E43B67A922909793007DCF55 /* AlbumDetailView.xib */; };
E43B67AD229194CD007DCF55 /* AlbumTracksDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = E43B67AC229194CD007DCF55 /* AlbumTracksDataSource.swift */; };
@ -240,6 +241,7 @@
E43AC1F022C68E6A001E483C /* NSPasteboardItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPasteboardItem.swift; sourceTree = "<group>"; };
E43AC1F222C6A439001E483C /* AlbumViewController+NSCollectionViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AlbumViewController+NSCollectionViewDelegate.swift"; sourceTree = "<group>"; };
E43AC1F422C6A4F4001E483C /* DraggedAlbum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraggedAlbum.swift; sourceTree = "<group>"; };
E43AC1F722C7065A001E483C /* AlbumCoverButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumCoverButton.swift; sourceTree = "<group>"; };
E43B67A822909793007DCF55 /* AlbumDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumDetailView.swift; sourceTree = "<group>"; };
E43B67A922909793007DCF55 /* AlbumDetailView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlbumDetailView.xib; sourceTree = "<group>"; };
E43B67AC229194CD007DCF55 /* AlbumTracksDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumTracksDataSource.swift; sourceTree = "<group>"; };
@ -454,6 +456,7 @@
E47E2FD222205D2500F747E6 /* MainWindow.swift */,
E423563F228623D2001216D6 /* QueueSongTitleView.swift */,
E4120D6B22AD8139004CB1F8 /* QueueView.swift */,
E43AC1F722C7065A001E483C /* AlbumCoverButton.swift */,
);
path = Views;
sourceTree = "<group>";
@ -920,6 +923,7 @@
E41E52FD223BF87300173814 /* MPDClient+Connection.swift in Sources */,
E450AD7E222620A10091BED3 /* Album.swift in Sources */,
E408D3B6220DD8970006D9BE /* Notification.swift in Sources */,
E43AC1F822C7065A001E483C /* AlbumCoverButton.swift in Sources */,
E45962C62241A78500FC1A1E /* MPDCommand.swift in Sources */,
E408D3B9220DE98F0006D9BE /* NSUserInterfaceItemIdentifier.swift in Sources */,
E4EB2379220F10B8008C70C0 /* MPDPair.swift in Sources */,

View File

@ -14,7 +14,7 @@ class AlbumViewItem: NSCollectionViewItem {
override var isSelected: Bool {
didSet {
//albumCoverBox.isHidden = !isSelected
albumCoverBox.layer?.borderWidth = isSelected ? 5 : 0
}
}
@ -24,16 +24,12 @@ class AlbumViewItem: NSCollectionViewItem {
albumCoverView.wantsLayer = true
albumCoverView.layer?.cornerRadius = 3
albumCoverView.layer?.borderWidth = 1
setAppearance()
// albumCoverBox.wantsLayer = true
// albumCoverBox.layer?.cornerRadius = 5
// albumCoverBox.layer?.borderWidth = 8
// if #available(OSX 10.14, *) {
// albumCoverBox.layer?.borderColor = NSColor.controlAccentColor.cgColor
// } else {
// albumCoverBox.layer?.borderColor = NSColor.selectedControlColor.cgColor
// }
albumCoverBox.wantsLayer = true
albumCoverBox.layer?.cornerRadius = 5
albumCoverBox.layer?.borderWidth = 0
setAppearance()
if #available(OSX 10.14, *) {
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
@ -67,8 +63,10 @@ class AlbumViewItem: NSCollectionViewItem {
[.darkAqua, .aqua]) == .darkAqua
albumCoverView.layer?.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
albumCoverBox.layer?.borderColor = NSColor.controlAccentColor.cgColor
} else {
albumCoverView.layer?.borderColor = .albumBorderColorLight
albumCoverBox.layer?.borderColor = NSColor.selectedControlColor.cgColor
}
}

View File

@ -0,0 +1,19 @@
//
// DraggedAlbum.swift
// Persephone
//
// Created by Daniel Barber on 2019/6/28.
// Copyright © 2019 Dan Barber. All rights reserved.
//
import AppKit
import CryptoSwift
struct DraggedAlbum: Codable {
var title: String
var artist: String
var hash: String {
return "\(title) - \(artist)".sha1()
}
}

View File

@ -27,13 +27,13 @@
<rect key="frame" x="0.0" y="0.0" width="148" height="138"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="juD-33-Glf">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="juD-33-Glf" customClass="AlbumCoverButton" customModule="Persephone" customModuleProvider="target">
<rect key="frame" x="5" y="5" width="138" height="128"/>
<shadow key="shadow" blurRadius="4">
<size key="offset" width="0.0" height="2"/>
<color key="color" white="0.0" alpha="0.34603323063380281" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</shadow>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="defaultCoverArt" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" transparent="YES" imageScaling="proportionallyUpOrDown" inset="2" id="t8A-Hz-L38">
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="defaultCoverArt" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" refusesFirstResponder="YES" state="on" transparent="YES" imageScaling="proportionallyUpOrDown" inset="2" id="t8A-Hz-L38">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>

View File

@ -0,0 +1,32 @@
//
// AlbumCoverButton.swift
// Persephone
//
// Created by Daniel Barber on 2019/6/28.
// Copyright © 2019 Dan Barber. All rights reserved.
//
import AppKit
class AlbumCoverButton: NSButton {
var dragging = false
override func mouseDown(with event: NSEvent) {
nextResponder?.mouseDown(with: event)
}
override func mouseDragged(with event: NSEvent) {
dragging = true
nextResponder?.mouseDragged(with: event)
}
override func mouseUp(with event: NSEvent) {
if dragging {
dragging = false
nextResponder?.mouseUp(with: event)
} else {
super.mouseDown(with: event)
super.mouseUp(with: event)
}
}
}