Repository navigation
cmux-next: glass over art keeps main text readable, like iOS, and shows the art #21783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b83f3c1
88cbefa
5679f79
f34aba4
063618a
df0a389
8f50a90
b1de7fb
a3e25a8
0d69ea8
9455e39
8a5ba0b
fd09552
284a488
e2e2a0d
654b0dc
9e7b17b
9863aec
7a78e5e
57f6a05
4e118ef
b90e7cb
de8268d
b0f5c17
8a8dfc0
1dd9656
a7ba4bb
ed2a8c7
3baba45
22dbdc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /// Which text the window's glass keeps readable over background art (`appearance.glassLegibility`). | ||
| /// The glass's tint never goes below the least opacity at which these roles keep their contrast | ||
| /// over the art (``BackdropArtRange``), so this decides how much of the art shows. The live choice | ||
| /// lives on the theme scopes (``ThemeScope/artLegibility``). | ||
| public nonisolated enum ArtLegibility: String, CaseIterable, Sendable { | ||
| /// Primary text at WCAG AA body contrast, as iOS glass does over a wallpaper: secondary and | ||
| /// tertiary text may read below their contrast over the art's brightest or darkest parts, and | ||
| /// much more of the art shows (Leo 2026-10-18: "IOS IOS"). | ||
| case primary | ||
| /// Every text role at its contrast over any part of the art: denser glass. | ||
| case all | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,8 @@ public nonisolated struct WindowBackdrop: Equatable, Sendable { | |
| public var art: BackdropArt? = nil | ||
| /// Optional bundled or system image beneath the material. | ||
| public var selection: BackdropSelection? = nil | ||
| /// The least tint over art at which every text role stays legible | ||
| /// (``ThemeTokens/legibleTintOpacity(over:requested:)``); 0 without art. Neither the opacity setting | ||
| /// The least tint over art at which the text the scope's ``ArtLegibility`` names stays legible | ||
| /// (``ThemeTokens/legibleTintOpacity(over:requested:legibility:)``); 0 without art. Neither the opacity setting | ||
| /// nor the tuner thins the glass below it. | ||
| public var legibleTintOpacity: Double = 0 | ||
| /// The art's own opacity: 1, or ``windowGlassArtOpacity`` under Window Glass (the Clear Glass | ||
|
|
@@ -101,9 +101,11 @@ public nonisolated struct WindowBackdrop: Equatable, Sendable { | |
| /// - Parameter art: Bundled art below the window's material and tint. | ||
| /// - Parameter tintOpacity: A workspace's own tint over art (`ThemeScope.backdropTintOpacity`), | ||
| /// replacing the work's and the window's; the legibility floor still applies. | ||
| /// - Parameter legibility: The text the floor keeps readable over art (`ThemeScope.artLegibility`). | ||
| public init(_ tokens: ThemeTokens, reduceTransparency: Bool = false, art: BackdropArt? = nil, | ||
| selection: BackdropSelection? = nil, tuning: AppearanceTuning = .identity, | ||
| texture: BackdropTexture = .default, tintOpacity workspaceTint: Double? = nil) { | ||
| texture: BackdropTexture = .default, tintOpacity workspaceTint: Double? = nil, | ||
| legibility: ArtLegibility = .primary) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| let resolvedSelection = selection ?? art.map(BackdropSelection.art) | ||
| // A work's own tint replaces the theme's (dark works show more of themselves); the | ||
| // legibility floor below still keeps text readable over it. | ||
|
|
@@ -123,7 +125,7 @@ public nonisolated struct WindowBackdrop: Equatable, Sendable { | |
| if windowGlass { artOpacity = Self.windowGlassArtOpacity } | ||
| if resolvedSelection != nil, !isOpaque { | ||
| let range = windowGlass ? .any : resolvedSelection?.artRange ?? .any | ||
| legibleTintOpacity = tokens.legibleTintOpacity(over: range, requested: 0) | ||
| legibleTintOpacity = tokens.legibleTintOpacity(over: range, requested: 0, legibility: legibility) | ||
| tintOpacity = max(tintOpacity, legibleTintOpacity) | ||
| } | ||
| self.art = art | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| public import CmuxNextDesign | ||
|
|
||
| /// `appearance.glassLegibility` in cmux.json: "primary" (default) or "all", the text the window's | ||
| /// glass keeps readable over background art (``ArtLegibility``). | ||
| public nonisolated struct GlassLegibilitySetting { | ||
| public nonisolated init() {} | ||
| public static let configPath = ["appearance", "glassLegibility"] | ||
| public static let fallback: ArtLegibility = .primary | ||
|
|
||
| /// A missing key is the default with no diagnostic; a bad value is the default plus a diagnostic. | ||
| func parse(_ root: JSONValue) -> (ArtLegibility, SettingsDiagnostic?) { | ||
| guard let value = root.value(at: Self.configPath) else { return (Self.fallback, nil) } | ||
| guard let text = value.stringValue, let legibility = ArtLegibility(rawValue: text) else { | ||
| let choices = ArtLegibility.allCases.map { "\"\($0.rawValue)\"" }.joined(separator: ", ") | ||
| return (Self.fallback, SettingsDiagnostic(kind: .invalidValue, path: "appearance.glassLegibility", | ||
| message: "expected one of \(choices)")) | ||
| } | ||
| return (legibility, nil) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With experimental appearance enabled,
appearance.saturation: 0andappearance.glassTransparency: 1, the new primary-only floor can leave primary text below its promised contrast. The floor uses the originalsurfaceBackground, butWindowMaterialViewpaints a tint with changed saturation.For
ghosttyDefaultover Hokusai, the new floor is 0.63. The gray tint gives white primary text about 4.19:1 contrast over the lightest art color, below 4.5:1. The old all-text floor keeps it above 4.5:1.Compute the floor from the tint color that will actually be painted, and cover this combination in a test.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!