pub struct Row<Msg: Clone> { /* private fields */ }Expand description
A horizontal layout container.
Children are arranged left-to-right. Use Row::align_right to
push the content block to the right edge of the available width.
row()
.spacing( 16.0 )
.align_right()
.push( icon_button( a_rgba, w, h ).on_press( Msg::A ) )
.push( icon_button( b_rgba, w, h ).on_press( Msg::B ) )
.into()spacing and padding accept any crate::Length:
row()
// 2 % of the viewport's smaller side, never below 8 px.
.spacing( Length::vmin( 2.0 ).at_least( 8.0 ) )
.push( icon_button( a_rgba, w, h ).on_press( Msg::A ) )
.push( icon_button( b_rgba, w, h ).on_press( Msg::B ) )
.into()Implementations§
Source§impl<Msg: Clone> Row<Msg>
impl<Msg: Clone> Row<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 horizontal gap between children. Default: 8.0 px. Accepts
any Length so the gap can 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: 0.0 px. Accepts any
Length.
Sourcepub fn no_shrink(self) -> Self
pub fn no_shrink(self) -> Self
Keep every child at its preferred width even when the cluster does not fit, letting it overflow the row’s rect.
The default distributes the shortfall instead, which is what a row of labelled buttons wants. Opt out for strips that are deliberately wider than their viewport — a carousel rail, a tray meant to be scrolled — where shrinking to fit would defeat the point.
Sourcepub fn align_right(self) -> Self
pub fn align_right(self) -> Self
Push the content block to the right edge of the available width.
Sourcepub fn align_top(self) -> Self
pub fn align_top(self) -> Self
Pin children to the top edge instead of the default vertical centering, so siblings of slightly different heights (e.g. two cards whose text metrics differ) share the same top line.
Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Stretch every child to the row’s inner height, so siblings share both the top and the bottom line regardless of their natural heights. The row’s own height still comes from the tallest child’s preferred size; children whose content should track the stretch need internal flexible spacers.
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)
Sourcepub fn layout(&self, rect: Rect, canvas: &Canvas) -> Vec<(Rect, usize)>
pub fn layout(&self, rect: Rect, canvas: &Canvas) -> Vec<(Rect, usize)>
Layout children within rect and return (rect, child_index) pairs.
Flexible Spacer children claim the
leftover horizontal space: non-spacer widgets keep their preferred
width, the remaining width (after subtracting spacing + padding) is
distributed between spacers in proportion to their weight. When no
spacers are present the cluster is centered (or right-aligned via
Row::align_right).
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for Row<Msg>
impl<Msg> !RefUnwindSafe for Row<Msg>
impl<Msg> !Send for Row<Msg>
impl<Msg> !Sync for Row<Msg>
impl<Msg> Unpin for Row<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for Row<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