pub struct Container { /* private fields */ }
Expand description
A flex container with a specified direction and items.
Implementations
sourceimpl Container
impl Container
sourcepub fn new(
direction: FlexDirection,
items: impl IntoIterator<Item = Item>
) -> Self
pub fn new(
direction: FlexDirection,
items: impl IntoIterator<Item = Item>
) -> Self
Creates a new flex container with a specified direction and containing the provided items.
Example
let container = Container::new(
FlexDirection::Column,
[
Item::auto(Text::with(TextProperties::new().content("Item 1"))),
Item::auto(Text::with(TextProperties::new().content("Item 2"))),
],
);
sourcepub fn empty(direction: FlexDirection) -> Self
pub fn empty(direction: FlexDirection) -> Self
Creates a new empty flex container with a specified direction.
sourcepub fn push(&mut self, item: Item) -> &mut Self
pub fn push(&mut self, item: Item) -> &mut Self
Adds an item to the end of the container.
Example
let mut container = Container::empty(FlexDirection::Row);
container
.push(Item::auto(Text::with(TextProperties::new().content("Item 1"))))
.push(Item::auto(Text::with(TextProperties::new().content("Item 2"))));
sourcepub fn column(items: impl IntoIterator<Item = Item>) -> Self
pub fn column(items: impl IntoIterator<Item = Item>) -> Self
Creates a container with column (vertical) layout.
Child components are laid out from top to bottom. Pass in the children as an something that can be converted to an iterator of items, e.g. an array of items.
This is a utility function and it is equivalent to calling
Container::new(FlexDirection::Column, items)
.
sourcepub fn column_reverse(items: impl IntoIterator<Item = Item>) -> Self
pub fn column_reverse(items: impl IntoIterator<Item = Item>) -> Self
Creates a container with reversed column (vertical) layout.
Child components are laid out from bottom to top. Pass in the children as an something that can be converted to an iterator of items, e.g. an array of items.
sourcepub fn row(items: impl IntoIterator<Item = Item>) -> Self
pub fn row(items: impl IntoIterator<Item = Item>) -> Self
Creates a container with row (horizontal) layout.
Child components are laid out from left to right. Pass in the children as an something that can be converted to an iterator of items, e.g. an array of items.
sourcepub fn row_reverse(items: impl IntoIterator<Item = Item>) -> Self
pub fn row_reverse(items: impl IntoIterator<Item = Item>) -> Self
Creates a container with reversed row (horizontal) layout.
Child components are laid out from right to left. Pass in the children as an something that can be converted to an iterator of items, e.g. an array of items.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Container
impl !Send for Container
impl !Sync for Container
impl Unpin for Container
impl !UnwindSafe for Container
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more