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

Show all track artists if any differs from album artist

This commit is contained in:
Wim Looman 2020-07-11 13:12:42 +02:00 committed by Daniel Barber
parent 1fd8e23f64
commit 53a9b38a9a
3 changed files with 16 additions and 3 deletions

View File

@ -13,14 +13,17 @@ class AlbumDetailSongTitleView: NSTableCellView {
@IBOutlet var songArtist: NSTextField!
var collapseArtist: NSLayoutConstraint!
func setSong(_ song: Song) {
func setShowArtist(_ show: Bool) {
if collapseArtist == nil {
collapseArtist = songArtist?.heightAnchor.constraint(equalToConstant: 0.0)
}
collapseArtist.isActive = !show
}
func setSong(_ song: Song) {
songTitle?.stringValue = song.title
songArtist?.stringValue = song.artist
collapseArtist.isActive = song.artist == song.albumArtist
}
}

View File

@ -82,7 +82,8 @@ extension AlbumDetailView: NSTableViewDelegate {
withIdentifier: .songTitle,
owner: self
) as! AlbumDetailSongTitleView
cellView.setShowArtist(dataSource.showSongArtist)
cellView.setSong(song)
return cellView

View File

@ -25,15 +25,24 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
}
var albumSongs: [AlbumSongItem] = []
var showSongArtist: Bool = false
func setAlbumSongs(_ songs: [Song]) {
var disc: String? = ""
var albumArtist: String?
showSongArtist = false
songs.forEach { song in
if song.disc != disc && song.disc != "0" {
disc = song.disc
albumSongs.append(AlbumSongItem(disc: song.disc))
}
if albumArtist == nil {
albumArtist = song.albumArtist
}
if song.artist != albumArtist {
showSongArtist = true
}
albumSongs.append(AlbumSongItem(song: song))
}