Toolbar size: let players enlarge the in-game ImGui bar

The bar's buttons are a fixed 20 logical px and the only multiplier is the
DPI scale, which is 1 for a DPI-unaware acclient, so the icons cannot be
made bigger. This adds a separate "chrome" row to PanelTextScale that the
bar draws at: it uses the existing baked enlarged fonts (icons stay sharp)
and scales the button size by the same step's factor. Tooltips and menus
opened from the bar inherit it.

- PanelTextScale: __chrome row with GetChrome/SetChrome; StepsInUse bakes it
  even with per-panel sizing off; SetForWindow's reset loop skips it;
  RYNTHCORE_PANEL_TEXT_SIZE overrides the file path for tests.
- ImGuiBar: grip right-click size row (- / + / Reset), Ctrl+wheel over the
  bar, and an on-screen clamp when the bar grows. A clamp only persists the
  position when the user dragged or the size changed, so a smaller AC
  window never overwrites the saved position.
- Settings > Display > Text Size: "Toolbar" combo.
- /rc ui barsize [0-10|+|-|+n|-n|status].
- tools/PanelTextScaleTests: offline tests for the chrome row.

Untouched: FontScale/_uiScale, placement scale, the plugin SDK, pop-out
styling and panel title bars.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-10-10 12:43:54 -07:00
commit 98316c1969
6 changed files with 351 additions and 14 deletions

View file

@ -27,6 +27,9 @@ namespace RynthCore.Engine.Compatibility;
/// <item><c>/rc ui retailvitals [on|off|status]</c> — hide AC's own
/// health/stamina/mana bars (<see cref="RetailVitalsHooks"/>; saved for the
/// PC, also in Settings &gt; UI). Alone it reports the state.</item>
/// <item><c>/rc ui barsize [0-10|+|-|status]</c> - the RynthCore bar's size (its own text
/// size step, <see cref="UI.PanelTextScale"/>; saved for the PC, also in Settings &gt;
/// Display). Alone it reports the size.</item>
/// <item><c>/rc vendor [list|info|status|buy &lt;id|sel&gt; [n]|sell &lt;id|sel&gt; [id ...]]</c>
/// — read / trade with the open vendor through the engine's vendor
/// primitives (<see cref="VendorTrade"/>); a manual test hook for the
@ -383,6 +386,29 @@ internal static class RynthCoreChatCommands
return;
}
// /rc ui barsize [0-10|+|-|status]: the bar's size. Alone it reports it.
if (parts[0].Equals("barsize", StringComparison.OrdinalIgnoreCase))
{
int cur = UI.PanelTextScale.GetChrome();
if (parts.Length >= 2 && !parts[1].Equals("status", StringComparison.OrdinalIgnoreCase))
{
int next;
// Bare + / -: one step. +n / -n: that many steps. Plain n: that size.
if (parts[1] == "+") next = cur + 1;
else if (parts[1] == "-") next = cur - 1;
else if (!int.TryParse(parts[1], System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out next))
{
Reply("Usage: /rc ui barsize [0-10|+|-|status]");
return;
}
else if (parts[1][0] is '+' or '-')
next += cur;
UI.PanelTextScale.SetChrome(next);
}
Reply("Bar size: " + UI.PanelTextScale.Describe(UI.PanelTextScale.GetChrome()) + ".");
return;
}
// /rc ui open|close|popout|redock|snap <Panel>: drive a panel by name (tests,
// dispatch.txt). Names may have spaces ("Monster Detail").
string verb = parts[0].ToLowerInvariant();
@ -415,7 +441,7 @@ internal static class RynthCoreChatCommands
if (parts.Length != 2 || !UI.PanelFaceStore.TryParseFace(parts[1], out UI.PanelFace face))
{
Reply("Usage: /rc ui list | /rc ui <Panel|bar> avalonia|imgui|both | /rc ui open|close|popout|redock|snap <Panel> | /rc ui retailvitals [on|off]");
Reply("Usage: /rc ui list | /rc ui <Panel|bar> avalonia|imgui|both | /rc ui open|close|popout|redock|snap <Panel> | /rc ui retailvitals [on|off] | /rc ui barsize [0-10|+|-|status]");
return;
}

