pub struct Column<Msg: Clone> {
pub children: Vec<Element<Msg>>,
pub spacing: Length,
pub padding: Length,
pub align_center_x: bool,
pub center_y: bool,
pub max_width: Option<Length>,
pub fit_content: bool,
}Expand description
A vertical layout container.
Children are arranged top-to-bottom with optional spacing and padding. Spacers absorb remaining vertical space, enabling push-to-bottom layouts.
column()
.padding( 24.0 )
.spacing( 12.0 )
.push( text( "Title" ) )
.push( spacer() )
.push( button( "OK" ).on_press( Msg::Ok ) )
.into()padding, spacing and max_width all accept any
crate::Length, so a responsive layout reads as:
column()
// Padding is 3 % of the viewport's smaller side, clamped to 16..48 px.
.padding( Length::vmin( 3.0 ).clamp( 16.0, 48.0 ) )
.spacing( Length::vmin( 1.5 ).at_least( 8.0 ) )
.max_width( Length::vw( 60.0 ).at_most( 720.0 ) )
.push( text( "Responsive" ) )
.push( button( "OK" ).on_press( Msg::Ok ) )
.into()Fields§
§children: Vec<Element<Msg>>§spacing: LengthVertical gap between children. Stored as Length so a Vmin(2.0)
or Em(0.5) gap scales with the viewport instead of freezing at a
px constant.
padding: LengthPadding on all sides. Same Length semantics as spacing.
align_center_x: bool§center_y: bool§max_width: Option<Length>§fit_content: boolImplementations§
Source§impl<Msg: Clone> Column<Msg>
impl<Msg: Clone> Column<Msg>
pub fn new() -> Self
Sourcepub fn spacing(self, s: impl Into<Length>) -> Self
pub fn spacing(self, s: impl Into<Length>) -> Self
Set the vertical gap between children. Default: 8.0 px. Accepts
any Length — pass an f32 for the px case, or a relative
value like Length::vmin( 2.0 ) to scale with the viewport.
Sourcepub fn padding(self, p: impl Into<Length>) -> Self
pub fn padding(self, p: impl Into<Length>) -> Self
Set the padding (all sides). Default: 16.0 px. Accepts any
Length.
Sourcepub fn align_center_x(self, c: bool) -> Self
pub fn align_center_x(self, c: bool) -> Self
When true (default), children are centered horizontally.
Sourcepub fn center_y(self, c: bool) -> Self
pub fn center_y(self, c: bool) -> Self
When true, center the content block vertically (only when no spacers are present).
Sourcepub fn max_width(self, w: impl Into<Length>) -> Self
pub fn max_width(self, w: impl Into<Length>) -> Self
Limit the content width. Accepts any Length. The column still
reports the parent’s max_width as its preferred width so the
parent allocates the full available rect.
Sourcepub fn fit_content(self) -> Self
pub fn fit_content(self) -> Self
Report the intrinsic content width as preferred width instead of filling
the available max_width. Use this when the column represents a card
or widget meant to sit side-by-side with other children inside a
Row — without this flag, two columns in a
row each claim the full row width and overflow their siblings.
The preferred width is computed as the max of children’s preferred
widths plus padding, capped by the external max_width the parent
offers and by any max_width setting on the column itself.
Sourcepub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)
pub fn preferred_size(&self, max_width: f32, canvas: &Canvas) -> (f32, f32)
Return the preferred (width, height) given available max_width.
pub fn draw(&self, _canvas: &mut Canvas, _rect: Rect, _focused: bool)
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for Column<Msg>
impl<Msg> !RefUnwindSafe for Column<Msg>
impl<Msg> !Send for Column<Msg>
impl<Msg> !Sync for Column<Msg>
impl<Msg> Unpin for Column<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Column<Msg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more