Struct Layout

Source
pub struct Layout(/* private fields */);
Expand description

Represents a layout tree which is the main building block of a UI in Zi.

Each node in the layout tree is one

  1. A component, any type implementing Component.
  2. A flex container that groups multiple Layouts, represented by Container.
  3. A canvas which corresponds to the raw content in a region, represented by Canvas.

Implementations§

Source§

impl Layout

Source

pub fn container( direction: FlexDirection, items: impl IntoIterator<Item = Item>, ) -> Self

Creates a new flex container with a specified direction and containing the provided items.

This is a utility function that builds a container and converts it to a Layout. It is equivalent to calling Container::new(direction, items).into().

Source

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 that builds a container and converts it to a Layout. It is equivalent to calling Container::column(items).into().

Source

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.

This is a utility function that builds a container and converts it to a Layout. It is equivalent to calling Container::column_reverse(items).into().

Source

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.

This is a utility function that builds a container and converts it to a Layout. It is equivalent to calling Container::row(items).into().

Source

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.

This is a utility function that builds a container and converts it to a Layout. It is equivalent to calling Container::row_reverse(items).into().

Trait Implementations§

Source§

impl From<Canvas> for Layout

Source§

fn from(canvas: Canvas) -> Self

Converts to this type from the input type.
Source§

impl From<Container> for Layout

Source§

fn from(container: Container) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Layout

§

impl !RefUnwindSafe for Layout

§

impl !Send for Layout

§

impl !Sync for Layout

§

impl Unpin for Layout

§

impl !UnwindSafe for Layout

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.