Skip to main content

ContainerBuilder

Struct ContainerBuilder 

Source
pub struct ContainerBuilder<'a> { /* private fields */ }
Expand description

Fluent builder for configuring containers before calling .col() or .row().

Obtain one via Context::container or Context::bordered. Chain the configuration methods you need, then finalize with .col(|ui| { ... }) or .row(|ui| { ... }).

§Example

use slt::{Border, Color};
ui.container()
    .border(Border::Rounded)
    .pad(1)
    .grow(1)
    .col(|ui| {
        ui.text("inside a bordered, padded, growing column");
    });

Implementations§

Source§

impl<'a> ContainerBuilder<'a>

Source

pub fn border(self, border: Border) -> Self

Set the border style.

Source

pub fn rounded(self) -> Self

Set rounded border style. Shorthand for .border(Border::Rounded).

Source

pub fn border_style(self, style: Style) -> Self

Set the style applied to the border characters.

Source

pub fn p(self, value: u32) -> Self

Set uniform padding on all sides. Alias for pad.

Source

pub fn pad(self, value: u32) -> Self

Set uniform padding on all sides.

Source

pub fn px(self, value: u32) -> Self

Set horizontal padding (left and right).

Source

pub fn py(self, value: u32) -> Self

Set vertical padding (top and bottom).

Source

pub fn pt(self, value: u32) -> Self

Set top padding.

Source

pub fn pr(self, value: u32) -> Self

Set right padding.

Source

pub fn pb(self, value: u32) -> Self

Set bottom padding.

Source

pub fn pl(self, value: u32) -> Self

Set left padding.

Source

pub fn padding(self, padding: Padding) -> Self

Set per-side padding using a Padding value.

Source

pub fn m(self, value: u32) -> Self

Set uniform margin on all sides.

Source

pub fn mx(self, value: u32) -> Self

Set horizontal margin (left and right).

Source

pub fn my(self, value: u32) -> Self

Set vertical margin (top and bottom).

Source

pub fn mt(self, value: u32) -> Self

Set top margin.

Source

pub fn mr(self, value: u32) -> Self

Set right margin.

Source

pub fn mb(self, value: u32) -> Self

Set bottom margin.

Source

pub fn ml(self, value: u32) -> Self

Set left margin.

Source

pub fn margin(self, margin: Margin) -> Self

Set per-side margin using a Margin value.

Source

pub fn w(self, value: u32) -> Self

Set a fixed width (sets both min and max width).

Source

pub fn h(self, value: u32) -> Self

Set a fixed height (sets both min and max height).

Source

pub fn min_w(self, value: u32) -> Self

Set the minimum width constraint. Shorthand for min_width.

Source

pub fn max_w(self, value: u32) -> Self

Set the maximum width constraint. Shorthand for max_width.

Source

pub fn min_h(self, value: u32) -> Self

Set the minimum height constraint. Shorthand for min_height.

Source

pub fn max_h(self, value: u32) -> Self

Set the maximum height constraint. Shorthand for max_height.

Source

pub fn min_width(self, value: u32) -> Self

Set the minimum width constraint in cells.

Source

pub fn max_width(self, value: u32) -> Self

Set the maximum width constraint in cells.

Source

pub fn min_height(self, value: u32) -> Self

Set the minimum height constraint in rows.

Source

pub fn max_height(self, value: u32) -> Self

Set the maximum height constraint in rows.

Source

pub fn constraints(self, constraints: Constraints) -> Self

Set all size constraints at once using a Constraints value.

Source

pub fn gap(self, gap: u32) -> Self

Set the gap (in cells) between child elements.

Source

pub fn grow(self, grow: u16) -> Self

Set the flex-grow factor. 1 means the container expands to fill available space.

Source

pub fn align(self, align: Align) -> Self

Set the cross-axis alignment of child elements.

Source

pub fn center(self) -> Self

Center children on the cross axis. Shorthand for .align(Align::Center).

Source

pub fn title(self, title: impl Into<String>) -> Self

Set a plain-text title rendered in the top border.

Source

pub fn title_styled(self, title: impl Into<String>, style: Style) -> Self

Set a styled title rendered in the top border.

Source

pub fn scroll_offset(self, offset: u32) -> Self

Set the vertical scroll offset in rows. Used internally by Context::scrollable.

Source

pub fn col(self, f: impl FnOnce(&mut Context)) -> Response

Finalize the builder as a vertical (column) container.

The closure receives a &mut Context for rendering children. Returns a Response with click/hover state for this container.

Source

pub fn row(self, f: impl FnOnce(&mut Context)) -> Response

Finalize the builder as a horizontal (row) container.

The closure receives a &mut Context for rendering children. Returns a Response with click/hover state for this container.

Auto Trait Implementations§

§

impl<'a> Freeze for ContainerBuilder<'a>

§

impl<'a> RefUnwindSafe for ContainerBuilder<'a>

§

impl<'a> Send for ContainerBuilder<'a>

§

impl<'a> Sync for ContainerBuilder<'a>

§

impl<'a> Unpin for ContainerBuilder<'a>

§

impl<'a> UnsafeUnpin for ContainerBuilder<'a>

§

impl<'a> !UnwindSafe for ContainerBuilder<'a>

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.