SubWindow
A SubWindow is a child-like window associated with a Window.
Multiple SubWindows can be linked to a single Window.
See the SubWindowDemo class.
// UI to control the visibility of the first sub-window
Gui.LabelInputBool("Show", ref show);
Gui.InputVector2Int("Pos", ref subWindow1Pos);
Gui.InputVector2Int("Size", ref subWindow1Size);
if (show)
{
// Layout the sub-window with the specified position and size
using (Style.SubWindow.BeginLayout(subWindow1Pos, subWindow1Size))
{
if (Gui.BeginSubWindow())
{
Gui.Text("AAA");
Gui.Text("BBB");
Gui.Text("CCC");
Gui.TextColorTexture(Properties.SampleTexture);
Gui.EndSubWindow();
}
}
}
Gui.Separator();
Gui.Text("Display while hovering.");
// Apply the text style for the tooltip display
using (Style.Text.Styles.Begin(textStyle))
Gui.NextTextWidth(" (?) ").Text(" (?) ");
// Check if the mouse pointer is over the last widget and show a tooltip sub-window if true
if (Gui.Ctx.IsValidPointerIn(Gui.Ctx.GetLastWidgetRect()))
{
// Position and layout the tooltip sub-window based on the mouse position
using (Style.SubWindow.BeginAutoSizeLayout(Gui.Input.MousePos + new Vector2(15, -15), new Vector2(400, 400)))
{
if (Gui.BeginSubWindow())
{
Gui.NextTextWidth("Tooltip").Text("Tooltip");
Gui.EndSubWindow();
}
}
}
Gui.Separator();
Gui.LabelInputBool("Show mouse pos", ref showMousePos);
if (showMousePos)
{
// Position and layout the sub-window near the mouse position
using (Style.SubWindow.BeginAutoSizeLayout(Input.MousePos + new Vector2(15, -15), new Vector2(200, 200)))
{
if (Gui.BeginSubWindow())
{
var mousePosStr = Input.MousePos.ToString();
Gui.NextTextWidth(mousePosStr).Text($"{mousePosStr}");
Gui.EndSubWindow();
}
}
}