Improve shadows performance.
This commit is contained in:
1 file changed
+17
@@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
import AVFoundation
|
||||||
|
|
||||||
class ArtworkSelectorViewItemLabel : NSTextField {
|
class ArtworkSelectorViewItemLabel : NSTextField {
|
||||||
|
|
||||||
@@ -198,6 +199,16 @@ class ArtworkSelectorViewItemView: NSView {
|
|||||||
} else {
|
} else {
|
||||||
backgroundLayer.backgroundColor = NSColor.controlHighlightColor.cgColor
|
backgroundLayer.backgroundColor = NSColor.controlHighlightColor.cgColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let image = imageLayer.contents as? NSImage {
|
||||||
|
let rect = AVMakeRect(aspectRatio: image.size, insideRect: imageLayer.bounds)
|
||||||
|
let path = CGMutablePath()
|
||||||
|
path.addRect(rect)
|
||||||
|
|
||||||
|
imageLayer.shadowPath = path
|
||||||
|
} else {
|
||||||
|
imageLayer.shadowPath = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -213,6 +224,12 @@ class ArtworkSelectorViewItem: NSCollectionViewItem {
|
|||||||
var doubleAction: Selector?
|
var doubleAction: Selector?
|
||||||
weak var target: AnyObject?
|
weak var target: AnyObject?
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
subTextField.layer?.isOpaque = true
|
||||||
|
textField?.layer?.isOpaque = true
|
||||||
|
}
|
||||||
|
|
||||||
override var title: String? {
|
override var title: String? {
|
||||||
set (title) {
|
set (title) {
|
||||||
textField?.stringValue = title ?? ""
|
textField?.stringValue = title ?? ""
|
||||||
|
|||||||
Reference in new issue
Block a user