diff --git a/src/ui/main-window/ThumbnailsView.swift b/src/ui/main-window/ThumbnailsView.swift index e8df9d47..55befcf4 100644 --- a/src/ui/main-window/ThumbnailsView.swift +++ b/src/ui/main-window/ThumbnailsView.swift @@ -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]? {