pub struct WrapGrid<Msg: Clone> {
pub children: Vec<Element<Msg>>,
pub columns: usize,
pub spacing_x: Length,
pub spacing_y: Length,
pub padding: Length,
pub centre_last_row: bool,
}Expand description
A grid layout that wraps children into rows of a fixed column count.
All cells in a row share the same height (the tallest item in that row). Column widths are equal, dividing the available width minus padding and spacing.
Designed for app-drawer style layouts — combine with scroll()
for vertically scrollable grids:
scroll(
grid( 4 )
.padding( 16.0 )
.spacing( 12.0 )
.push( icon_button( data.clone(), w, h ).on_press( Msg::Open( 0 ) ) )
.push( icon_button( data, w, h ).on_press( Msg::Open( 1 ) ) )
// ...
)
.into()Fields§
§children: Vec<Element<Msg>>Child widgets laid out in row-major order.
columns: usizeNumber of columns per row.
spacing_x: LengthHorizontal gap between cells.
spacing_y: LengthVertical gap between rows.
padding: LengthPadding on all sides.
centre_last_row: boolWhen true, a partial last row is centred horizontally within
the grid’s content rect instead of being left-aligned.
Implementations§
Source§impl<Msg: Clone> WrapGrid<Msg>
impl<Msg: Clone> WrapGrid<Msg>
Sourcepub fn spacing(self, s: impl Into<Length>) -> Self
pub fn spacing(self, s: impl Into<Length>) -> Self
Set both horizontal and vertical gap between cells (default 8.0).
Sourcepub fn spacing_x(self, s: impl Into<Length>) -> Self
pub fn spacing_x(self, s: impl Into<Length>) -> Self
Set only the horizontal gap between cells; leaves vertical spacing untouched.
Sourcepub fn spacing_y(self, s: impl Into<Length>) -> Self
pub fn spacing_y(self, s: impl Into<Length>) -> Self
Set only the vertical gap between rows; leaves horizontal spacing untouched.
Sourcepub fn centre_last_row(self, yes: bool) -> Self
pub fn centre_last_row(self, yes: bool) -> Self
Centre a partial last row horizontally inside the content rect.
Default is false (left-aligned, like other grids).
Trait Implementations§
Auto Trait Implementations§
impl<Msg> Freeze for WrapGrid<Msg>
impl<Msg> !RefUnwindSafe for WrapGrid<Msg>
impl<Msg> !Send for WrapGrid<Msg>
impl<Msg> !Sync for WrapGrid<Msg>
impl<Msg> Unpin for WrapGrid<Msg>where
Msg: Unpin,
impl<Msg> !UnwindSafe for WrapGrid<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