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.

macOS: improve active tab and option label contrast in light mode

Onur Ugur43b941e06d88
diff --git a/macos/Sources/RustyFiles/BrowserWindowController.swift b/macos/Sources/RustyFiles/BrowserWindowController.swift
index 77ad687d..d06982b2 100644
--- a/macos/Sources/RustyFiles/BrowserWindowController.swift
+++ b/macos/Sources/RustyFiles/BrowserWindowController.swift
@@ -127,8 +127,11 @@ final class RootView: FlippedView {
override func viewDidChangeEffectiveAppearance() {
super.viewDidChangeEffectiveAppearance()
- needsDisplay = true
- subviews.forEach { $0.needsDisplay = true }
+ func redraw(_ v: NSView) {
+ v.needsDisplay = true
+ v.subviews.forEach(redraw)
+ }
+ redraw(self)
}
}
diff --git a/macos/Sources/RustyFiles/CommandPalette.swift b/macos/Sources/RustyFiles/CommandPalette.swift
index cb46b48b..a4d0dd0a 100644
--- a/macos/Sources/RustyFiles/CommandPalette.swift
+++ b/macos/Sources/RustyFiles/CommandPalette.swift
@@ -416,11 +416,17 @@ private final class PaletteBackground: NSView {
override func draw(_ dirtyRect: NSRect) {
let p = Palette.of(self)
let r = NSBezierPath(roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5), xRadius: 14, yRadius: 14)
+ if !p.dark {
+ p.cardBg.withAlphaComponent(0.78).setFill()
+ r.fill()
+ }
p.border.setStroke()
r.stroke()
p.divider.setFill()
NSRect(x: 12, y: bounds.height - 54, width: bounds.width - 24, height: 1).fill()
}
+
+ override func viewDidChangeEffectiveAppearance() { needsDisplay = true }
}
private final class PaletteRow: NSTableCellView {
diff --git a/macos/Sources/RustyFiles/FileList.swift b/macos/Sources/RustyFiles/FileList.swift
index a9b4c7ca..8fde901e 100644
--- a/macos/Sources/RustyFiles/FileList.swift
+++ b/macos/Sources/RustyFiles/FileList.swift
@@ -613,6 +613,15 @@ final class FileTableView: NSTableView, NSServicesMenuRequestor {
override func acceptsPreviewPanelControl(_ panel: QLPreviewPanel!) -> Bool { true }
override func beginPreviewPanelControl(_ panel: QLPreviewPanel!) { list?.beginQuickLook(panel) }
override func endPreviewPanelControl(_ panel: QLPreviewPanel!) { list?.endQuickLook(panel) }
+
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ let color = Palette.of(self).text
+ enumerateAvailableRowViews { rowView, _ in
+ (rowView.view(atColumn: 0) as? NameCellView)?.textField?.textColor = color
+ rowView.needsDisplay = true
+ }
+ }
}
// MARK: - status bar
diff --git a/macos/Sources/RustyFiles/LayoutFlyout.swift b/macos/Sources/RustyFiles/LayoutFlyout.swift
index c17d67ff..bb9c3c41 100644
--- a/macos/Sources/RustyFiles/LayoutFlyout.swift
+++ b/macos/Sources/RustyFiles/LayoutFlyout.swift
@@ -154,7 +154,7 @@ final class LayoutTile: HoverView {
Draw.roundedRect(r, radius: Metrics.radiusSmall, fill: p.hover)
}
Draw.icon(mode.icon, in: NSRect(x: 0, y: 8, width: bounds.width, height: 20), size: 18, color: isOn ? p.accent : p.text)
- Draw.text(mode.title, in: NSRect(x: 2, y: 32, width: bounds.width - 4, height: 14), font: NSFont.systemFont(ofSize: 10), color: p.textSecondary, align: .center)
+ Draw.text(mode.title, in: NSRect(x: 2, y: 32, width: bounds.width - 4, height: 14), font: NSFont.systemFont(ofSize: 10, weight: isOn ? .medium : .regular), color: isOn ? p.text : p.textSecondary, align: .center)
}
override func mouseUp(with event: NSEvent) { onPick?() }
diff --git a/macos/Sources/RustyFiles/PreviewPane.swift b/macos/Sources/RustyFiles/PreviewPane.swift
index cd147444..4e9f2abe 100644
--- a/macos/Sources/RustyFiles/PreviewPane.swift
+++ b/macos/Sources/RustyFiles/PreviewPane.swift
@@ -61,6 +61,20 @@ final class PreviewPane: FlippedView {
/// name and properties beside it (preview_wide.rs).
var atBottom = false { didSet { if atBottom != oldValue { needsLayout = true; needsDisplay = true } } }
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ let p = Palette.of(self)
+ nameLabel.textColor = p.text
+ empty.textColor = p.textSecondary
+ for pair in rows.subviews.chunked(2) {
+ guard pair.count == 2, let key = pair[0] as? NSTextField, let value = pair[1] as? NSTextField else { continue }
+ key.textColor = p.textSecondary
+ value.textColor = p.text
+ }
+ needsLayout = true
+ needsDisplay = true
+ }
+
override func draw(_ dirtyRect: NSRect) {
// the divider on the side next to the list (`border_l_1`, or `border_t_1` at the bottom)
let p = Palette.of(self)
diff --git a/macos/Sources/RustyFiles/Properties.swift b/macos/Sources/RustyFiles/Properties.swift
index c9ad3579..f54c9323 100644
--- a/macos/Sources/RustyFiles/Properties.swift
+++ b/macos/Sources/RustyFiles/Properties.swift
@@ -739,6 +739,8 @@ final class PropertiesBackground: FlippedView {
Palette.of(self).contentBg.setFill()
dirtyRect.fill()
}
+
+ override func viewDidChangeEffectiveAppearance() { needsDisplay = true }
}
/// A card: the tile colour, rounded, with a hairline border.
diff --git a/macos/Sources/RustyFiles/SelfTest.swift b/macos/Sources/RustyFiles/SelfTest.swift
index a9be391a..f0d0f448 100644
--- a/macos/Sources/RustyFiles/SelfTest.swift
+++ b/macos/Sources/RustyFiles/SelfTest.swift
@@ -70,6 +70,70 @@ enum SelfTest {
scroll(sv, ended, dx: 0)
check(swiped.isEmpty, "a short sideways nudge is not a swipe")
+ // 0c. light mode contrast and glass appearance (issue 682): active tabs, lenses and option
+ // labels stay readable in light mode across Liquid Glass, Translucent and Solid materials
+ do {
+ let d = UserDefaults.standard
+ let savedMaterial = d.object(forKey: "material")
+ let savedWash = d.object(forKey: "surfaceWash")
+ let savedAccent = d.object(forKey: "accent")
+ defer {
+ if let savedMaterial { d.set(savedMaterial, forKey: "material") } else { d.removeObject(forKey: "material") }
+ if let savedWash { d.set(savedWash, forKey: "surfaceWash") } else { d.removeObject(forKey: "surfaceWash") }
+ if let savedAccent { d.set(savedAccent, forKey: "accent") } else { d.removeObject(forKey: "accent") }
+ Palette.invalidate()
+ }
+ d.set(50, forKey: "surfaceWash")
+ d.set("", forKey: "accent")
+ let lightHost = NSView()
+ lightHost.appearance = NSAppearance(named: .aqua)
+ let darkHost = NSView()
+ darkHost.appearance = NSAppearance(named: .darkAqua)
+ let darkWallpaper = Palette.hex(0x1E1E1E)
+ let whiteBg = Palette.hex(0xFFFFFF)
+
+ for mat in AppSettings.Material.allCases {
+ d.set(mat.rawValue, forKey: "material")
+ Palette.invalidate()
+ let p = Palette.of(lightHost)
+ check(!p.dark, "aqua view resolves light palette (\(mat.rawValue))")
+ let baseBg: NSColor
+ switch mat {
+ case .glass:
+ baseBg = Palette.composite(p.windowBg, over: darkWallpaper)
+ case .finder:
+ baseBg = Palette.hex(0xE6E6E6)
+ case .solid:
+ baseBg = Palette.composite(p.windowBg, over: darkWallpaper)
+ }
+ let contentSurface = Palette.composite(p.contentBg, over: baseBg)
+ let tabSurface = Palette.composite(mat == .glass ? p.tabActive.withAlphaComponent(0.65) : p.tabActive, over: baseBg)
+ check(Palette.contrastRatio(p.text, over: tabSurface) >= 7.0, "light active tab text contrast (\(mat.rawValue))")
+ check(Palette.contrastRatio(p.text, over: contentSurface) >= 7.0, "light option title contrast (\(mat.rawValue))")
+ check(Palette.contrastRatio(p.textSecondary, over: contentSurface) >= 4.5, "light option detail contrast (\(mat.rawValue))")
+ check(Palette.contrastRatio(p.textTertiary, over: whiteBg) >= 4.5, "light tertiary label contrast on white (\(mat.rawValue))")
+ }
+
+ d.set("glass", forKey: "material")
+ Palette.invalidate()
+ for hex in AppSettings.swatches {
+ d.set(String(format: "#%06X", hex), forKey: "accent")
+ Palette.invalidate()
+ let p = Palette.of(lightHost)
+ check(Palette.contrastRatio(p.accentText, over: p.accent) >= 4.5, String(format: "light accentText contrast on #%06X", hex))
+ }
+
+ let lightLens = LensView(cornerRadius: 8)
+ lightLens.appearance = NSAppearance(named: .aqua)
+ lightLens.applyAppearance()
+ let darkLens = LensView(cornerRadius: 8)
+ darkLens.appearance = NSAppearance(named: .darkAqua)
+ darkLens.applyAppearance()
+ check(lightLens.style == .regular, "light lens uses frosted regular glass")
+ check(darkLens.style == .clear, "dark lens keeps clear glass")
+ check(Palette.of(darkHost).dark, "darkAqua view resolves dark palette")
+ }
+
// 1. copy a file and a folder: both arrive whole
Transfer(.copy, [a.appendingPathComponent("big.bin"), a.appendingPathComponent("folder")], into: b).start(window: nil) { made in
check(made.count == 2, "copy reports two new items")
diff --git a/macos/Sources/RustyFiles/Settings.swift b/macos/Sources/RustyFiles/Settings.swift
index 82cbc229..67a38f3a 100644
--- a/macos/Sources/RustyFiles/Settings.swift
+++ b/macos/Sources/RustyFiles/Settings.swift
@@ -212,11 +212,12 @@ enum AppSettings {
Palette.invalidate()
}
- /// The window and content washes for the surface value, as theme.rs `glass_washes`: 50 is
- /// dark 0.18 / 0.22, light 0.20 / 0.35; 100 the Mica strength; 0 none; straight lines between.
- /// Off glass the washes are the full strength the Windows app gives Mica (100).
+ /// The window and content washes for the surface value, as theme.rs `glass_washes`: dark keeps
+ /// 0.18 / 0.22 at 50 and 0.40 / 0.45 at 100; light uses a stronger veil (0.62 / 0.78 at 50,
+ /// 0.85 / 0.92 at 100) because macOS Liquid Glass is much clearer than Windows Mica and dark
+ /// text needs a bright surface behind it over dark wallpapers. Off glass, full strength (100).
static func washes(dark: Bool) -> (window: CGFloat, content: CGFloat) {
- let (w50, c50, w100, c100): (CGFloat, CGFloat, CGFloat, CGFloat) = dark ? (0.18, 0.22, 0.40, 0.45) : (0.20, 0.35, 0.30, 0.50)
+ let (w50, c50, w100, c100): (CGFloat, CGFloat, CGFloat, CGFloat) = dark ? (0.18, 0.22, 0.40, 0.45) : (0.62, 0.78, 0.85, 0.92)
let v = CGFloat(isGlass ? surfaceWash : 100)
if v <= 50 {
let t = v / 50
diff --git a/macos/Sources/RustyFiles/SettingsView.swift b/macos/Sources/RustyFiles/SettingsView.swift
index 132a6052..3f99e9ad 100644
--- a/macos/Sources/RustyFiles/SettingsView.swift
+++ b/macos/Sources/RustyFiles/SettingsView.swift
@@ -450,7 +450,7 @@ final class LiquidSwitch: HoverView {
override func draw(_ dirtyRect: NSRect) {
let p = Palette.of(self)
let track = bounds
- let off = p.dark ? NSColor(white: 1, alpha: 0.16) : NSColor(white: 0, alpha: 0.16)
+ let off = p.dark ? NSColor(white: 1, alpha: 0.16) : NSColor(white: 0, alpha: 0.20)
let fill = off.blended(withFraction: progress, of: p.accent) ?? p.accent
Draw.roundedRect(track, radius: track.height / 2, fill: fill)
let tw = track.width * 0.58, th = track.height * 0.9
@@ -512,8 +512,15 @@ final class LiquidDropdown: HoverView {
override func draw(_ dirtyRect: NSRect) {
let p = Palette.of(self)
- let fill = p.dark ? NSColor(white: 1, alpha: hovered ? 0.15 : 0.10) : NSColor(white: 0, alpha: hovered ? 0.10 : 0.06)
- Draw.roundedRect(bounds, radius: bounds.height / 2, fill: fill)
+ let r = bounds.insetBy(dx: 0.5, dy: 0.5)
+ let path = NSBezierPath(roundedRect: r, xRadius: r.height / 2, yRadius: r.height / 2)
+ let fill = p.dark ? NSColor(white: 1, alpha: hovered ? 0.15 : 0.10) : (hovered ? p.pressed : NSColor(white: 1, alpha: 0.78))
+ fill.setFill()
+ path.fill()
+ if !p.dark {
+ p.border.setStroke()
+ path.stroke()
+ }
Draw.text(label, in: NSRect(x: 14, y: 0, width: bounds.width - 14 - 8 - 14 - 14, height: bounds.height), font: Metrics.textSm, color: p.text)
Draw.icon("chevron-down", in: NSRect(x: bounds.width - 14 - 14, y: 0, width: 14, height: bounds.height), size: 14, color: p.textSecondary)
}
@@ -571,7 +578,7 @@ final class LiquidSlider: HoverView {
let (lo, hi) = span
let x = lo + (hi - lo) * CGFloat(value) / 100
let track = NSRect(x: lo, y: 10, width: hi - lo, height: 4)
- Draw.roundedRect(track, radius: 2, fill: p.dark ? NSColor(white: 1, alpha: 0.16) : NSColor(white: 0, alpha: 0.14))
+ Draw.roundedRect(track, radius: 2, fill: p.dark ? NSColor(white: 1, alpha: 0.16) : NSColor(white: 0, alpha: 0.18))
Draw.roundedRect(NSRect(x: lo, y: 10, width: x - lo, height: 4), radius: 2, fill: p.accent)
let size = dragging ? thumbHeld : thumbRest
let thumb = NSRect(x: x - size.width / 2, y: 12 - size.height / 2, width: size.width, height: size.height)
@@ -649,7 +656,8 @@ final class PlainButton: HoverView {
let p = Palette.of(self)
let r = bounds.insetBy(dx: 0.5, dy: 0.5)
let path = NSBezierPath(roundedRect: r, xRadius: Metrics.radiusSmall, yRadius: Metrics.radiusSmall)
- (hovered ? p.pressed : p.hover).setFill()
+ let fill = p.dark ? (hovered ? p.pressed : p.hover) : (hovered ? p.pressed : NSColor(white: 1, alpha: 0.78))
+ fill.setFill()
path.fill()
p.border.setStroke()
path.stroke()
@@ -715,7 +723,7 @@ final class AccentPicker: HoverView {
default:
let selected = value == "" ? current.isEmpty : (!current.isEmpty && !isSwatch)
let path = NSBezierPath(roundedRect: r.insetBy(dx: 0.5, dy: 0.5), xRadius: Metrics.radiusSmall, yRadius: Metrics.radiusSmall)
- p.hover.setFill()
+ (p.dark ? p.hover : NSColor(white: 1, alpha: 0.78)).setFill()
path.fill()
(selected ? p.accent : p.border).setStroke()
path.stroke()
@@ -887,6 +895,8 @@ final class ValueLabel: FlippedView {
override func draw(_ dirtyRect: NSRect) {
Draw.text(text, in: bounds, font: Metrics.textSm, color: Palette.of(self).textSecondary, align: .right)
}
+
+ override func viewDidChangeEffectiveAppearance() { needsDisplay = true }
}
// MARK: - the page
@@ -1151,7 +1161,13 @@ final class SettingsView: FlippedView, NSTextFieldDelegate {
override func viewDidChangeEffectiveAppearance() {
super.viewDidChangeEffectiveAppearance()
+ search.textColor = Palette.of(self).text
needsLayout = true
+ func redraw(_ v: NSView) {
+ v.needsDisplay = true
+ v.subviews.forEach(redraw)
+ }
+ redraw(self)
}
}
@@ -1175,6 +1191,8 @@ final class SectionHeader: FlippedView {
title, in: NSRect(x: 0, y: 20, width: bounds.width, height: bounds.height - 24),
font: secondary ? Metrics.textSm : NSFont.systemFont(ofSize: 14, weight: .semibold), color: secondary ? p.textSecondary : p.text)
}
+
+ override func viewDidChangeEffectiveAppearance() { needsDisplay = true }
}
/// The page list: "Settings" (20 semibold), the search box (32, hover fill, border), then the
@@ -1223,11 +1241,13 @@ final class SettingsNavView: HoverView {
if isSelected && !AppSettings.isGlass {
Draw.roundedRect(r, radius: Metrics.radiusSmall, fill: p.selection)
Draw.selectionPill(in: r, accent: p.accent)
+ } else if isSelected && !p.dark {
+ Draw.roundedRect(r, radius: 14, fill: p.tabActive.withAlphaComponent(0.60))
} else if !isSelected && hot == i {
Draw.roundedRect(r, radius: Metrics.radiusSmall, fill: p.hover)
}
Draw.icon(page.icon, in: NSRect(x: r.minX + 12, y: r.minY, width: 16, height: r.height), size: 16, color: isSelected ? p.accent : p.textSecondary)
- Draw.text(page.title, in: NSRect(x: r.minX + 12 + 16 + 12, y: r.minY, width: r.width - 52, height: r.height), font: Metrics.textSm, color: p.text)
+ Draw.text(page.title, in: NSRect(x: r.minX + 12 + 16 + 12, y: r.minY, width: r.width - 52, height: r.height), font: isSelected ? Metrics.textSmMedium : Metrics.textSm, color: p.text)
if page.isExperimental {
// the "Experimental" pill: px 6, 1 px border, 10 pt secondary
let label = String(localized: "Experimental")
@@ -1438,8 +1458,17 @@ final class SettingsListCard: FlippedView {
func height(for width: CGFloat) -> CGFloat { head.height(for: width) + CGFloat(rowViews.count) * Self.rowH + 6 }
+ private func applyTextColors() {
+ let p = Palette.of(self)
+ for (t, sub, _) in rowViews {
+ t.textColor = entries.isEmpty ? p.textSecondary : p.text
+ sub?.textColor = p.textSecondary
+ }
+ }
+
override func layout() {
super.layout()
+ applyTextColors()
let hh = head.height(for: bounds.width)
head.frame = NSRect(x: 0, y: 0, width: bounds.width, height: hh)
var y = hh
@@ -1477,4 +1506,10 @@ final class SettingsListCard: FlippedView {
NSBezierPath(ovalIn: NSRect(x: 26, y: hh + CGFloat(i) * Self.rowH + (Self.rowH - 12) / 2, width: 12, height: 12)).fill()
}
}
+
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ applyTextColors()
+ needsDisplay = true
+ }
}
diff --git a/macos/Sources/RustyFiles/Sidebar.swift b/macos/Sources/RustyFiles/Sidebar.swift
index e082abeb..c2f0d8df 100644
--- a/macos/Sources/RustyFiles/Sidebar.swift
+++ b/macos/Sources/RustyFiles/Sidebar.swift
@@ -462,6 +462,8 @@ final class SidebarListView: HoverView {
} else if isSelected && (!hasLens || !AppSettings.isGlass) {
Draw.roundedRect(r, radius: Metrics.radiusSmall, fill: p.selection)
Draw.selectionPill(in: r, accent: p.accent)
+ } else if isSelected && !p.dark {
+ Draw.roundedRect(r, radius: 14, fill: p.tabActive.withAlphaComponent(0.60))
} else if !isSelected && hot == i {
Draw.roundedRect(r, radius: Metrics.radiusSmall, fill: p.hover)
}
diff --git a/macos/Sources/RustyFiles/StatusCenter.swift b/macos/Sources/RustyFiles/StatusCenter.swift
index 31ec4846..9e2fff3b 100644
--- a/macos/Sources/RustyFiles/StatusCenter.swift
+++ b/macos/Sources/RustyFiles/StatusCenter.swift
@@ -590,6 +590,9 @@ final class FerryQuestionView: FlippedView {
override func draw(_ dirtyRect: NSRect) {
guard let question else { return }
let p = Palette.of(self)
+ if !p.dark && AppSettings.isGlass {
+ Draw.roundedRect(bounds, radius: 16, fill: p.cardBg.withAlphaComponent(0.78))
+ }
var y: CGFloat = 16
Draw.icon("send", in: NSRect(x: 16, y: y, width: 16, height: 18), size: 16, color: p.accent)
Draw.text("Ferry", in: NSRect(x: 16 + 16 + 8, y: y, width: 100, height: 18), font: Metrics.textXs, color: p.textSecondary)
diff --git a/macos/Sources/RustyFiles/Theme.swift b/macos/Sources/RustyFiles/Theme.swift
index fd184a73..1df6904c 100644
--- a/macos/Sources/RustyFiles/Theme.swift
+++ b/macos/Sources/RustyFiles/Theme.swift
@@ -39,10 +39,51 @@ struct Palette {
return hex(v)
}
+ /// Relative luminance of an opaque sRGB colour (WCAG 2.1).
+ static func relativeLuminance(_ color: NSColor) -> CGFloat {
+ guard let c = color.usingColorSpace(.sRGB) else { return 0 }
+ func lin(_ v: CGFloat) -> CGFloat { v <= 0.04045 ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4) }
+ return 0.2126 * lin(c.redComponent) + 0.7152 * lin(c.greenComponent) + 0.0722 * lin(c.blueComponent)
+ }
+
+ /// Composites `foreground` (which may be translucent) over an opaque `background`.
+ static func composite(_ foreground: NSColor, over background: NSColor) -> NSColor {
+ guard let fg = foreground.usingColorSpace(.sRGB), let bg = background.usingColorSpace(.sRGB) else { return foreground }
+ let a = fg.alphaComponent
+ return NSColor(
+ srgbRed: fg.redComponent * a + bg.redComponent * (1 - a),
+ green: fg.greenComponent * a + bg.greenComponent * (1 - a),
+ blue: fg.blueComponent * a + bg.blueComponent * (1 - a),
+ alpha: 1)
+ }
+
+ /// WCAG contrast ratio (1…21) of `foreground` drawn over an opaque `background`.
+ static func contrastRatio(_ foreground: NSColor, over background: NSColor) -> CGFloat {
+ let l1 = relativeLuminance(composite(foreground, over: background))
+ let l2 = relativeLuminance(background)
+ return (max(l1, l2) + 0.05) / (min(l1, l2) + 0.05)
+ }
+
+ /// White or near-black text, whichever has higher contrast over `background`.
+ private static func contrastText(on background: NSColor) -> NSColor {
+ let white = hex(0xFFFFFF), dark = hex(0x000000, 0.90)
+ return contrastRatio(white, over: background) >= contrastRatio(dark, over: background) ? white : dark
+ }
+
/// The accent (chosen, else the system's) as Windows would shade it for this theme.
@MainActor
private static func shadedAccent(dark: Bool) -> NSColor {
- let base = parse(AppSettings.accent) ?? NSColor.controlAccentColor
+ let base: NSColor
+ if let custom = parse(AppSettings.accent) {
+ base = custom
+ } else {
+ let appearance = NSAppearance(named: dark ? .darkAqua : .aqua) ?? NSAppearance.currentDrawing()
+ var resolved = NSColor.controlAccentColor
+ appearance.performAsCurrentDrawingAppearance {
+ resolved = NSColor.controlAccentColor.usingColorSpace(.sRGB) ?? NSColor.controlAccentColor
+ }
+ base = resolved
+ }
guard let a = base.usingColorSpace(.sRGB) else { return dark ? hex(0x60CDFF) : hex(0x005FB8) }
return dark ? (a.blended(withFraction: 0.45, of: .white) ?? a) : (a.blended(withFraction: 0.25, of: .black) ?? a)
}
@@ -64,18 +105,18 @@ struct Palette {
cardBg: hex(0xF9F9F9),
tileBg: hex(0xFFFFFF, 0.70),
tileHover: hex(0xF9F9F9, 0.50),
- border: hex(0x000000, 0.07),
- divider: hex(0x000000, 0.07),
+ border: hex(0x000000, 0.11),
+ divider: hex(0x000000, 0.10),
text: hex(0x000000, 0.90),
- textSecondary: hex(0x000000, 0.62),
- textTertiary: hex(0x000000, 0.45),
+ textSecondary: hex(0x000000, 0.68),
+ textTertiary: hex(0x000000, 0.55),
accent: accent,
- accentText: hex(0xFFFFFF),
+ accentText: contrastText(on: accent),
hover: hex(0x000000, 0.04),
- pressed: hex(0x000000, 0.07),
- selection: hex(0x000000, 0.06),
+ pressed: hex(0x000000, 0.08),
+ selection: hex(0x000000, 0.07),
selectionBorder: accent.withAlphaComponent(0.55),
- tabActive: hex(0xFFFFFF, 0.70),
+ tabActive: hex(0xFFFFFF, 0.92),
danger: hex(0xC42B1C))
}
if AppSettings.theme == .black {
@@ -400,16 +441,18 @@ enum Icons {
/// A glass lens: the Liquid Glass piece that marks a selection over a glass window (the
/// sidebar's selected place, the active tab, the round glass behind "+"), where the Windows
/// app draws HyperGlass lenses. It sits *under* the drawn content, so text stays on top.
+/// In light mode it switches from `.clear` to `.regular` so dark text over it never drops
+/// into dark clear-glass refraction.
@MainActor
final class LensView: NSGlassEffectView {
init(cornerRadius: CGFloat) {
super.init(frame: .zero)
self.cornerRadius = cornerRadius
- style = .clear
// live lensing under the pointer and on press (macOS 27); use KVC selector check so macOS 26 SDK builds cleanly
if #available(macOS 27.0, *), responds(to: Selector(("setEffectIsInteractive:"))) {
setValue(true, forKey: "effectIsInteractive")
}
+ applyAppearance()
}
@available(*, unavailable)
@@ -420,6 +463,21 @@ final class LensView: NSGlassEffectView {
/// Lenses never take clicks; the view above them does.
override func hitTest(_ point: NSPoint) -> NSView? { nil }
+ override func viewDidMoveToWindow() {
+ super.viewDidMoveToWindow()
+ applyAppearance()
+ }
+
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ applyAppearance()
+ }
+
+ func applyAppearance() {
+ let dark = effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua
+ style = dark ? .clear : .regular
+ }
+
/// Moves to `frame`, sliding there when it was already showing (the lens travels from the
/// old selection to the new one, as on Windows).
func move(to frame: NSRect, animated: Bool) {
diff --git a/macos/Sources/RustyFiles/Tiles.swift b/macos/Sources/RustyFiles/Tiles.swift
index 26c2e383..bee5b20d 100644
--- a/macos/Sources/RustyFiles/Tiles.swift
+++ b/macos/Sources/RustyFiles/Tiles.swift
@@ -320,6 +320,17 @@ final class TileCollectionView: NSCollectionView, NSServicesMenuRequestor {
override func acceptsPreviewPanelControl(_ panel: QLPreviewPanel!) -> Bool { true }
override func beginPreviewPanelControl(_ panel: QLPreviewPanel!) { list?.beginQuickLook(panel) }
override func endPreviewPanelControl(_ panel: QLPreviewPanel!) { list?.endQuickLook(panel) }
+
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ let p = Palette.of(self)
+ for item in visibleItems() {
+ guard let t = item as? TileItem else { continue }
+ t.tile.label.textColor = p.text
+ t.tile.facts.textColor = p.textSecondary
+ t.tile.needsDisplay = true
+ }
+ }
}
/// A group's header in the grid: the title in the accent, medium, then a line (the list's
diff --git a/macos/Sources/RustyFiles/TitleBar.swift b/macos/Sources/RustyFiles/TitleBar.swift
index 50e13f91..3bb854a6 100644
--- a/macos/Sources/RustyFiles/TitleBar.swift
+++ b/macos/Sources/RustyFiles/TitleBar.swift
@@ -126,6 +126,18 @@ final class TabStripView: HoverView, NSViewToolTipOwner {
// off glass the active tab is filled, as on Windows (no lens)
p.tabActive.setFill()
path.fill()
+ if !p.dark {
+ p.border.setStroke()
+ NSBezierPath(roundedTopRect: r.insetBy(dx: 0.5, dy: 0.5), radius: Metrics.radius).stroke()
+ }
+ } else if isActive && !p.dark {
+ // over light glass, give the active tab a bright frosted veil over the lens so its
+ // dark label and accent icon stay legible against dark wallpapers and stand apart
+ // from inactive tabs
+ p.tabActive.withAlphaComponent(0.65).setFill()
+ path.fill()
+ p.border.setStroke()
+ NSBezierPath(roundedTopRect: r.insetBy(dx: 0.5, dy: 0.5), radius: Metrics.radius).stroke()
} else if !isActive && hoveredTab == i {
p.hover.setFill()
path.fill()
@@ -138,16 +150,17 @@ final class TabStripView: HoverView, NSViewToolTipOwner {
let textEnd = close ? closeRect(i).minX - 8 : r.maxX - 4
let room = NSRect(x: x, y: r.minY, width: max(textEnd - x, 0), height: r.height)
let color = isActive ? p.text : p.textSecondary
+ let font = isActive ? Metrics.textSmMedium : Metrics.textSm
if AppSettings.tabPath, let path = t.path {
- Draw.text(path, in: room, font: Metrics.textXs, color: color, truncation: .byTruncatingTail)
+ Draw.text(path, in: room, font: isActive ? Metrics.textXsSemibold : Metrics.textXs, color: color, truncation: .byTruncatingTail)
} else if let hint = t.hint {
// the name first (never more than 70 % of the room), the telling folder after it, lighter
- let nameW = min(Draw.textWidth(t.title, font: Metrics.textSm), room.width * 0.7)
- Draw.text(t.title, in: NSRect(x: room.minX, y: room.minY, width: nameW, height: room.height), font: Metrics.textSm, color: color)
+ let nameW = min(Draw.textWidth(t.title, font: font), room.width * 0.7)
+ Draw.text(t.title, in: NSRect(x: room.minX, y: room.minY, width: nameW, height: room.height), font: font, color: color)
let hx = room.minX + nameW + 4
Draw.text("@" + hint, in: NSRect(x: hx, y: room.minY, width: max(room.maxX - hx, 0), height: room.height), font: Metrics.textSm, color: p.textTertiary)
} else {
- Draw.text(t.title, in: room, font: Metrics.textSm, color: color)
+ Draw.text(t.title, in: room, font: font, color: color)
}
if close {
let c = closeRect(i)
@@ -308,6 +321,7 @@ final class TitleBarView: FlippedView {
plusLens.frame = plus.frame
plusLens.isHidden = !AppSettings.isGlass
if !sessionLabel.isHidden {
+ sessionLabel.textColor = Palette.of(self).textSecondary
let w = min(sessionLabel.intrinsicContentSize.width, max(bounds.width - plus.frame.maxX - 16, 0))
sessionLabel.frame = NSRect(x: plus.frame.maxX + 8, y: plus.frame.midY - 8, width: w, height: 16)
}
@@ -317,4 +331,10 @@ final class TitleBarView: FlippedView {
lens.size.height += Metrics.radius
tabLens.move(to: lens, animated: !inLiveResize)
}
+
+ override func viewDidChangeEffectiveAppearance() {
+ super.viewDidChangeEffectiveAppearance()
+ sessionLabel.textColor = Palette.of(self).textSecondary
+ strip.needsDisplay = true
+ }
}