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 border_top(self, show: bool) -> Self

Show or hide the top border.

Source

pub fn border_right(self, show: bool) -> Self

Show or hide the right border.

Source

pub fn border_bottom(self, show: bool) -> Self

Show or hide the bottom border.

Source

pub fn border_left(self, show: bool) -> Self

Show or hide the left border.

Source

pub fn border_sides(self, sides: BorderSides) -> Self

Set which border sides are visible.

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 dark_border_style(self, style: Style) -> Self

Border style used when dark mode is active.

Source

pub fn bg(self, color: Color) -> Self

Source

pub fn dark_bg(self, color: Color) -> Self

Background color used when dark mode is active.

Source

pub fn group_hover_bg(self, color: Color) -> Self

Background color applied when the parent group is hovered.

Source

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

Border style applied when the parent group is hovered.

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 xs_w(self, value: u32) -> Self

Width applied only at Xs breakpoint (< 40 cols).

§Example
ui.container().w(20).md_w(40).lg_w(60).col(|ui| { ... });
Source

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

Width applied only at Sm breakpoint (40-79 cols).

Source

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

Width applied only at Md breakpoint (80-119 cols).

Source

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

Width applied only at Lg breakpoint (120-159 cols).

Source

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

Width applied only at Xl breakpoint (>= 160 cols).

Source

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

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

Source

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

Height applied only at Xs breakpoint (< 40 cols).

Source

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

Height applied only at Sm breakpoint (40-79 cols).

Source

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

Height applied only at Md breakpoint (80-119 cols).

Source

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

Height applied only at Lg breakpoint (120-159 cols).

Source

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

Height applied only at Xl breakpoint (>= 160 cols).

Source

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

Set the minimum width constraint. Shorthand for min_width.

Source

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

Minimum width applied only at Xs breakpoint (< 40 cols).

Source

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

Minimum width applied only at Sm breakpoint (40-79 cols).

Source

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

Minimum width applied only at Md breakpoint (80-119 cols).

Source

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

Minimum width applied only at Lg breakpoint (120-159 cols).

Source

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

Minimum width applied only at Xl breakpoint (>= 160 cols).

Source

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

Set the maximum width constraint. Shorthand for max_width.

Source

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

Maximum width applied only at Xs breakpoint (< 40 cols).

Source

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

Maximum width applied only at Sm breakpoint (40-79 cols).

Source

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

Maximum width applied only at Md breakpoint (80-119 cols).

Source

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

Maximum width applied only at Lg breakpoint (120-159 cols).

Source

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

Maximum width applied only at Xl breakpoint (>= 160 cols).

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 w_pct(self, pct: u8) -> Self

Set width as a percentage (1-100) of the parent container.

Source

pub fn h_pct(self, pct: u8) -> Self

Set height as a percentage (1-100) of the parent container.

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 xs_gap(self, value: u32) -> Self

Gap applied only at Xs breakpoint (< 40 cols).

Source

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

Gap applied only at Sm breakpoint (40-79 cols).

Source

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

Gap applied only at Md breakpoint (80-119 cols).

§Example
ui.container().gap(0).md_gap(2).col(|ui| { ... });
Source

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

Gap applied only at Lg breakpoint (120-159 cols).

Source

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

Gap applied only at Xl breakpoint (>= 160 cols).

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 xs_grow(self, value: u16) -> Self

Grow factor applied only at Xs breakpoint (< 40 cols).

Source

pub fn sm_grow(self, value: u16) -> Self

Grow factor applied only at Sm breakpoint (40-79 cols).

Source

pub fn md_grow(self, value: u16) -> Self

Grow factor applied only at Md breakpoint (80-119 cols).

Source

pub fn lg_grow(self, value: u16) -> Self

Grow factor applied only at Lg breakpoint (120-159 cols).

Source

pub fn xl_grow(self, value: u16) -> Self

Grow factor applied only at Xl breakpoint (>= 160 cols).

Source

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

Uniform padding applied only at Xs breakpoint (< 40 cols).

Source

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

Uniform padding applied only at Sm breakpoint (40-79 cols).

Source

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

Uniform padding applied only at Md breakpoint (80-119 cols).

Source

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

Uniform padding applied only at Lg breakpoint (120-159 cols).

Source

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

Uniform padding applied only at Xl breakpoint (>= 160 cols).

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 justify(self, justify: Justify) -> Self

Set the main-axis content distribution mode.

Source

pub fn space_between(self) -> Self

Distribute children with equal space between; first at start, last at end.

Source

pub fn space_around(self) -> Self

Distribute children with equal space around each child.

Source

pub fn space_evenly(self) -> Self

Distribute children with equal space between all children and edges.

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.

Source

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

Finalize the builder as an inline text line.

Like row but gap is forced to zero for seamless inline rendering of mixed-style text.

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.