Skip to main content

GridLayout

Struct GridLayout 

Source
pub struct GridLayout {
    pub titles: HeaderTitles,
    pub cols: u32,
    pub sections: Vec<(u32, &'static str)>,
    pub widgets: Vec<GridWidget>,
    pub cell_size: f32,
    pub width: u32,
    pub height: u32,
    /* private fields */
}
Expand description

Grid-based layout for a plugin UI.

Fields§

§titles: HeaderTitles

Header band titles. Both slots default to None, in which case no header is drawn and the grid starts at y = 0 (plus padding).

§cols: u32

Number of columns in the grid.

§sections: Vec<(u32, &'static str)>

Section labels positioned above specific rows: (row_index, label).

§widgets: Vec<GridWidget>

All widgets placed in the grid.

§cell_size: f32

Cell size in logical points (width and height of one grid cell).

§width: u32

Computed width in logical points.

§height: u32

Computed height in logical points.

Implementations§

Source§

impl GridLayout

Source

pub fn build(entries: Vec<Section>) -> GridLayout

Build a grid layout from sections containing widgets. No header is drawn, cols defaults to the widest section’s widget count (extended to fit any explicitly-positioned widget), and cell_size defaults to GRID_DEFAULT_CELL_SIZE. Override any of those via Self::with_titles / Self::with_cols / Self::with_cell_size.

Each entry is either a Section (created with section("LABEL", vec![...])) or a bare GridWidget (auto-wrapped via From). Example:

GridLayout::build(vec![
    section("LOW", vec![
        GridWidget::knob(P::Freq, "Freq"),
        GridWidget::knob(P::Gain, "Gain"),
    ]),
    GridWidget::knob(P::Output, "Output").into(),
])
Source

pub fn with_cols(self, cols: u32) -> GridLayout

Override the default column count (which is the widest section’s widget count, or whatever explicit positions require - whichever is larger). Use to force wrapping: .with_cols(2) on a 4-widget section produces a 2×2 grid. Recomputes auto-flow placement and window size.

Source

pub fn with_cell_size(self, cell_size: f32) -> GridLayout

Override the default cell size (GRID_DEFAULT_CELL_SIZE). The cell is square - this is both the width and height of one grid cell in logical points.

Source

pub fn with_grid(self, cols: u32, cell_size: f32) -> GridLayout

Like Self::with_cols but accepts the cell size in the same call - useful when both are non-default. Equivalent to .with_cell_size(s).with_cols(c).

Source

pub fn with_titles(self, titles: HeaderTitles) -> GridLayout

Set both header slots at once. Replaces any previously configured titles. Recomputes the height to account for the extra band - width stays the same since the header spans the full grid width.

use truce_gui_types::layout::{GridLayout, HeaderTitles};
GridLayout::build(sections).with_titles(HeaderTitles::pair("EQ", "v0.1"))
Source

pub fn with_title(self, title: &'static str) -> GridLayout

Set the title slot (left, larger / brighter), preserving any previously configured subtitle.

GridLayout::build(sections).with_title("EQ")
Source

pub fn with_subtitle(self, subtitle: &'static str) -> GridLayout

Set the subtitle slot (right, smaller / dimmer), preserving any previously configured title.

GridLayout::build(sections).with_subtitle("v0.1")
Source

pub fn compute_size(&self) -> (u32, u32)

Compute the window size from the grid.

Trait Implementations§

Source§

impl Clone for GridLayout

Source§

fn clone(&self) -> GridLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GridLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<PluginLayout> for GridLayout

Source§

fn from(pl: PluginLayout) -> GridLayout

Converts to this type from the input type.
Source§

impl IntoLayoutEditor for GridLayout

Available on iOS or crate feature cpu or crate feature gpu only.
Source§

fn into_editor<P: Params + 'static>(self, params: &Arc<P>) -> Box<dyn Editor>

Wrap this layout in truce’s default editor, picking the renderer from the active truce-gui feature. See default_editor.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,