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:
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user