mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
No commits in common. "0e6b34513a20c523ac62351ca51638c307c4542d" and "9bedbec407ef7ede155a3bb9f716d9b354e6f548" have entirely different histories.
0e6b34513a
...
9bedbec407
@ -18,7 +18,6 @@
|
||||
E408D3C2220E134F0006D9BE /* AlbumViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E408D3C1220E134F0006D9BE /* AlbumViewController.swift */; };
|
||||
E408D3CA220E341D0006D9BE /* AlbumItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E408D3C8220E341D0006D9BE /* AlbumItem.swift */; };
|
||||
E408D3CB220E341D0006D9BE /* AlbumItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = E408D3C9220E341D0006D9BE /* AlbumItem.xib */; };
|
||||
E40FE7132219AD7A00A4223F /* AlbumItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E40FE7122219AD7A00A4223F /* AlbumItemView.swift */; };
|
||||
E41B22C021FB6BBA00D544F6 /* libmpdclient.2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */; settings = {ATTRIBUTES = (Required, ); }; };
|
||||
E41B22C121FB6C3300D544F6 /* libmpdclient.2.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
E41B22C621FB932700D544F6 /* MPDClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = E41B22C521FB932700D544F6 /* MPDClient.swift */; };
|
||||
@ -83,7 +82,6 @@
|
||||
E408D3C1220E134F0006D9BE /* AlbumViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumViewController.swift; sourceTree = "<group>"; };
|
||||
E408D3C8220E341D0006D9BE /* AlbumItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumItem.swift; sourceTree = "<group>"; };
|
||||
E408D3C9220E341D0006D9BE /* AlbumItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AlbumItem.xib; sourceTree = "<group>"; };
|
||||
E40FE7122219AD7A00A4223F /* AlbumItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumItemView.swift; sourceTree = "<group>"; };
|
||||
E41B22BF21FB6BBA00D544F6 /* libmpdclient.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libmpdclient.2.dylib; path = libmpdclient/output/libmpdclient.2.dylib; sourceTree = "<group>"; };
|
||||
E41B22C421FB715A00D544F6 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
|
||||
E41B22C521FB932700D544F6 /* MPDClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPDClient.swift; sourceTree = "<group>"; };
|
||||
@ -236,7 +234,7 @@
|
||||
E408D3C3220E138B0006D9BE /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E40FE7122219AD7A00A4223F /* AlbumItemView.swift */,
|
||||
E408D3C8220E341D0006D9BE /* AlbumItem.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -333,7 +331,6 @@
|
||||
E4D1B597220BA3A20026F233 /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E408D3C8220E341D0006D9BE /* AlbumItem.swift */,
|
||||
E408D3C1220E134F0006D9BE /* AlbumViewController.swift */,
|
||||
E4E8CC932206097F0024217A /* NotificationsController.swift */,
|
||||
E4E8CC912204F4B80024217A /* QueueViewController.swift */,
|
||||
@ -501,7 +498,6 @@
|
||||
E465049A21E94DF500A70F4C /* WindowController.swift in Sources */,
|
||||
E41B22C621FB932700D544F6 /* MPDClient.swift in Sources */,
|
||||
E407861C2110CE6E006887B1 /* AppDelegate.swift in Sources */,
|
||||
E40FE7132219AD7A00A4223F /* AlbumItemView.swift in Sources */,
|
||||
E4E8CC9A22075D370024217A /* Song.swift in Sources */,
|
||||
E408D3CA220E341D0006D9BE /* AlbumItem.swift in Sources */,
|
||||
E4E8CC902204EC7F0024217A /* Delegate.swift in Sources */,
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "playButtonLarge.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "playButtonLarge@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 295 B |
Binary file not shown.
|
Before Width: | Height: | Size: 516 B |
@ -9,13 +9,7 @@
|
||||
import Cocoa
|
||||
|
||||
class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineViewDelegate {
|
||||
struct SongItem {
|
||||
var song: MPDClient.Song
|
||||
var queuePos: Int
|
||||
var isPlaying: Bool
|
||||
}
|
||||
|
||||
var queue: [SongItem] = []
|
||||
var queue: [MPDClient.Song] = []
|
||||
var queuePos: Int = -1
|
||||
|
||||
var queueIcon: NSImage? = nil
|
||||
@ -26,6 +20,11 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
let playIcon = NSImage(named: "playButton")
|
||||
let pauseIcon = NSImage(named: "pauseButton")
|
||||
|
||||
struct SongItem {
|
||||
var song: MPDClient.Song
|
||||
var queuePos: Int
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@ -75,14 +74,8 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
guard let queue = notification.userInfo?[Notification.queueKey] as? [MPDClient.Song]
|
||||
else { return }
|
||||
|
||||
var newQueue: [SongItem] = []
|
||||
self.queue = queue
|
||||
|
||||
for (index, mpdSong) in queue.enumerated() {
|
||||
let songItem = SongItem(song: mpdSong, queuePos: index, isPlaying: index == queuePos)
|
||||
newQueue.append(songItem)
|
||||
}
|
||||
|
||||
self.queue = newQueue
|
||||
queueView.reloadData()
|
||||
}
|
||||
|
||||
@ -90,13 +83,16 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
guard let queuePos = notification.userInfo?[Notification.queuePosKey] as? Int
|
||||
else { return }
|
||||
|
||||
let oldSongRowPos = self.queuePos
|
||||
let newSongRowPos = queuePos
|
||||
let oldSongRowPos = self.queuePos + 1
|
||||
let newSongRowPos = queuePos + 1
|
||||
self.queuePos = queuePos
|
||||
|
||||
setQueuePos(oldSongRowPos: oldSongRowPos, newSongRowPos: newSongRowPos)
|
||||
|
||||
queueView.reloadData()
|
||||
queueView.reloadData(
|
||||
forRowIndexes: [oldSongRowPos, newSongRowPos],
|
||||
columnIndexes: [0, 1]
|
||||
)
|
||||
}
|
||||
|
||||
func setQueueIcon(_ state: MPDClient.Status.State) {
|
||||
@ -111,11 +107,30 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
}
|
||||
|
||||
func setQueuePos(oldSongRowPos: Int, newSongRowPos: Int) {
|
||||
if oldSongRowPos >= 0 {
|
||||
queue[oldSongRowPos].isPlaying = false
|
||||
if oldSongRowPos > 0 {
|
||||
guard let oldSongRow = queueView.rowView(atRow: oldSongRowPos, makeIfNecessary: true),
|
||||
let oldSongTitleCell = oldSongRow.view(atColumn: 0) as? NSTableCellView
|
||||
else { return }
|
||||
|
||||
setRowFont(rowView: oldSongRow, font: systemFontRegular)
|
||||
oldSongTitleCell.imageView?.image = nil
|
||||
}
|
||||
|
||||
queue[newSongRowPos].isPlaying = true
|
||||
guard let songRow = queueView.rowView(atRow: newSongRowPos, makeIfNecessary: true),
|
||||
let newSongTitleCell = songRow.view(atColumn: 0) as? NSTableCellView
|
||||
else { return }
|
||||
|
||||
setRowFont(rowView: songRow, font: systemFontBold)
|
||||
newSongTitleCell.imageView?.image = self.queueIcon
|
||||
}
|
||||
|
||||
func setRowFont(rowView: NSTableRowView, font: NSFont) {
|
||||
guard let songTitleCell = rowView.view(atColumn: 0) as? NSTableCellView,
|
||||
let songArtistCell = rowView.view(atColumn: 1) as? NSTableCellView
|
||||
else { return }
|
||||
|
||||
songTitleCell.textField?.font = font
|
||||
songArtistCell.textField?.font = font
|
||||
}
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
||||
@ -128,7 +143,7 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
||||
if index > 0 {
|
||||
return queue[index - 1]
|
||||
return SongItem(song: queue[index - 1], queuePos: index - 1)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
@ -144,13 +159,6 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
) as! NSTableCellView
|
||||
|
||||
cellView.textField?.stringValue = songItem.song.getTag(.title)
|
||||
if songItem.isPlaying {
|
||||
cellView.textField?.font = systemFontBold
|
||||
cellView.imageView?.image = self.queueIcon
|
||||
} else {
|
||||
cellView.textField?.font = systemFontRegular
|
||||
cellView.imageView?.image = nil
|
||||
}
|
||||
|
||||
return cellView
|
||||
case "songArtistColumn":
|
||||
@ -160,11 +168,6 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
|
||||
) as! NSTableCellView
|
||||
|
||||
cellView.textField?.stringValue = songItem.song.getTag(.artist)
|
||||
if songItem.isPlaying {
|
||||
cellView.textField?.font = systemFontBold
|
||||
} else {
|
||||
cellView.textField?.font = systemFontRegular
|
||||
}
|
||||
|
||||
return cellView
|
||||
default:
|
||||
|
||||
@ -109,27 +109,6 @@ class MPDClient {
|
||||
idle()
|
||||
}
|
||||
|
||||
func playAlbum(_ album: Album) {
|
||||
noIdle()
|
||||
commandQueue.async { [unowned self] in
|
||||
var songs: [Song] = []
|
||||
|
||||
mpd_run_clear(self.connection)
|
||||
mpd_search_db_songs(self.connection, true)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album.title)
|
||||
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM_ARTIST, album.artist)
|
||||
mpd_search_commit(self.connection)
|
||||
while let mpdSong = mpd_recv_song(self.connection) {
|
||||
songs.append(Song(mpdSong))
|
||||
}
|
||||
for song in songs {
|
||||
mpd_run_add(self.connection, song.uri)
|
||||
}
|
||||
mpd_run_play_pos(self.connection, 0)
|
||||
}
|
||||
idle()
|
||||
}
|
||||
|
||||
func queueCommand(command: Command) {
|
||||
noIdle()
|
||||
commandQueue.async { [unowned self] in
|
||||
|
||||
@ -41,10 +41,6 @@ extension MPDClient {
|
||||
mpd_song_free(mpdSong)
|
||||
}
|
||||
|
||||
var uri: UnsafePointer<Int8> {
|
||||
return mpd_song_get_uri(mpdSong)
|
||||
}
|
||||
|
||||
func getTag(_ tagType: TagType) -> String {
|
||||
let mpdTagType = mpd_tag_type(rawValue: Int32(tagType.rawValue))
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="albumArtist" destination="5Uu-j1-qyT" id="2Et-tX-InT"/>
|
||||
<outlet property="albumCoverView" destination="Kfb-8f-ean" id="CXx-gB-gz8"/>
|
||||
<outlet property="albumCoverView" destination="Kfb-8f-ean" id="ZAL-jD-lHj"/>
|
||||
<outlet property="albumTitle" destination="KEh-NL-c2W" id="SI3-hm-H2B"/>
|
||||
<outlet property="imageView" destination="Kfb-8f-ean" id="Ur0-hX-wJm"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="v7W-XA-Emc"/>
|
||||
@ -17,7 +17,7 @@
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY" customClass="AlbumItemView" customModule="Persephone" customModuleProvider="target">
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="128" height="167"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
@ -41,45 +41,24 @@
|
||||
<rect key="frame" x="0.0" y="39" width="128" height="128"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="blankAlbum" id="FsA-JX-BFh"/>
|
||||
</imageView>
|
||||
<button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="n8W-do-HyG">
|
||||
<rect key="frame" x="43" y="81" width="42" height="43"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="42" id="XXC-YE-Ego"/>
|
||||
<constraint firstAttribute="width" constant="42" id="zcR-GT-zym"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="inline" bezelStyle="inline" image="playButtonLarge" imagePosition="only" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="T1p-LZ-RpJ">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="playAlbum:" target="-2" id="gNt-Rn-kte"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="5Uu-j1-qyT" firstAttribute="trailing" secondItem="KEh-NL-c2W" secondAttribute="trailing" id="64z-uz-4nY"/>
|
||||
<constraint firstAttribute="bottom" secondItem="KEh-NL-c2W" secondAttribute="bottom" constant="18" id="8Kg-1r-wNp"/>
|
||||
<constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="JMi-4i-dgs"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="KQC-Wz-Bsg"/>
|
||||
<constraint firstItem="n8W-do-HyG" firstAttribute="centerX" secondItem="KEh-NL-c2W" secondAttribute="centerX" id="Kf1-ws-d4q"/>
|
||||
<constraint firstItem="5Uu-j1-qyT" firstAttribute="leading" secondItem="KEh-NL-c2W" secondAttribute="leading" id="MUo-0i-fX9"/>
|
||||
<constraint firstItem="Kfb-8f-ean" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Qbk-jx-zAi"/>
|
||||
<constraint firstItem="KEh-NL-c2W" firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="U0w-G4-ggX"/>
|
||||
<constraint firstItem="KEh-NL-c2W" firstAttribute="leading" secondItem="Kfb-8f-ean" secondAttribute="leading" id="V8r-Rc-Dx7"/>
|
||||
<constraint firstAttribute="bottom" secondItem="5Uu-j1-qyT" secondAttribute="bottom" id="gci-4h-pDZ"/>
|
||||
<constraint firstItem="n8W-do-HyG" firstAttribute="centerY" secondItem="Kfb-8f-ean" secondAttribute="centerY" id="pgP-oA-Nxa"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Kfb-8f-ean" secondAttribute="bottom" constant="39" id="sid-zJ-YMA"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="imageView" destination="Kfb-8f-ean" id="T7Z-En-dU3"/>
|
||||
<outlet property="playButton" destination="n8W-do-HyG" id="Xw0-iI-svx"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-22" y="125.5"/>
|
||||
</customView>
|
||||
<collectionViewItem id="Qgu-aI-55A" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"/>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="blankAlbum" width="128" height="128"/>
|
||||
<image name="playButtonLarge" width="22" height="22"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@ -10,7 +10,6 @@ import Cocoa
|
||||
|
||||
class AlbumItem: NSCollectionViewItem {
|
||||
var observer: NSKeyValueObservation?
|
||||
var album: MPDClient.Album?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@ -28,7 +27,6 @@ class AlbumItem: NSCollectionViewItem {
|
||||
}
|
||||
|
||||
func setAlbum(_ album: MPDClient.Album) {
|
||||
self.album = album
|
||||
albumTitle.stringValue = album.title
|
||||
albumArtist.stringValue = album.artist
|
||||
}
|
||||
@ -44,12 +42,6 @@ class AlbumItem: NSCollectionViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func playAlbum(_ sender: Any) {
|
||||
guard let album = album else { return }
|
||||
|
||||
AppDelegate.mpdClient.playAlbum(album)
|
||||
}
|
||||
|
||||
@IBOutlet var albumCoverView: NSImageView!
|
||||
@IBOutlet var albumTitle: NSTextField!
|
||||
@IBOutlet var albumArtist: NSTextField!
|
||||
@ -1,48 +0,0 @@
|
||||
//
|
||||
// AlbumItemView.swift
|
||||
// Persephone
|
||||
//
|
||||
// Created by Daniel Barber on 2019/2/17.
|
||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AlbumItemView: NSView {
|
||||
var trackingArea: NSTrackingArea?
|
||||
|
||||
override func updateTrackingAreas() {
|
||||
super.updateTrackingAreas()
|
||||
|
||||
guard let albumImageView = imageView else { return }
|
||||
|
||||
if let trackingArea = self.trackingArea {
|
||||
self.removeTrackingArea(trackingArea)
|
||||
}
|
||||
|
||||
let trackingArea = NSTrackingArea(
|
||||
rect: albumImageView.frame,
|
||||
options: [.mouseEnteredAndExited, .activeAlways],
|
||||
owner: self,
|
||||
userInfo: nil
|
||||
)
|
||||
|
||||
self.trackingArea = trackingArea
|
||||
addTrackingArea(trackingArea)
|
||||
}
|
||||
|
||||
override func resize(withOldSuperviewSize oldSize: NSSize) {
|
||||
playButton.isHidden = true
|
||||
}
|
||||
|
||||
override func mouseEntered(with event: NSEvent) {
|
||||
playButton.isHidden = false
|
||||
}
|
||||
|
||||
override func mouseExited(with event: NSEvent) {
|
||||
playButton.isHidden = true
|
||||
}
|
||||
|
||||
@IBOutlet var imageView: NSImageView!
|
||||
@IBOutlet var playButton: NSButton!
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 295 B |
Binary file not shown.
|
Before Width: | Height: | Size: 516 B |
Binary file not shown.
Loading…
Reference in New Issue
Block a user