feat(ui): persist retained window layouts

This commit is contained in:
Erik 2026-07-10 23:17:29 +02:00
parent a8e9503d2e
commit 921c388e2c
22 changed files with 705 additions and 141 deletions

View file

@ -106,6 +106,59 @@ public sealed class RetailWindowFrameTests
Assert.False(content.Resizable);
}
[Fact]
public void HiddenInventory_RestoredExpandedBeforeFirstDraw_GrowsContentsRows()
{
ImportedLayout layout = FixtureLoader.LoadInventory();
UiItemList grid = Assert.IsType<UiItemList>(
layout.FindElement(InventoryController.ContentsGridId));
grid.Columns = 6;
grid.CellWidth = 32f;
grid.CellHeight = 32f;
grid.Flush();
for (int i = 0; i < 102; i++)
grid.AddItem(new UiItemSlot());
var root = new UiRoot { Width = 1280, Height = 720 };
RetailWindowHandle handle = RetailWindowFrame.Mount(
root,
layout.Root,
NoTex,
new RetailWindowFrame.Options
{
WindowName = WindowNames.Inventory,
Chrome = RetailWindowChrome.NineSlice,
ContentWidth = layout.Root.Width,
ContentHeight = layout.Root.Height,
Visible = false,
ResizeX = false,
ResizeY = true,
ResizableEdges = ResizeEdges.Bottom,
MaxHeight = 560f,
});
// Production installs the controller-owned policies after mounting, while
// inventory is still hidden, and captures their design baseline immediately.
InventoryController.ConfigureResizeLayout(layout);
// Persistence restores the hidden window before its first visible draw.
handle.ResizeTo(handle.Width, 527f);
ApplyAnchors(handle.OuterFrame);
grid.LayoutCells();
Assert.Equal(251f, grid.Height);
Assert.Equal(42, grid.Children.Count(child => child.Visible));
}
private static void ApplyAnchors(UiElement parent)
{
foreach (UiElement child in parent.Children)
{
child.ApplyAnchor(parent.Width, parent.Height);
ApplyAnchors(child);
}
}
private static ElementInfo Constraints(int minHeight, int maxHeight)
{
var info = new ElementInfo();