fix: round corners would be aliased after changing theme (#1698)
This commit is contained in:
1 parent
24b8617c54
commit
9ae76a90fc
1 file changed
+13
-8
@@ -19,15 +19,20 @@ class ThumbnailsView: NSVisualEffectView {
|
||||
/// using layer!.cornerRadius works but the corners are aliased; this custom approach gives smooth rounded corners
|
||||
/// see https://stackoverflow.com/a/29386935/2249756
|
||||
func updateRoundedCorners(_ cornerRadius: CGFloat) {
|
||||
let edgeLength = 2.0 * cornerRadius + 1.0
|
||||
maskImage = NSImage(size: NSSize(width: edgeLength, height: edgeLength), flipped: false) { rect in
|
||||
let bezierPath = NSBezierPath(roundedRect: rect, xRadius: cornerRadius, yRadius: cornerRadius)
|
||||
NSColor.black.set()
|
||||
bezierPath.fill()
|
||||
return true
|
||||
if cornerRadius == 0 {
|
||||
maskImage = nil
|
||||
} else {
|
||||
let edgeLength = 2.0 * cornerRadius + 1.0
|
||||
let mask = NSImage(size: NSSize(width: edgeLength, height: edgeLength), flipped: false) { rect in
|
||||
let bezierPath = NSBezierPath(roundedRect: rect, xRadius: cornerRadius, yRadius: cornerRadius)
|
||||
NSColor.black.set()
|
||||
bezierPath.fill()
|
||||
return true
|
||||
}
|
||||
mask.capInsets = NSEdgeInsets(top: cornerRadius, left: cornerRadius, bottom: cornerRadius, right: cornerRadius)
|
||||
mask.resizingMode = .stretch
|
||||
maskImage = mask
|
||||
}
|
||||
maskImage!.capInsets = NSEdgeInsets(top: cornerRadius, left: cornerRadius, bottom: cornerRadius, right: cornerRadius)
|
||||
maskImage!.resizingMode = .stretch
|
||||
}
|
||||
|
||||
func nextRow(_ direction: Direction) -> [ThumbnailView]? {
|
||||
|
||||
Reference in new issue
Block a user