fix(settings): read the preview colours from the same tokens as the chrome
The preview still picked its colours by hand: SurfaceHover for the active row where the sidebar uses SurfaceActive, and a plain surface for the pills where the status bar uses SurfaceRaised. Since SurfaceActive was just raised from 0.1 to 0.25, the preview showed a noticeably different active row than the one next to it. It resolves through TokenResolver now. Copying the lerp formulas is how it drifted out of sync to begin with.
This commit is contained in:
@@ -11,6 +11,13 @@ namespace HellionChat.Ui.Components.Settings;
|
||||
|
||||
internal sealed class LivePreviewPanel : IDisposable
|
||||
{
|
||||
// The preview reads the same tokens the real chrome does. Copying their lerp
|
||||
// formulas here is how it drifted out of sync in the first place.
|
||||
private static readonly StyleEngine.TokenResolver Tokens = new();
|
||||
|
||||
private static uint Abgr(StyleEngine.Token token, ThemeColors colors) =>
|
||||
ColourUtil.RgbaToAbgr(Tokens.Resolve(token, colors));
|
||||
|
||||
// Static counter for S5 reload-stress verification: after 10 reloads the
|
||||
// counter must read 0 (plugin disabled) or 1 (plugin enabled). Anything
|
||||
// higher signals a Dispose skip and a subscriber leak against ThemeRegistry.
|
||||
@@ -177,6 +184,8 @@ internal sealed class LivePreviewPanel : IDisposable
|
||||
var rowHeight = MiddleBandHeight / 3f;
|
||||
var surface = ColourUtil.RgbaToAbgr(theme.Colors.Surface);
|
||||
var surfaceHover = ColourUtil.RgbaToAbgr(theme.Colors.SurfaceHover);
|
||||
|
||||
var surfaceActive = Abgr(StyleEngine.Token.SurfaceActive, theme.Colors);
|
||||
var textAbgr = ColourUtil.RgbaToAbgr(theme.Colors.TextPrimary);
|
||||
var primaryAbgr = ColourUtil.RgbaToAbgr(theme.Colors.Primary);
|
||||
var accentAbgr = ColourUtil.RgbaToAbgr(theme.Colors.Accent);
|
||||
@@ -193,7 +202,7 @@ internal sealed class LivePreviewPanel : IDisposable
|
||||
var rowMax = new Vector2(origin.X + SidebarWidth, rowMin.Y + rowHeight);
|
||||
var isActive = i == 0;
|
||||
|
||||
draw.AddRectFilled(rowMin, rowMax, isActive ? surfaceHover : surface);
|
||||
draw.AddRectFilled(rowMin, rowMax, isActive ? surfaceActive : surface);
|
||||
|
||||
if (isActive)
|
||||
draw.AddRectFilled(rowMin, new Vector2(rowMin.X + 2f, rowMax.Y), primaryAbgr);
|
||||
@@ -339,7 +348,7 @@ internal sealed class LivePreviewPanel : IDisposable
|
||||
1f
|
||||
);
|
||||
|
||||
var fill = ColourUtil.RgbaToAbgr(theme.Colors.SurfaceHover);
|
||||
var fill = Abgr(StyleEngine.Token.SurfaceRaised, theme.Colors);
|
||||
var textAbgr = ColourUtil.RgbaToAbgr(theme.Colors.TextPrimary);
|
||||
var pillY = origin.Y + (height - pillH) * 0.5f;
|
||||
|
||||
@@ -387,7 +396,7 @@ internal sealed class LivePreviewPanel : IDisposable
|
||||
);
|
||||
draw.AddText(
|
||||
new Vector2(versionMin.X + padX, pillY + (pillH - versionSize.Y) * 0.5f),
|
||||
ColourUtil.RgbaToAbgr(theme.Colors.TextDim),
|
||||
ColourUtil.RgbaToAbgr(theme.Colors.TextMuted),
|
||||
label
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user