Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Fix overlapping settings list card borders on macOS

sunzhaozhengafec2bdc98f8
diff --git a/macos/Sources/RustyFiles/SettingsView.swift b/macos/Sources/RustyFiles/SettingsView.swift
index 3f99e9ad..a8fd58af 100644
--- a/macos/Sources/RustyFiles/SettingsView.swift
+++ b/macos/Sources/RustyFiles/SettingsView.swift
@@ -766,8 +766,10 @@ final class SettingsCardView: FlippedView {
var detail: String? { didSet { needsDisplay = true; superview?.superview?.superview?.needsLayout = true } }
let icon: String?
let control: NSView?
+ private let drawsBackground: Bool
- init(title: String, detail: String?, icon: String?, control: NSView?) {
+ init(title: String, detail: String?, icon: String?, control: NSView?, drawsBackground: Bool = true) {
+ self.drawsBackground = drawsBackground
self.title = title
self.detail = detail
self.icon = icon
@@ -820,16 +822,18 @@ final class SettingsCardView: FlippedView {
override func draw(_ dirtyRect: NSRect) {
let p = Palette.of(self)
- let r = bounds.insetBy(dx: 0.5, dy: 0.5)
- let path = NSBezierPath(roundedRect: r, xRadius: Metrics.radius, yRadius: Metrics.radius)
- p.hover.setFill()
- path.fill()
- if marked {
- p.accent.withAlphaComponent(0.18).setFill()
+ if drawsBackground {
+ let r = bounds.insetBy(dx: 0.5, dy: 0.5)
+ let path = NSBezierPath(roundedRect: r, xRadius: Metrics.radius, yRadius: Metrics.radius)
+ p.hover.setFill()
path.fill()
+ if marked {
+ p.accent.withAlphaComponent(0.18).setFill()
+ path.fill()
+ }
+ (marked ? p.accent : p.border).setStroke()
+ path.stroke()
}
- (marked ? p.accent : p.border).setStroke()
- path.stroke()
if let icon {
Draw.icon(icon, in: NSRect(x: 16, y: 0, width: 18, height: bounds.height), size: 18, color: p.text)
}
@@ -1413,7 +1417,7 @@ final class SettingsListCard: FlippedView {
init(title: String, detail: String?, icon: String?, entries: [(String, String?, NSColor?)], empty: String,
rowActions: [(String, (Int) -> Void)], control: NSView?) {
- head = SettingsCardView(title: title, detail: detail, icon: icon, control: control)
+ head = SettingsCardView(title: title, detail: detail, icon: icon, control: control, drawsBackground: false)
self.entries = entries
self.empty = empty
super.init(frame: .zero)
@@ -1487,10 +1491,10 @@ final class SettingsListCard: FlippedView {
}
override func draw(_ dirtyRect: NSRect) {
- // one card: the head draws its own box; the list continues it below with dividers
+ // The header and rows share one outline; draw only separators inside it.
let p = Palette.of(self)
let hh = head.height(for: bounds.width)
- let r = NSRect(x: 0.5, y: hh - 8, width: bounds.width - 1, height: bounds.height - hh + 8 - 0.5)
+ let r = bounds.insetBy(dx: 0.5, dy: 0.5)
let path = NSBezierPath(roundedRect: r, xRadius: Metrics.radius, yRadius: Metrics.radius)
p.hover.setFill()
path.fill()