Skip to main content

LayoutBuilder

Struct LayoutBuilder 

Source
pub struct LayoutBuilder { /* private fields */ }
Expand description

Ergonomic builder for constructing layouts.

Users create panels, arrange them in row()/col() containers via closures, then call build() to get a Layout ready for resolution.

Implementations§

Source§

impl LayoutBuilder

Source

pub fn new() -> Self

Create an empty builder with no root set.

Source

pub fn panel(&mut self, kind: impl Into<Arc<str>>) -> Result<PanelId, PaneError>

Create a panel with grow(1.0) default constraints.

Source

pub fn panel_with( &mut self, kind: impl Into<Arc<str>>, constraints: Constraints, ) -> Result<PanelId, PaneError>

Create a panel with explicit constraints.

Source

pub fn row( &mut self, f: impl FnOnce(&mut ContainerCtx<'_>), ) -> Result<(), PaneError>

Set the root to a row container with zero gap.

Source

pub fn row_gap( &mut self, gap: f32, f: impl FnOnce(&mut ContainerCtx<'_>), ) -> Result<(), PaneError>

Set the root to a row container with the specified gap.

Source

pub fn col( &mut self, f: impl FnOnce(&mut ContainerCtx<'_>), ) -> Result<(), PaneError>

Set the root to a column container with zero gap.

Source

pub fn col_gap( &mut self, gap: f32, f: impl FnOnce(&mut ContainerCtx<'_>), ) -> Result<(), PaneError>

Set the root to a column container with the specified gap.

Source

pub fn set_window_size(&mut self, size: usize)

Consume the builder, validate the tree, and return a Layout. Set how many panels the active window shows at once.

Source

pub fn build(self) -> Result<Layout, PaneError>

Validate the tree and produce a Layout.

Trait Implementations§

Source§

impl Default for LayoutBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, 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.