UI module

split

procedureextensionexperimentalsince 0.31.0Source

Two panes with a draggable divider. position is the first pane's size along axis (HORIZONTAL puts the panes side by side); the app keeps it so it can be saved. Use for pane: split(.HORIZONTAL, *width) { if pane == 0 { ... } else { ... } }.

Example↗
width := 150.0;
ui := headless(.{ width = 400, height = 200 });
defer free_ui(*ui);
frame(*ui, *width, (w: *float) {
    for pane: split(.HORIZONTAL, w, .{ min = 100 }) {
        if pane == 0 label("files"); else label("editor");
    }
});
assert(width == 150);
split :: (
    axis: Axis,
    position: *float,
    options: Split_Options = .{},
    loc := #caller_location
) -> Split

Two panes with a draggable divider. position is the first pane's size along axis (HORIZONTAL puts the panes side by side); the app keeps it so it can be saved. Use for pane: split(.HORIZONTAL, *width) { if pane == 0 { ... } else { ... } }.

Parameters

axis: Axis
the direction the panes sit in.
position: *float
the first pane's size in points. It is clamped to the options' limits and updated while the divider is dragged.
options: Split_Options = .{}
the smallest and largest size of the first pane.
loc := #caller_location
the call site. It identifies the widget from one frame to the next, so leave the default.

Returns

Example↗
width := 150.0;
ui := headless(.{ width = 400, height = 200 });
defer free_ui(*ui);
frame(*ui, *width, (w: *float) {
    for pane: split(.HORIZONTAL, w, .{ min = 100 }) {
        if pane == 0 label("files"); else label("editor");
    }
});
assert(width == 150);

See also