Refactor/opacity model - unified opacity setting - #903
Open
MalpenZibo wants to merge 4 commits into
Open
Conversation
Opacity was a property of every colour a widget painted, so each call site applied it and any two overlapping layers composed it. It is now applied once when the theme is built, to the palette itself. iced already marks which colours are paint and which are ink: in a `palette::Pair`, `color` is drawn behind content and `text` goes on top of it. So the rule is total — every `color` takes the opacity, every `text` stays opaque — and no call site has to ask for a translucent colour. Whatever it reads is already right. `Palette::background` carries it too, since `Palette` is the convenient accessor for the common case and that is the one colour on it that is paint. Its accents stay opaque because on the base palette they are read as ink, for text and icons; an accent used as paint comes from the extended palette, where it does carry the opacity. The extended set is generated from an opaque copy of the background: `mix` interpolates alpha as well, so deriving from the translucent one would spread assorted alphas across the variants (mixing an opaque accent with a 0.8 background yields 0.9) instead of every background landing on the configured value. Config: `appearance.bar.opacity` and `appearance.menu.opacity` are replaced by a single `appearance.opacity`. Breaking for anyone setting either. Fixes five defects that all came from the same root: - Hovering a bar module painted a second full background over the group pill, taking 0.8 to 0.8 + 0.8 * 0.2 = 0.96. Hover is now a small fixed overlay. - Notification cards applied the opacity on hover but not at rest, so they were opaque until the pointer touched them and any blur behind them only appeared on hover. - Sub-menus, the weather card and the media player card read the *bar* opacity while living on the menu surface, and stacked it on the menu's own background. - The active quick-settings button mixed in the raw seed accent, which never carried the opacity. - The OSD background was hardcoded opaque and now follows the setting like every other surface. `hovered()` composites an interaction overlay into a single colour, which is a separate concern from opacity and the only helper left.
`appearance.bar.opacity` and `appearance.menu.opacity` are gone, so the pages that described them now describe one `appearance.opacity` covering every surface, and the blur table reads against that instead of the two. The rest of what this commit used to carry -- the BlurMode enum and its docs -- landed in #866 instead, so the config key would not change shape twice.
Two more buttons had the defect already fixed for the bar modules: they paint no background at rest, so the surface shows through, and then paint a *full* background on hover. The two layers compose, taking a 0.8 surface to 0.8 + 0.8 * 0.2 = 0.96 and washing out both the translucency and any blur behind it. - `ButtonKind::Outline`, which is what the calendar's "back to today" button uses, and where this is most visible. - The quick-settings submenu button. Both now add a small overlay instead, matching `ButtonKind::Transparent` and the bar modules. The rule that separates the two cases: a widget transparent at rest must add an overlay on hover, while one that already paints its own background at rest is a card and may keep swapping it — the second layer is there either way, so hovering it does not shift the opacity.
The comments explaining the opacity model were written at the length of the discussion that produced them, not the length the codebase uses. Cut to the non-obvious "why" and one line each, matching the surrounding style.
MalpenZibo
marked this pull request as ready for review
August 5, 2026 07:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.