UI module

spacer

procedureextensionexperimentalsince 0.31.0Source

Empty space that grows to fill what is left in its row or column.

Example↗
ui := headless(.{ width = 300, height = 40 });
defer free_ui(*ui);
frame(*ui, *ui, (u: *UI_State) {
    for row(.{ width = 300 }) {
        label("left");
        spacer();  // pushes what follows to the right edge
        label("right");
    }
});
assert(find_label(*ui, "right").rect.x > 200);
spacer :: (grow: float = 1, loc := #caller_location)

Empty space that grows to fill what is left in its row or column.

Parameters

grow: float = 1
its share of the leftover space.
loc := #caller_location
the call site. It identifies the widget from one frame to the next, so leave the default.
Example↗
ui := headless(.{ width = 300, height = 40 });
defer free_ui(*ui);
frame(*ui, *ui, (u: *UI_State) {
    for row(.{ width = 300 }) {
        label("left");
        spacer();  // pushes what follows to the right edge
        label("right");
    }
});
assert(find_label(*ui, "right").rect.x > 200);

See also