View file

@ -13,6 +13,11 @@
// returns it); a bar whose face is Avalonia/Both still pops out as the
// Avalonia bar.
//
// The bar's size is its own text size step (PanelTextScale chrome row): the bar's
// fonts come from that baked set and its metrics scale by the step's factor. Set it
// from the grip's right-click menu, Ctrl+wheel over the bar, Settings > Display or
// /rc ui barsize.
//
// Face key "__bar" in panel_faces.txt; code default Avalonia. While the ImGui
// bar shows, the docked Avalonia bar is hidden and takes no clicks
// (AvaloniaOverlay.DockedBarSuppressed). AC thread except where noted.
@ -87,10 +92,26 @@ internal static class ImGuiBar
// Square buttons, logical px (x the DPI scale).
private const float ButtonSize = 20f, ButtonGap = 3f;
/// <summary>
/// The bar's text size step (the nearest one already baked) and its scale factor. The one
/// place either is worked out, so the bar's fonts and its metrics always agree.
/// </summary>
private static int ChromeStep(out float factor)
{
int step = ImGuiFonts.BakedStepNear(PanelTextScale.GetChrome());
factor = PanelTextScale.Factor(step);
return step;
}
private static ButtonInfo[]? _buttons;
private static string _tooltip = "";
private static bool _placed;
private static Vector2 _pos, _persistedPos;
// What may write a new position to the bar= row: the user dragging the grip, or the bar being
// pulled back on screen by a size change (a few frames: the window grows a frame late). A clamp
// from a smaller AC window leaves the saved position alone.
private static bool _userMoved;
private static int _lastStep, _sizeWatch;
private const string PopOutTitle = "__bar";
// Popped out (the ImGui bar in its own window). Read from panel_state once,
@ -173,12 +194,15 @@ internal static class ImGuiBar
private static void DrawPopped(float s, Vector2 display)
{
EnsureButtons();
int step = ChromeStep(out float factor);
s *= factor;
float place = AvaloniaOverlay.InputScale > 0 ? AvaloniaOverlay.InputScale : 1f;
ImGuiNET.ImGui.SetNextWindowPos(ImGuiPopOuts.PanelOrigin, ImGuiCond.Always);
PushBarWindowStyle(s);
ImGuiNET.ImGui.Begin("##rc_bar", BarFlags);
try
{
ImGuiFonts.CurrentStep = step;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
DrawContent(s, place, popped: true);
ImGuiNET.ImGui.PopFont();
@ -189,6 +213,7 @@ internal static class ImGuiBar
}
finally
{
ImGuiFonts.CurrentStep = 0;
ImGuiNET.ImGui.End();
PopBarWindowStyle();
}
@ -218,6 +243,8 @@ internal static class ImGuiBar
public static void Draw(float s)
{
EnsureButtons();
int step = ChromeStep(out float factor);
s *= factor;
float place = AvaloniaOverlay.InputScale > 0 ? AvaloniaOverlay.InputScale : 1f;
bool both = ResolveFace() == PanelFace.Both;
@ -229,18 +256,23 @@ internal static class ImGuiBar
_pos = _persistedPos = logical * place;
ImGuiNET.ImGui.SetNextWindowPos(_pos, ImGuiCond.Always);
_placed = true;
_lastStep = step; // the size the bar loads at is the baseline, not a change
}
if (step != _lastStep) { _lastStep = step; _sizeWatch = 4; }
PushBarWindowStyle(s);
ImGuiNET.ImGui.Begin("##rc_bar", BarFlags);
try
{
ImGuiFonts.CurrentStep = step;
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
DrawContent(s, place, popped: false);
ImGuiNET.ImGui.PopFont();
KeepOnScreen();
}
finally
{
ImGuiFonts.CurrentStep = 0;
_pos = ImGuiNET.ImGui.GetWindowPos();
ImGuiNET.ImGui.End();
PopBarWindowStyle();
@ -249,15 +281,35 @@ internal static class ImGuiBar
if (!ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left) && _pos != _persistedPos)
{
_persistedPos = _pos;
Vector2 logical = _pos / place - (both ? new Vector2(24, 24) : Vector2.Zero);
double left = logical.X, top = logical.Y;
UiBackgroundWriter.Enqueue("persist bar", () => PanelStateStore.SetBarPosition(left, top));
if (!both) AvaloniaOverlay.SyncDockedBarPosition(left, top);
if (_userMoved || _sizeWatch > 0)
{
Vector2 logical = _pos / place - (both ? new Vector2(24, 24) : Vector2.Zero);
double left = logical.X, top = logical.Y;
UiBackgroundWriter.Enqueue("persist bar", () => PanelStateStore.SetBarPosition(left, top));
if (!both) AvaloniaOverlay.SyncDockedBarPosition(left, top);
}
_userMoved = false;
}
if (_sizeWatch > 0) _sizeWatch--;
}
/// <summary>A bigger size can push the bar's right end off the screen: pull it back (not while it is being dragged).</summary>
private static void KeepOnScreen()
{
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
if (display.X <= 1 || ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left)) return;
Vector2 pos = ImGuiNET.ImGui.GetWindowPos();
Vector2 next = Vector2.Clamp(pos, Vector2.Zero, Vector2.Max(Vector2.Zero, display - ImGuiNET.ImGui.GetWindowSize()));
if (next != pos) ImGuiNET.ImGui.SetWindowPos(next);
}
private static void DrawContent(float s, float place, bool popped)
{
// Ctrl+wheel over the bar steps its size (the panels' title bars do the same).
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
if (io.KeyCtrl && io.MouseWheel != 0f && ImGuiNET.ImGui.IsWindowHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem))
PanelTextScale.SetChrome(PanelTextScale.GetChrome() + (io.MouseWheel > 0f ? 1 : -1));
var square = new Vector2(ButtonSize, ButtonSize) * s;
var dl = ImGuiNET.ImGui.GetWindowDrawList();
ImFontPtr iconFont = ImGuiFonts.Get(UiFont.Ui14);
@ -280,12 +332,13 @@ internal static class ImGuiBar
if (display.X > 1)
next = Vector2.Clamp(next, Vector2.Zero, Vector2.Max(Vector2.Zero, display - size));
ImGuiNET.ImGui.SetWindowPos(next);
_userMoved = true;
}
ImGuiNET.ImGui.SetItemTooltip(_tooltip);
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right))
ImGuiNET.ImGui.OpenPopup("##face_bar");
PhosphorIcons.DrawCentered(dl, iconFont, PhosphorIcons.DotsSixVertical, rcPos, new Vector2(square.X * 0.8f, square.Y), RynthTheme.RcLabel);
FacePopup("##face_bar", FaceKey, hasImGuiFace: true);
FacePopup("##face_bar", FaceKey, hasImGuiFace: true, s);
// Collapse: the bar folds to its grip and this caret.
bool collapsed = RynthAiDashboardState.BarCollapsed;
@ -394,7 +447,7 @@ internal static class ImGuiBar
return clicked;
}
private static void FacePopup(string popupId, string title, bool hasImGuiFace)
private static void FacePopup(string popupId, string title, bool hasImGuiFace, float s = 1f)
{
if (!ImGuiNET.ImGui.BeginPopup(popupId)) return;
ImGuiNET.ImGui.TextDisabled(title == FaceKey ? "Bar, docked, shows as" : "Docked, shows as");
@ -407,9 +460,46 @@ internal static class ImGuiBar
}
if (!hasImGuiFace)
ImGuiNET.ImGui.TextDisabled("(no ImGui version yet)");
if (title == FaceKey)
BarSizeRows(s);
ImGuiNET.ImGui.EndPopup();
}
/// <summary>The bar's own popup: smaller / bigger, the current size, reset (the panels' text size popup, for the bar).</summary>
private static void BarSizeRows(float s)
{
int step = PanelTextScale.GetChrome();
int max = PanelTextScale.SizeNames.Length - 1;
float btn = ButtonSize * s;
ImFontPtr iconFont = ImGuiFonts.Get(UiFont.Ui14);
uint text = ImGuiNET.ImGui.GetColorU32(ImGuiCol.Text);
ImGuiNET.ImGui.Separator();
ImGuiNET.ImGui.TextUnformatted("Bar size");
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
ImGuiNET.ImGui.BeginDisabled(step <= 0);
if (IconButton("##bs_smaller", iconFont, PhosphorIcons.Minus, new Vector2(btn, btn), text))
PanelTextScale.SetChrome(step - 1);
ImGuiNET.ImGui.EndDisabled();
ImGuiNET.ImGui.SetItemTooltip("Smaller");
ImGuiNET.ImGui.SameLine(0, 4 * s);
ImGuiNET.ImGui.BeginDisabled(step >= max);
if (IconButton("##bs_bigger", iconFont, PhosphorIcons.Plus, new Vector2(btn, btn), text))
PanelTextScale.SetChrome(step + 1);
ImGuiNET.ImGui.EndDisabled();
ImGuiNET.ImGui.SetItemTooltip("Bigger");
ImGuiNET.ImGui.PopStyleVar();
ImGuiNET.ImGui.SameLine(0, 8 * s);
ImGuiNET.ImGui.AlignTextToFramePadding();
ImGuiNET.ImGui.TextUnformatted(PanelTextScale.Describe(step));
ImGuiNET.ImGui.BeginDisabled(step == 0);
if (ImGuiNET.ImGui.Button(PhosphorIcons.ArrowCounterClockwise + " Reset"))
PanelTextScale.SetChrome(0);
ImGuiNET.ImGui.EndDisabled();
ImGuiNET.ImGui.SetItemTooltip("Back to normal size");
}
private static void PushBarButtonStyle(float s)
{
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, Vector2.Zero);
@ -446,6 +536,6 @@ internal static class ImGuiBar
list.Add(new ButtonInfo(title, "##bar_" + title, "##face_" + title, icon, letter, title, ImGuiOnly: true));
}
_buttons = list.ToArray();
_tooltip = $"RynthCore {EntryPoint.BuildStamp}\nDrag here to move the bar. Right-click: bar face.";
_tooltip = $"RynthCore {EntryPoint.BuildStamp}\nDrag here to move the bar. Right-click: bar face and size. Ctrl+wheel over the bar: size.";
}
}

