diff --git a/HellionChat/Ui/Components/Settings/Tabs/ChannelsTab.cs b/HellionChat/Ui/Components/Settings/Tabs/ChannelsTab.cs index 4e1e338..38398a8 100644 --- a/HellionChat/Ui/Components/Settings/Tabs/ChannelsTab.cs +++ b/HellionChat/Ui/Components/Settings/Tabs/ChannelsTab.cs @@ -63,15 +63,16 @@ internal sealed class ChannelsTab if (ImGui.CollapsingHeader("Sidebar")) { - // Range matches Sidebar.MinSidebarWidth/MaxSidebarWidth (40-300). The - // lower bound sits just above the 38px icon-only threshold; the - // on-disk default (44) and the 150px expanded reference both fit. + // Bounds come from the constants rather than repeating the numbers, + // so the slider cannot drift away from the clamp in Sidebar.GetWidth. + // The stored value is unscaled; display scaling is applied where the + // sidebar is drawn. DrawSliderInt( "Sidebar width", () => Plugin.Config.SidebarWidth, v => Plugin.Config.SidebarWidth = v, - 40, - 300 + (int)Sidebar.MinSidebarWidth, + (int)Sidebar.MaxSidebarWidth ); } } diff --git a/HellionChat/Ui/Components/Sidebar.cs b/HellionChat/Ui/Components/Sidebar.cs index fcbd0fe..0886e1d 100644 --- a/HellionChat/Ui/Components/Sidebar.cs +++ b/HellionChat/Ui/Components/Sidebar.cs @@ -27,9 +27,9 @@ internal sealed class Sidebar public const float MinSidebarWidth = 40f; public const float MaxSidebarWidth = 300f; - private const float RowHeight = 32f; - private const float PopOutHitWidth = 22f; - private const float GreetedHitWidth = 22f; + private static float RowHeight => Metrics.SidebarRowHeight; + private static float PopOutHitWidth => Metrics.SidebarPopOutHitWidth; + private static float GreetedHitWidth => Metrics.SidebarGreetedHitWidth; // B3-2 render observability: counts greeted glyphs actually drawn this frame. // Incremented ONLY in the real glyph branch in DrawRow; reset at Draw start. @@ -85,6 +85,10 @@ internal sealed class Sidebar _pool = pool; } + // Both stay unscaled. The stored width and the switch threshold are user + // settings in design pixels, and SidebarModeAutoSwitchStep compares this + // return value against the raw bounds. Display scaling is applied once, at + // the single draw call site below. public bool IsExpanded(float windowWidth) => windowWidth >= Plugin.Config.SidebarAutoSwitchThresholdPx; @@ -111,12 +115,15 @@ internal sealed class Sidebar if (!_fonts.FontsReady) { - ImGui.Dummy(new Vector2(IconOnlyWidth, 0)); + // A scale change triggers a font rebuild, so this branch is really + // hit while GlobalScale is moving -- an unscaled width here makes + // the sidebar jump. + ImGui.Dummy(new Vector2(Metrics.SidebarIconOnlyWidth, 0)); return; } var expanded = IsExpanded(windowWidth); - var width = GetWidth(windowWidth); + var width = GetWidth(windowWidth) * Metrics.Scale; using var child = ImRaii.Child("##hellion-sidebar", new Vector2(width, 0)); if (!child.Success) return;