diff --git a/Persephone/Controllers/AlbumDetailView.swift b/Persephone/Controllers/AlbumDetailView.swift
index e174c43..f668e18 100644
--- a/Persephone/Controllers/AlbumDetailView.swift
+++ b/Persephone/Controllers/AlbumDetailView.swift
@@ -22,6 +22,8 @@ class AlbumDetailView: NSViewController {
albumTracksView.dataSource = dataSource
albumTracksView.delegate = self
+ albumTracksView.intercellSpacing = CGSize(width: 0, height: 13)
+ albumTracksView.gridStyleMask = .solidHorizontalGridLineMask
albumCoverView.wantsLayer = true
albumCoverView.layer?.cornerRadius = 5
@@ -80,11 +82,19 @@ extension AlbumDetailView: NSTableViewDelegate {
return cellForTrackNumber(tableView, with: song)
case "trackTitleColumn":
return cellForSongTitle(tableView, with: song)
+ case "trackDurationColumn":
+ return cellForSongDuration(tableView, with: song)
default:
return nil
}
}
+ func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
+ let view = NSTableRowView()
+
+ return view
+ }
+
func cellForTrackNumber(_ tableView: NSTableView, with song: Song) -> NSView {
let cellView = tableView.makeView(
withIdentifier: .trackNumber,
@@ -106,4 +116,16 @@ extension AlbumDetailView: NSTableViewDelegate {
return cellView
}
+
+ func cellForSongDuration(_ tableView: NSTableView, with song: Song) -> NSView {
+ let cellView = tableView.makeView(
+ withIdentifier: .songDuration,
+ owner: self
+ ) as! NSTableCellView
+
+ cellView.textField?.font = .timerFont
+ cellView.textField?.stringValue = song.duration.formattedTime
+
+ return cellView
+ }
}
diff --git a/Persephone/Controllers/AlbumViewItem.swift b/Persephone/Controllers/AlbumViewItem.swift
index bb3af6e..4b47c67 100644
--- a/Persephone/Controllers/AlbumViewItem.swift
+++ b/Persephone/Controllers/AlbumViewItem.swift
@@ -11,6 +11,7 @@ import AppKit
class AlbumViewItem: NSCollectionViewItem {
var observer: NSKeyValueObservation?
var album: Album?
+ var detailPopover: NSPopover?
override func viewDidLoad() {
super.viewDidLoad()
@@ -27,6 +28,12 @@ class AlbumViewItem: NSCollectionViewItem {
}
}
+ override func prepareForReuse() {
+ super.prepareForReuse()
+
+ detailPopover?.close()
+ }
+
func setAlbum(_ album: Album) {
self.album = album
albumTitle.stringValue = album.title
@@ -63,10 +70,10 @@ class AlbumViewItem: NSCollectionViewItem {
detailViewController.setAlbum(album)
- let popoverView = NSPopover()
- popoverView.contentViewController = detailViewController
- popoverView.behavior = .transient
- popoverView.show(
+ detailPopover = NSPopover()
+ detailPopover?.contentViewController = detailViewController
+ detailPopover?.behavior = .transient
+ detailPopover?.show(
relativeTo: sender.bounds,
of: sender,
preferredEdge: .maxY
diff --git a/Persephone/Extensions/NSUserInterfaceItemIdentifier.swift b/Persephone/Extensions/NSUserInterfaceItemIdentifier.swift
index 47251d1..aba4675 100644
--- a/Persephone/Extensions/NSUserInterfaceItemIdentifier.swift
+++ b/Persephone/Extensions/NSUserInterfaceItemIdentifier.swift
@@ -20,5 +20,5 @@ extension NSUserInterfaceItemIdentifier {
static let trackNumber = NSUserInterfaceItemIdentifier("trackNumberCell")
static let songTitle = NSUserInterfaceItemIdentifier("songTitleCell")
- static let songDuration = NSUserInterfaceItemIdentifier("durationCell")
+ static let songDuration = NSUserInterfaceItemIdentifier("songDurationCell")
}
diff --git a/Persephone/MPDClient/Models/MPDSong.swift b/Persephone/MPDClient/Models/MPDSong.swift
index d55d8b8..a907e30 100644
--- a/Persephone/MPDClient/Models/MPDSong.swift
+++ b/Persephone/MPDClient/Models/MPDSong.swift
@@ -49,6 +49,10 @@ extension MPDClient {
return String(cString: uri)
}
+ var duration: Int {
+ return Int(mpd_song_get_duration(song))
+ }
+
var album: MPDAlbum {
return MPDAlbum(
title: getTag(.album),
diff --git a/Persephone/Models/Song.swift b/Persephone/Models/Song.swift
index 99db96e..6e6a5f2 100644
--- a/Persephone/Models/Song.swift
+++ b/Persephone/Models/Song.swift
@@ -23,6 +23,10 @@ struct Song {
return mpdSong.getTag(.artist)
}
+ var duration: Time {
+ return Time(timeInSeconds: mpdSong.duration)
+ }
+
var album: Album {
return Album(mpdAlbum: mpdSong.album)
}
diff --git a/Persephone/Resources/AlbumDetailView.xib b/Persephone/Resources/AlbumDetailView.xib
index edf6d4e..2efb6b0 100644
--- a/Persephone/Resources/AlbumDetailView.xib
+++ b/Persephone/Resources/AlbumDetailView.xib
@@ -57,13 +57,13 @@
-
+
-
+
-
+
@@ -88,7 +88,7 @@
-
+
@@ -106,7 +106,7 @@
-
+
@@ -120,12 +120,12 @@
-
+
-
-
+
+
@@ -143,7 +143,7 @@
-
+
@@ -156,12 +156,12 @@
-
-
+
+
-
+
@@ -196,7 +196,7 @@
-
+