refactor(theme): extract ChildBgAlpha threshold logic to testable helper (F1.2)

HellionStyle.PushGlobal had two lines that resolved the child-bg alpha
based on window opacity. Moves the 0.999f threshold and the alpha-mask
into HellionStyleHelpers.ResolveChildBgAlpha so the logic is reachable
from the build suite without touching the ImGui surface.
This commit is contained in:
2026-05-12 18:19:15 +02:00
parent dd597fca44
commit 28ea2fa553
2 changed files with 21 additions and 7 deletions
+4 -7
View File
@@ -43,13 +43,10 @@ internal static class HellionStyle
var alphaByte = (uint)Math.Clamp((int)(windowOpacity * 255f), 0x55, 0xFF); var alphaByte = (uint)Math.Clamp((int)(windowOpacity * 255f), 0x55, 0xFF);
var windowBgWithAlpha = (c.WindowBg & 0xFFFFFF00u) | alphaByte; var windowBgWithAlpha = (c.WindowBg & 0xFFFFFF00u) | alphaByte;
// ChildBg alpha: child areas rendered inside ChatLogWindow would // ChildBg alpha resolution lives in HellionStyleHelpers so the
// multiply their alpha with WindowBg, making 50% opacity appear // threshold logic can be covered by a pure-helper test in the
// ~75% solid. At full opacity the theme's alpha is preserved; below // build suite.
// it ChildBg goes fully transparent so only WindowBg sets the final var childBgWithAlpha = HellionStyleHelpers.ResolveChildBgAlpha(c.ChildBg, windowOpacity);
// coverage.
var childBgAlpha = windowOpacity >= 0.999f ? (c.ChildBg & 0xFFu) : 0u;
var childBgWithAlpha = (c.ChildBg & 0xFFFFFF00u) | childBgAlpha;
// Layout // Layout
stack.PushStyleVar(ImGuiStyleVar.WindowRounding, l.WindowRounding); stack.PushStyleVar(ImGuiStyleVar.WindowRounding, l.WindowRounding);
+17
View File
@@ -0,0 +1,17 @@
namespace HellionChat.Ui;
internal static class HellionStyleHelpers
{
// Child surfaces are drawn over WindowBg, so at partial window opacity
// the theme's own ChildBg alpha would double-multiply and read too solid.
// Above ~full opacity we preserve the theme alpha; below it we wipe to 0
// so WindowBg alone carries the coverage. The 0.999f threshold is a
// float-imprecision guard around the user-facing 100% slider value.
// TEST-MIRROR: ../../Hellion Build test/_Helpers/HellionStyleHelpersTests.cs
public static uint ResolveChildBgAlpha(uint themeChildBgRgba, float windowOpacity)
{
var alphaPreserved = windowOpacity >= 0.999f;
var childBgAlpha = alphaPreserved ? (themeChildBgRgba & 0xFFu) : 0u;
return (themeChildBgRgba & 0xFFFFFF00u) | childBgAlpha;
}
}