Skip to main content

grid

Macro grid 

Source
macro_rules! grid {
    ({ $($body:tt)* }) => { ... };
    (cols: $cols:expr, { $($body:tt)* }) => { ... };
    (cell: $cell:expr, { $($body:tt)* }) => { ... };
    (cols: $cols:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, subtitle: $subtitle:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, subtitle: $subtitle:expr, cols: $cols:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, subtitle: $subtitle:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, subtitle: $subtitle:expr, cols: $cols:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, cols: $cols:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (title: $title:expr, cols: $cols:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (subtitle: $subtitle:expr, { $($body:tt)* }) => { ... };
    (subtitle: $subtitle:expr, cols: $cols:expr, { $($body:tt)* }) => { ... };
    (subtitle: $subtitle:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
    (subtitle: $subtitle:expr, cols: $cols:expr, cell: $cell:expr, { $($body:tt)* }) => { ... };
}
Expand description

Declarative grid layout DSL for plugin GUIs.

Defaults: no header, cols = max widgets per section, cell_size = GRID_DEFAULT_CELL_SIZE. Override any of those via the cols: / cell: keyword args, or set the header band with title: "..." and / or subtitle: "..." (each is independently optional).

§Example

use truce_gui_types::grid;

// Minimal - auto-cols, default cell size, no header.
fn gui_layout() -> truce_gui_types::layout::GridLayout {
    grid!({
        knob(ID_GAIN, "Gain")
        slider(ID_PAN, "Pan")
    })
}

// Force wrapping: 4 widgets on a 2-col grid.
fn wrapped() -> truce_gui_types::layout::GridLayout {
    grid!(cols: 2, {
        knob(ID_GAIN, "Gain")
        slider(ID_PAN, "Pan")
        toggle(ID_BYPASS, "Bypass")
        meter(&[METER_L, METER_R], "Level")
    })
}

// Header - title + subtitle, or either one alone.
fn with_header() -> truce_gui_types::layout::GridLayout {
    grid!(title: "MY PLUGIN", subtitle: "V1.0", cols: 4, cell: 50.0, {
        knob(ID_GAIN, "Gain")
    })
}

fn title_only() -> truce_gui_types::layout::GridLayout {
    grid!(title: "MY PLUGIN", { knob(ID_GAIN, "Gain") })
}