Demos/HudLayout.cs
using Goo;
using Sandbox.UI;
namespace Sandbox;
// Per-child anchored slot; JustifyContent/AlignItems from Layout.ResolveAnchor. Demo-side.
public static class HudLayout
{
public static Container Anchored( Layout.Anchor anchor, Container content, float padding = 0f, string? key = null )
{
var r = Layout.ResolveAnchor( anchor );
// cell must be Column to match Hud.Overlay; the engine default Row swaps axes (top-center renders center-left), and r.FlexDirection is also wrong here (ColumnReverse for top anchors renders bottom-center) - it belongs on the inner stacking column.
return new Container
{
Key = key,
Position = PositionMode.Absolute,
Top = 0,
Left = 0,
Width = Length.Percent( 100 ),
Height = Length.Percent( 100 ),
Padding = padding,
PointerEvents = PointerEvents.None,
FlexDirection = FlexDirection.Column,
JustifyContent = r.JustifyContent,
AlignItems = r.AlignItems,
Children = { content },
};
}
}