View file

@ -462,6 +462,8 @@ internal static class SettingsSchema
Section("Text Size (in-game panels)"),
Combo("All Panels", PanelTextScale.SizeNames, _ => PanelTextScale.GetAll(), (_, v) => PanelTextScale.SetAll(v),
"Text size for every in-game panel: 0 = normal, each step 10% bigger, yourjokin = 2.5x."),
Combo("Toolbar", PanelTextScale.SizeNames, _ => PanelTextScale.GetChrome(), (_, v) => PanelTextScale.SetChrome(v),
"Size of the RynthCore icon bar (its icons and tooltips), separate from the panels: 0 = normal, each step 10% bigger.\nAlso: right-click the bar's grip, Ctrl+wheel over the bar, or /rc ui barsize."),
Bool("Size Each Panel Separately", _ => PanelTextScale.PerPanel, (_, v) => PanelTextScale.PerPanel = v,
"Off: every panel uses All Panels. On: set each panel's text size below.", gates: true),
TextSize("RynthAi Dashboard", "RynthAi"),

View file

@ -6,7 +6,9 @@
// as "Title=size" lines; set from Settings > Display or from a window's own
// title bar (the text size button, Ctrl+wheel; ImGuiPanelHost). One size
// ("All Panels") applies to every panel unless "Size each panel separately"
// is on.
// is on. The toolbar (the icon bar, ImGuiBar) has its own size, the "chrome"
// row (Settings > Display > Toolbar, the bar's right-click menu, Ctrl+wheel on
// the bar, /rc ui barsize); it is independent of All Panels and per-panel sizes.
// ============================================================================
using System;
@ -27,11 +29,16 @@ internal static class PanelTextScale
private static readonly Dictionary<string, int> Sizes = new(StringComparer.OrdinalIgnoreCase);
private static bool _loaded;
private static string FilePath => Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RynthCore", "panel_text_size.txt");
// RYNTHCORE_PANEL_TEXT_SIZE points a test at its own file instead of the real one.
private static readonly string FilePath =
Environment.GetEnvironmentVariable("RYNTHCORE_PANEL_TEXT_SIZE") is { Length: > 0 } overridePath
? overridePath
: Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RynthCore", "panel_text_size.txt");
private const string AllKey = "__all";
private const string PerPanelKey = "__perPanel";
private const string ChromeKey = "__chrome";
/// <summary>The size (0-10) a panel is drawn at: its own when sizing per panel, else All Panels.</summary>
public static int Get(string title)
@ -59,6 +66,18 @@ internal static class PanelTextScale
public static int GetAll() => GetOwn(AllKey);
public static void SetAll(int size) => Set(AllKey, size);
/// <summary>The toolbar's size (0-10): its own row, 0 unless set; never All Panels.</summary>
public static int GetChrome()
{
lock (Sync)
{
Load();
return Sizes.TryGetValue(ChromeKey, out int c) ? c : 0;
}
}
public static void SetChrome(int size) => Set(ChromeKey, size);
/// <summary>Off: every panel uses All Panels. On: each panel has its own size.</summary>
public static bool PerPanel
{
@ -108,7 +127,7 @@ internal static class PanelTextScale
// effect: start them from what every panel shows now.
var keys = new List<string>(Sizes.Keys);
foreach (string k in keys)
if (k != AllKey && k != PerPanelKey) Sizes[k] = all;
if (k != AllKey && k != PerPanelKey && k != ChromeKey) Sizes[k] = all;
Sizes[PerPanelKey] = 1;
}
Sizes[title] = size;
@ -145,7 +164,7 @@ internal static class PanelTextScale
/// <summary>Font size factor for a size step.</summary>
public static float Factor(int step) => Scales[Math.Clamp(step, 0, Scales.Length - 1)];
/// <summary>The distinct non-zero sizes any panel uses (fonts are baked for these).</summary>
/// <summary>The distinct non-zero sizes any panel or the toolbar uses (fonts are baked for these).</summary>
public static List<int> StepsInUse()
{
lock (Sync)
@ -156,7 +175,7 @@ internal static class PanelTextScale
foreach (var kv in Sizes)
{
if (kv.Key == PerPanelKey) continue;
if (!perPanel && kv.Key != AllKey) continue; // only All Panels is in use
if (!perPanel && kv.Key != AllKey && kv.Key != ChromeKey) continue; // All Panels and the toolbar are in use
if (kv.Value > 0 && !steps.Contains(kv.Value)) steps.Add(kv.Value);
}
return steps;

View file

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the toolbar's text size (the "chrome" row of PanelTextScale).
src\RynthCore.Engine\UI\PanelTextScale.cs, compiled in, with a stub ImGuiFonts. The toolbar's
row must survive a window being sized (SetForWindow's reset loop), be baked even when sizing
per panel is off (StepsInUse), be left alone by All Panels changes, stay unbaked at 0, clamp,
and round-trip through the file. PanelTextScale reads its file path once per process, so each
case runs in a child process pointed at a temp file with RYNTHCORE_PANEL_TEXT_SIZE. Never
touches %LOCALAPPDATA%\RynthCore.
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>PanelTextScaleTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\src\RynthCore.Engine\UI\PanelTextScale.cs" Link="Engine\PanelTextScale.cs" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,174 @@
using System.Diagnostics;
using RynthCore.Engine.UI;
namespace RynthCore.Engine.ImGuiBackend
{
/// <summary>Stub of the engine's fonts: counts the re-bake requests PanelTextScale makes.</summary>
internal static class ImGuiFonts
{
internal static int Rebuilds;
internal static void RequestRebuild(int delayMs = 0) => Rebuilds++;
}
}
namespace PanelTextScaleTests
{
// Offline tests for the toolbar text size. See the csproj.
internal static class Program
{
private static int _fails, _asserts;
private static void Check(bool cond, string msg)
{
_asserts++;
if (!cond) { _fails++; Console.WriteLine($" [FAIL] {msg}"); }
}
private static void Eq<T>(T actual, T expected, string msg) =>
Check(EqualityComparer<T>.Default.Equals(actual, expected), $"{msg}: expected '{expected}', got '{actual}'");
// case name -> the file it starts from (null = no file)
private static readonly (string Name, string? Seed, Action Body)[] Cases =
{
("ChromeSurvivesSetForWindow", "__all=2\n__chrome=3\n", ChromeSurvivesSetForWindow),
("StepsInUseHasChromeWhenPerPanelOff", "__all=0\n__chrome=3\n", StepsInUseHasChromeWhenPerPanelOff),
("UseForAllAndSetAllLeaveChromeAlone", "__chrome=3\n", UseForAllAndSetAllLeaveChromeAlone),
("ChromeZeroIsNotBaked", "__all=0\n__chrome=0\n", ChromeZeroIsNotBaked),
("ChromeDoesNotFallBackToAll", "__all=5\n", ChromeDoesNotFallBackToAll),
("ChromeClamps", null, ChromeClamps),
("RoundTripWrite", null, RoundTripWrite),
("RoundTripRead", null, RoundTripRead),
};
private static int Main(string[] args)
{
if (args.Length > 1 && args[0] == "--child")
{
foreach (var c in Cases)
if (c.Name == args[1]) { c.Body(); return _fails == 0 && _asserts > 0 ? 0 : 1; }
Console.WriteLine(" [FAIL] unknown case " + args[1]);
return 1;
}
string root = Path.Combine(Path.GetTempPath(), "rynth-panel-text-tests-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(root);
int fails = 0;
try
{
foreach (var c in Cases)
{
if (c.Name == "RoundTripRead") continue; // run right after RoundTripWrite, on its file
string file = Path.Combine(root, c.Name + ".txt");
if (c.Seed != null) File.WriteAllText(file, c.Seed);
Console.WriteLine(c.Name);
bool ok = RunChild(c.Name, file);
if (ok && c.Name == "RoundTripWrite")
{
Console.WriteLine("RoundTripRead");
ok = RunChild("RoundTripRead", file);
}
if (!ok) fails++;
}
}
finally
{
try { Directory.Delete(root, true); } catch { }
}
Console.WriteLine();
Console.WriteLine(fails == 0 ? "PASS" : $"FAIL ({fails} case(s) failed)");
return fails == 0 ? 0 : 1;
}
private static bool RunChild(string name, string file)
{
var psi = new ProcessStartInfo(Environment.ProcessPath!)
{
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
};
psi.ArgumentList.Add("--child");
psi.ArgumentList.Add(name);
psi.Environment["RYNTHCORE_PANEL_TEXT_SIZE"] = file;
using Process p = Process.Start(psi)!;
string output = p.StandardOutput.ReadToEnd() + p.StandardError.ReadToEnd();
p.WaitForExit();
if (output.Length > 0) Console.Write(output);
return p.ExitCode == 0;
}
private static string[] Lines(string? file = null) =>
File.ReadAllLines(file ?? Environment.GetEnvironmentVariable("RYNTHCORE_PANEL_TEXT_SIZE")!);
// Sizing one window with per-panel off rewrites every other row to the All
// Panels size; the toolbar's row is not a panel and must keep its own.
private static void ChromeSurvivesSetForWindow()
{
PanelTextScale.SetForWindow("Radar", 4);
Eq(PanelTextScale.GetChrome(), 3, "chrome after SetForWindow (per-panel off)");
Check(Lines().Contains("__chrome=3"), "chrome row still 3 in the file");
Eq(PanelTextScale.GetOwn("Radar"), 4, "the window itself did change");
Check(PanelTextScale.PerPanel, "SetForWindow switched per-panel on");
Eq(PanelTextScale.Get("Other"), 2, "other panels stay at All Panels");
}
// Per-panel off: StepsInUse used to skip every non-All row, so the toolbar's
// size would never have been baked.
private static void StepsInUseHasChromeWhenPerPanelOff()
{
Check(!PanelTextScale.PerPanel, "per-panel is off");
Eq(PanelTextScale.GetAll(), 0, "All Panels is 0");
var steps = PanelTextScale.StepsInUse();
Check(steps.Contains(3), "StepsInUse contains the chrome step 3 (got [" + string.Join(",", steps) + "])");
Eq(steps.Count, 1, "and nothing else");
}
private static void UseForAllAndSetAllLeaveChromeAlone()
{
PanelTextScale.UseForAll(5);
Eq(PanelTextScale.GetChrome(), 3, "chrome after UseForAll(5)");
PanelTextScale.SetAll(2);
Eq(PanelTextScale.GetChrome(), 3, "chrome after SetAll(2)");
Eq(PanelTextScale.GetAll(), 2, "All Panels did change");
var steps = PanelTextScale.StepsInUse();
Check(steps.Contains(3) && steps.Contains(2), "both steps baked (got [" + string.Join(",", steps) + "])");
}
private static void ChromeZeroIsNotBaked()
{
Eq(PanelTextScale.StepsInUse().Count, 0, "nothing in use with chrome 0 and All 0");
PanelTextScale.SetChrome(3);
Check(PanelTextScale.StepsInUse().Contains(3), "chrome 3 baked");
PanelTextScale.SetChrome(0);
Eq(PanelTextScale.StepsInUse().Count, 0, "back to nothing after SetChrome(0)");
}
private static void ChromeDoesNotFallBackToAll()
{
Eq(PanelTextScale.GetAll(), 5, "All Panels is 5");
Eq(PanelTextScale.GetChrome(), 0, "toolbar without its own row is normal size");
}
private static void ChromeClamps()
{
PanelTextScale.SetChrome(99);
Eq(PanelTextScale.GetChrome(), PanelTextScale.SizeNames.Length - 1, "clamped to the top size");
PanelTextScale.SetChrome(-4);
Eq(PanelTextScale.GetChrome(), 0, "clamped to 0");
}
private static void RoundTripWrite()
{
int before = RynthCore.Engine.ImGuiBackend.ImGuiFonts.Rebuilds;
PanelTextScale.SetChrome(4);
Eq(RynthCore.Engine.ImGuiBackend.ImGuiFonts.Rebuilds, before + 1, "SetChrome requested one re-bake");
Check(Lines().Contains("__chrome=4"), "file has __chrome=4");
PanelTextScale.SetChrome(4);
Eq(RynthCore.Engine.ImGuiBackend.ImGuiFonts.Rebuilds, before + 1, "same size again requests nothing");
}
// A fresh process reads what RoundTripWrite saved.
private static void RoundTripRead()
{
Eq(PanelTextScale.GetChrome(), 4, "chrome read back from the file");
}
}
}