Skip to main content

Window

All widgets are rendered inside a Window.

See the WindowDemo class.

Gui.LabelInputBool("Show StandardWindow", ref showStandardWindow);
Gui.LabelInputBool("Show BlankWindow", ref showBlankWindow);
Gui.LabelInputBool("Show OuterWindow", ref showOuterWindow);

// Setting the initial position for newly opened windows.
using var s = Style.Window.InitialRects.Begin(Ctx.GetWindowRect().Move(-new Vector2(100f, 100f)));

// Standard window example.
if (Gui.BeginStandardWindow("StandardWindow", ref showStandardWindow))
{
// This method must be executed if Begin returns true.
Gui.EndStandardWindow();
}

// Blank window example.
if (showBlankWindow && Gui.BeginBlankWindow("BlankWindow"))
{
// note:Render a background to avoid visual confusion when nothing is drawn.
using var s1 = Style.Box.Colors.Begin(Style.StandardWindow.BackgroundColors.Get());
Gui.Box(Ctx.GetWindowRect());

using (Style.Text.AlignmentXs.Begin(AlignmentX.Center))
using (Style.ScaleFactors.Begin(2f))
Gui.NextRect(Ctx.GetWindowRect()).Text("BlankWindow");

Gui.EndBlankWindow();
}

// Nested window example.
if (showOuterWindow && Gui.BeginStandardWindow("Outer", ref showOuterWindow))
{
Gui.Text("Closing the outer window also closes the nested window.");

// Position and size the nested window.
using var s2 = Style.Window.InitialRects.Begin(
Ctx.GetWindowRect()
.Shrink(50f)
.CreateCenteredWithMinSize(100, 100));

if (Gui.BeginStandardWindow("Nested"))
{
Gui.EndStandardWindow();
}
Gui.EndStandardWindow();
}