fix(style): the popup text fed RGBA into the contrast helper -- and a guard so this stops recurring

Fifth and sixth occurrences of the same defect in one day, this time in PopupRow
and three spots in the lab. The menu entries and the channel picker were
unreadable at rest on the green theme and only became legible on hover, because
the hover lerp pulls toward a correctly converted accent -- which is exactly the
symptom the tester reported.

The shape of the mistake is always identical: a raw ThemeColors member (RGBA)
handed to EnsureContrast (ABGR). The compiler cannot see it, both layouts are
uint, and a stray extra RgbaToAbgr around the call makes the result look
plausible while measuring a contrast between two colours that are never on
screen.

So this commit is mostly the guard. preflight Block G runs
scripts/verify-colour-channels.sh, which flags any raw theme member in either
argument of EnsureContrast across the UI tree. Falsified before trusting: broken
deliberately, it goes red; and on its very first real run it caught three
offenders in the lab that a hand-rolled grep had missed minutes earlier.
This commit is contained in:
2026-08-19 19:09:22 +02:00
parent d7a308b522
commit 3e46600fc3
4 changed files with 86 additions and 7 deletions
@@ -64,8 +64,10 @@ internal static class PopupRow
accentAbgr
);
var textAbgr = ColourUtil.RgbaToAbgr(
ColourUtil.EnsureContrast(c.TextPrimary, c.ChildBg, 4.5f)
var textAbgr = ColourUtil.EnsureContrast(
ColourUtil.RgbaToAbgr(c.TextPrimary),
ColourUtil.RgbaToAbgr(c.ChildBg),
4.5f
);
if (active || amount > 0f)
textAbgr = ColourUtil.Lerp(textAbgr, accentAbgr, active ? 0.6f : amount * 0.4f);
+19 -5
View File
@@ -178,8 +178,10 @@ internal sealed class InputBarLabWindow : Window
{
var glyph = icon.ToIconString();
var size = ImGui.CalcTextSize(glyph);
var tint = ColourUtil.RgbaToAbgr(
ColourUtil.EnsureContrast(c.TextPrimary, c.ChildBg, 4.5f)
var tint = ColourUtil.EnsureContrast(
ColourUtil.RgbaToAbgr(c.TextPrimary),
ColourUtil.RgbaToAbgr(c.ChildBg),
4.5f
);
if (amount > 0f)
tint = ColourUtil.Lerp(tint, accent, amount);
@@ -286,7 +288,11 @@ internal sealed class InputBarLabWindow : Window
break;
}
var ink = ColourUtil.RgbaToAbgr(ColourUtil.EnsureContrast(c.WindowBg, c.Accent, 4.5f));
var ink = ColourUtil.EnsureContrast(
ColourUtil.RgbaToAbgr(c.WindowBg),
ColourUtil.RgbaToAbgr(c.Accent),
4.5f
);
using (fonts.FontAwesome.Push())
{
var arrow = FontAwesomeIcon.ArrowRight.ToIconString();
@@ -333,7 +339,11 @@ internal sealed class InputBarLabWindow : Window
var max = origin + new Vector2(width, height);
var dl = ImGui.GetWindowDrawList();
var accent = ColourUtil.RgbaToAbgr(ColourUtil.EnsureContrast(c.Accent, c.ChildBg, 4.5f));
var accent = ColourUtil.EnsureContrast(
ColourUtil.RgbaToAbgr(c.Accent),
ColourUtil.RgbaToAbgr(c.ChildBg),
4.5f
);
// The band variant is the one the mockup drew and v1.11.0 abandoned.
// Here at a fraction of the strength, as a tint rather than a plate --
@@ -388,7 +398,11 @@ internal sealed class InputBarLabWindow : Window
var width = dl.DrawTrackedText(
pos,
text,
ColourUtil.RgbaToAbgr(ColourUtil.EnsureContrast(c.TextMuted, c.WindowBg, 4.5f)),
ColourUtil.EnsureContrast(
ColourUtil.RgbaToAbgr(c.TextMuted),
ColourUtil.RgbaToAbgr(c.WindowBg),
4.5f
),
1.6f * Metrics.Scale
);