feat(style): add a scale-aware metrics layer

Layout constants lived as bare floats in the components: row heights, hit
widths, insets, reserve widths. None of them multiplied by GlobalScale, so at
125% or 150% display scaling the text grows and the boxes do not. The quick
buttons stop fitting into their 130px column.

Metrics holds the design values and exposes scaled properties. The Raw
constants stay reachable for the few places that must store or compare an
unscaled value: Sidebar.GetWidth (a SelfTest pins it against raw numbers) and
the width slider bounds.

Scale is pinned once per frame against ImGui.GetFrameCount(). GlobalScale is a
live value the Dalamud slider moves on every dragged frame, so reading it per
access can shift a CalcSize away from its matching Draw inside one frame, and
costs three native calls each time.

Not in ThemeLayout: that record is serialised into theme JSON, and layout
customisation is out of scope per the master spec.

MetricsMath is the pure half so the build suite can pin the arithmetic. Text
heights are measured rather than scaled -- the font is built from
Config.FontSizeV2, which GlobalScale does not feed into.
This commit is contained in:
2026-08-17 23:34:08 +02:00
parent 0ef33934a2
commit 28b97b3f70
2 changed files with 125 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
namespace HellionChat.Util;
// Pure scaling arithmetic, split out from Metrics so the build suite can pin it
// without standing up an ImGui frame.
internal static class MetricsMath
{
internal static float Scale(float raw, float scale) => raw * scale;
// Vertical centering for text inside a fixed-height row. Frozen offsets keep
// their mis-centering at every other font size; a computed one does not.
internal static float CenterY(float rowHeight, float textHeight) =>
(rowHeight - textHeight) * 0.5f;
}