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

Compare commits

...

4 Commits

Author SHA1 Message Date
9f8f3a6ecf
Little bit of tidy up 2019-12-06 17:44:03 -05:00
034eb6dca5
Bump the border radius a little 2019-11-02 20:25:36 -04:00
47ad36f12a
Better borders
The original border was not following the curve of the album cover
corners. Changing the background of the background box too fills in
these little gaps and makes the selection look cleaner.
2019-11-01 13:38:58 -04:00
da851365d6
Improve album art display
* Mask album art to rounded corners
* Add a black background colour for albums with non square artwork
2019-11-01 13:11:09 -04:00
2 changed files with 28 additions and 12 deletions

View File

@ -14,7 +14,7 @@ class AlbumViewItem: NSCollectionViewItem {
override var isSelected: Bool {
didSet {
albumCoverBox.layer?.borderWidth = isSelected ? 5 : 0
setAppearance(selected: isSelected)
}
}
@ -22,18 +22,20 @@ class AlbumViewItem: NSCollectionViewItem {
super.viewDidLoad()
albumCoverView.wantsLayer = true
albumCoverView.layer?.cornerRadius = 3
albumCoverView.layer?.backgroundColor = NSColor.black.cgColor
albumCoverView.layer?.cornerRadius = 4
albumCoverView.layer?.borderWidth = 1
albumCoverView.layer?.masksToBounds = true
albumCoverBox.wantsLayer = true
albumCoverBox.layer?.cornerRadius = 5
albumCoverBox.layer?.borderWidth = 0
albumCoverBox.layer?.cornerRadius = 7
albumCoverBox.layer?.borderWidth = 5
setAppearance()
setAppearance(selected: false)
if #available(OSX 10.14, *) {
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
self.setAppearance()
self.setAppearance(selected: false)
}
}
}
@ -57,16 +59,22 @@ class AlbumViewItem: NSCollectionViewItem {
}
}
func setAppearance() {
func setAppearance(selected isSelected: Bool) {
guard let viewLayer = albumCoverView.layer,
let boxLayer = albumCoverBox.layer
else { return }
if #available(OSX 10.14, *) {
let darkMode = NSApp.effectiveAppearance.bestMatch(from:
[.darkAqua, .aqua]) == .darkAqua
albumCoverView.layer?.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
albumCoverBox.layer?.borderColor = NSColor.controlAccentColor.cgColor
viewLayer.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
boxLayer.borderColor = isSelected ? NSColor.controlAccentColor.cgColor : CGColor.clear
boxLayer.backgroundColor = albumCoverBox.layer?.borderColor
} else {
albumCoverView.layer?.borderColor = .albumBorderColorLight
albumCoverBox.layer?.borderColor = NSColor.selectedControlColor.cgColor
viewLayer.borderColor = .albumBorderColorLight
boxLayer.borderColor = isSelected ? NSColor.selectedControlColor.cgColor : CGColor.clear
boxLayer.backgroundColor = albumCoverBox.layer?.borderColor
}
}

View File

@ -9,6 +9,7 @@
import AppKit
class AlbumDetailView: NSViewController {
var observer: NSKeyValueObservation?
var album: Album?
var dataSource = AlbumTracksDataSource()
@ -30,10 +31,17 @@ class AlbumDetailView: NSViewController {
albumTracksView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
albumCoverView.wantsLayer = true
albumCoverView.layer?.cornerRadius = 5
albumCoverView.layer?.backgroundColor = NSColor.black.cgColor
albumCoverView.layer?.cornerRadius = 6
albumCoverView.layer?.borderWidth = 1
albumCoverView.layer?.masksToBounds = true
setAppearance()
if #available(OSX 10.14, *) {
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
self.setAppearance()
}
}
}
override func viewWillAppear() {