Skip to main content

Axis

See the AxisDemo class.

void DrawUsingFixed()
{
Gui.LabelInputNumeric("width", ref width);
// Start horizontal rendering.
using (Ctx.Horizontal())
{
isOnCheckBox = Gui
.NextWidth(40)
.NextHeight(Size.Fixed(40))
.CheckBox(isOnCheckBox);

for (int i = 0; i < 3; i++)
{
using var s = Ctx.PushId(i);

if (Gui
.NextWidth(width)
.TextButton($"{i}"))
{
Logger.Debug("IsPressed");
}
}
}
}
void DrawUsingRatio()
{
// Start horizontal rendering.
using (Ctx.Horizontal())
{
// note:Due to the spaces, even with this ratio setting, it cannot be rendered at 1:1.
if (Gui.NextRatioWidth(1 / 2f).TextButton($"0"))
{
}
if (Gui.NextRatioWidth(1 / 1f).TextButton($"1"))
{
}
}
}
// Combination of padding and Axis.
void DrawWithPadding()
{
// Start vertical rendering.
using (Ctx.Vertical())
{
TextButton("0");
using (Ctx.BeginPadding(new Padding(20, 20, 20, 20)))
TextButton("1");
using (Ctx.Horizontal())
{
TextButton("2");
TextButton("3");
}
TextButton("4");
}
void TextButton(string s)
{
Gui.NextWidth(50).TextButton(s);
}
}
void DrawUsingHorizontalAndVertical()
{
var i = 0;
using (Ctx.Horizontal())
{
Text();

// If switched to vertical rendering during horizontal rendering,
// rendering will continue horizontally from the current position.
using (Ctx.Vertical())
{
Text();
Text();
using (Ctx.Horizontal())
{
Text();
Text();
// The rendering result does not change if the Axis and Alignment are the same.
using (Ctx.Horizontal())
{
Text();
}
}

Text();
}
Text();
}

void Text()
{
Gui.NextWidth(50).TextButton(i.ToString());
i++;
}
}
void DrawMisc()
{
Gui.LabelInputNumeric("slider width", ref sliderWidth);

using (Ctx.Horizontal())
{
Gui.NextWidth(20f).CheckBox(ref showExtra);
Gui.NextWidth(sliderWidth).Slider(ref sliderValue, 0f, 100f);

using (Ctx.Vertical())
{
Gui.Image(Properties.SampleTexture);
Gui.FixedWidthText($"{sliderValue}");
if (showExtra)
Gui.Text("AAA");
}
}
}