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
impl VerticalLayout
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new VerticalLayout.
pub fn set_id(self, id: GlobalId) -> Self
pub fn with_label(self, label: &str) -> Self
Sourcepub fn add_children<I>(self, children: I) -> Selfwhere
I: IntoIterator<Item: Layout + 'static>,
pub fn add_children<I>(self, children: I) -> Selfwhere
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(),
]);pub fn add_boxed_children<I>(self, children: I) -> Self
Sourcepub fn main_axis_alignment(self, main_axis_alignment: AxisAlignment) -> Self
pub fn main_axis_alignment(self, main_axis_alignment: AxisAlignment) -> Self
Set the main axis alignment
Sourcepub fn cross_axis_alignment(self, cross_axis_alignment: AxisAlignment) -> Self
pub fn cross_axis_alignment(self, cross_axis_alignment: AxisAlignment) -> Self
Set the cross axis alignment.
Sourcepub fn main_axis_overflow(&self) -> bool
pub fn main_axis_overflow(&self) -> bool
Returns true if a VerticalLayout’s children are overflowing its main-axis
(y-axis).
Sourcepub fn cross_axis_overflow(&self) -> bool
pub fn cross_axis_overflow(&self) -> bool
Returns true if a VerticalLayout’s children are overflowing its cross-axis
(x-axis).
Sourcepub fn maximum_height(self, height: f32) -> Self
pub fn maximum_height(self, height: f32) -> Self
Sets the maximum height of the layout node.
Sourcepub fn min_height(self, height: f32) -> Self
pub fn min_height(self, height: f32) -> Self
Sets the minimum height of the layout node.
Sourcepub fn intrinsic_size(self, intrinsic_size: IntrinsicSize) -> Self
pub fn intrinsic_size(self, intrinsic_size: IntrinsicSize) -> Self
Sets the intrinsic size of the layout node.
Trait Implementations§
Source§impl Debug for VerticalLayout
impl Debug for VerticalLayout
Source§impl Default for VerticalLayout
impl Default for VerticalLayout
Source§fn default() -> VerticalLayout
fn default() -> VerticalLayout
Returns the “default value” for a type. Read more
Source§impl<I> From<I> for VerticalLayoutwhere
I: IntoIterator<Item: Layout + 'static>,
impl<I> From<I> for VerticalLayoutwhere
I: IntoIterator<Item: Layout + 'static>,
Source§impl Layout for VerticalLayout
impl Layout for VerticalLayout
fn label(&self) -> String
fn set_position(&mut self, position: Position)
fn set_x(&mut self, x: f32)
fn set_y(&mut self, y: f32)
fn children(&self) -> &[Box<dyn Layout>]
Source§fn constraints(&self) -> BoxConstraints
fn constraints(&self) -> BoxConstraints
Returns the
BoxConstraints of the Layout.Source§fn get_intrinsic_size(&self) -> IntrinsicSize
fn get_intrinsic_size(&self) -> IntrinsicSize
Returns the
IntrinsicSize of the Layoutfn set_max_height(&mut self, height: f32)
fn set_max_width(&mut self, width: f32)
fn set_min_height(&mut self, height: f32)
fn set_min_width(&mut self, width: f32)
Source§fn collect_errors(&mut self) -> Vec<LayoutError>
fn collect_errors(&mut self) -> Vec<LayoutError>
Collect all the errors from the node tree.
Source§fn iter(&self) -> LayoutIter<'_> ⓘ
fn iter(&self) -> LayoutIter<'_> ⓘ
Returns an iterator over the layout tree.
Source§fn solve_min_constraints(&mut self) -> (f32, f32)
fn solve_min_constraints(&mut self) -> (f32, f32)
Solve the minimum constraints of each
Layout node recursivelySource§fn solve_max_constraints(&mut self)
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)
fn update_size(&mut self)
Update the size of every
LayoutNode based on it’s size and constraints.Source§fn position_children(&mut self)
fn position_children(&mut self)
Position the layout nodes after size calculations.
fn as_layout_node(&self) -> LayoutNode
Auto Trait Implementations§
impl Freeze for VerticalLayout
impl !RefUnwindSafe for VerticalLayout
impl !Send for VerticalLayout
impl !Sync for VerticalLayout
impl Unpin for VerticalLayout
impl !UnwindSafe for VerticalLayout
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
Mutably borrows from an owned value. Read more