VerticalLayout

Struct VerticalLayout 

Source
pub struct VerticalLayout { /* private fields */ }
Expand description

A Layout node that arranges it’s children vertically.

This layout’s main axis is the y-axis, and it’s cross axis is the x-axis.

§Example

use cascada::{solve_layout, AxisAlignment, EmptyLayout, IntrinsicSize, Padding, Size, VerticalLayout};

let child = EmptyLayout::new()
    .intrinsic_size(IntrinsicSize::fixed(12.0,50.0));


let mut layout = VerticalLayout::new()
    .spacing(12)
    .padding(Padding::all(24.0))
    .add_children([child.clone(),child])
    .main_axis_alignment(AxisAlignment::Center);

solve_layout(&mut layout, Size::unit(500.0));

§Algorithm

  • BoxSizing::Shrink: The minimum width is set to the sum of the minimum widths of all the children + spacing + horizontal padding.
  • BoxSizing::Fixed: The minimum width is set to the fixed width regardless of all other properties.

If the intrinsic height is BoxSizing::Shrink then the final height will be the sum of the all child node heights + vertical padding + spacing.

Implementations§

Source§

impl VerticalLayout

Source

pub fn new() -> Self

Creates a new VerticalLayout.

Source

pub fn set_id(self, id: GlobalId) -> Self

Source

pub fn with_label(self, label: &str) -> Self

Source

pub fn add_child(self, child: impl Layout + 'static) -> Self

Appends a Layout node to the list of children.

§Example
use cascada::{EmptyLayout,VerticalLayout};

VerticalLayout::new()
    .add_child(EmptyLayout::default())
    .add_child(VerticalLayout::default());
Source

pub fn add_children<I>(self, children: I) -> Self
where I: IntoIterator<Item: Layout + 'static>,

Add multiple child nodes to the list of children.

§Example
use cascada::{VerticalLayout,EmptyLayout};

VerticalLayout::new()
    .add_children([
        EmptyLayout::new(),
        EmptyLayout::new(),
        EmptyLayout::new(),
    ]);
Source

pub fn add_boxed_children<I>(self, children: I) -> Self
where I: IntoIterator<Item = Box<dyn Layout + 'static>>,

Source

pub fn main_axis_alignment(self, main_axis_alignment: AxisAlignment) -> Self

Set the main axis alignment

Source

pub fn cross_axis_alignment(self, cross_axis_alignment: AxisAlignment) -> Self

Set the cross axis alignment.

Source

pub fn padding(self, padding: Padding) -> Self

Set this layout’s Padding.

Source

pub fn spacing(self, spacing: u32) -> Self

Set this layout’s spacing.

Source

pub fn main_axis_overflow(&self) -> bool

Returns true if a VerticalLayout’s children are overflowing its main-axis (y-axis).

Source

pub fn cross_axis_overflow(&self) -> bool

Returns true if a VerticalLayout’s children are overflowing its cross-axis (x-axis).

Source

pub fn max_width(self, width: f32) -> Self

Sets the maximum width of the layout node.

Source

pub fn maximum_height(self, height: f32) -> Self

Sets the maximum height of the layout node.

Source

pub fn min_width(self, width: f32) -> Self

Sets the minimum width of the layout node.

Source

pub fn min_height(self, height: f32) -> Self

Sets the minimum height of the layout node.

Source

pub fn intrinsic_size(self, intrinsic_size: IntrinsicSize) -> Self

Sets the intrinsic size of the layout node.

Trait Implementations§

Source§

impl Debug for VerticalLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VerticalLayout

Source§

fn default() -> VerticalLayout

Returns the “default value” for a type. Read more
Source§

impl<I> From<I> for VerticalLayout
where I: IntoIterator<Item: Layout + 'static>,

Source§

fn from(iter: I) -> Self

Converts to this type from the input type.
Source§

impl Layout for VerticalLayout

Source§

fn label(&self) -> String

Source§

fn id(&self) -> GlobalId

Get the id of the Layout
Source§

fn position(&self) -> Position

Returns the Position of the Layout
Source§

fn set_position(&mut self, position: Position)

Source§

fn set_x(&mut self, x: f32)

Source§

fn set_y(&mut self, y: f32)

Source§

fn size(&self) -> Size

Returns the Size of the Layout
Source§

fn children(&self) -> &[Box<dyn Layout>]

Source§

fn constraints(&self) -> BoxConstraints

Returns the BoxConstraints of the Layout.
Source§

fn get_intrinsic_size(&self) -> IntrinsicSize

Returns the IntrinsicSize of the Layout
Source§

fn set_max_height(&mut self, height: f32)

Source§

fn set_max_width(&mut self, width: f32)

Source§

fn set_min_height(&mut self, height: f32)

Source§

fn set_min_width(&mut self, width: f32)

Source§

fn collect_errors(&mut self) -> Vec<LayoutError>

Collect all the errors from the node tree.
Source§

fn iter(&self) -> LayoutIter<'_>

Returns an iterator over the layout tree.
Source§

fn solve_min_constraints(&mut self) -> (f32, f32)

Solve the minimum constraints of each Layout node recursively
Source§

fn solve_max_constraints(&mut self)

Solve the max constraints for the children and pass them down the tree
Source§

fn update_size(&mut self)

Update the size of every LayoutNode based on it’s size and constraints.
Source§

fn position_children(&mut self)

Position the layout nodes after size calculations.
Source§

fn bounds(&self) -> Bounds

Returns the Bounds of the Layout
Source§

fn get(&self, id: GlobalId) -> Option<&dyn Layout>

Searches for a Layout node with a matching GlobalId.
Source§

fn as_layout_node(&self) -> LayoutNode

Auto Trait Implementations§

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<L> DebugTree for L
where L: Layout,

Source§

fn print_children(&self, indent: usize)

Source§

fn print(&self, indent: usize)

Source§

fn debug_tree(&self)

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.