DeferredBuilding
It is used when you want to defer the rendering of a widget.
See the DeferredBuildingDemo class.
using var vertRects = LayoutBuilder.Fit(1f).Fit(1f).Fit(1f).BuildAllocatedHorizontal(height: 100f);
/// Within this scope, widget rendering is deferred and drawn after the next widget.
///
/// If you want to render a widget in the foreground, you need to execute it later.
/// However, executing it later will cause its input processing to be prioritized
/// over the widget executed earlier.
/// In such cases, using <see cref="Context.BeginDeferredBuilding"/> allows
/// you to render the widget after the next widget.
using (Ctx.BeginDeferredBuilding())
{
using (Style.Button.Colors.Begin(Style.Button.Colors.Get().ChangeAlpha(220)))
using (Style.Button.HoveredColors.Begin(Style.Button.HoveredColors.Get().ChangeAlpha(220)))
{
// Rendered in the foreground.
if (Gui.NextRect(vertRects.R1.CreateCenteredWithHeight(30f)).TextButton("Front"))
{
Logger.Debug("IsPressed Front");
}
}
}
using (Style.FontSizes.Begin(70f))
{
// Rendered in the background.
if (Gui.NextRect(vertRects.Whole).TextButton("Back"))
{
Logger.Debug("IsPressed Back");
}
}