pub enum LayoutNode {
Leaf,
Padding {
padding: EdgeInsets,
child: Box<LayoutNode>,
},
Stack {
children: Vec<LayoutNode>,
},
Column {
children: Vec<LayoutNode>,
},
Clip {
child: Box<LayoutNode>,
},
ScrollY {
scroll_y: f32,
child: Box<LayoutNode>,
},
}Expand description
Retained layout tree node (experimental; coexists with Widget trait layout).
This is not a compatibility shim; it is intended as the future retained layout engine base.
Geometry is in logical pixels and values are not validated for finiteness.
ScrollY::scroll_y is currently retained but deliberately has no effect on
child offsets; callers must not yet rely on this node for visible scrolling.
§Examples
use ailloli_ui_core::{Constraints, EdgeInsets, Scale, Size};
use ailloli_ui_runtime::layout::{LayoutCtx, LayoutNode};
let mut node = LayoutNode::Padding {
padding: EdgeInsets::all(2.0),
child: Box::new(LayoutNode::Leaf),
};
let result = node.layout(&LayoutCtx::new(Scale::new(1.0)), Constraints::tight(20.0, 10.0));
assert_eq!(result.size, Size::new(20.0, 10.0));
assert_eq!(result.children[0].offset.x, 2.0);Variants§
Leaf
Fills the stored maximum constraints and has no children.
Padding
Insets one child by per-side logical pixels.
Fields
padding: EdgeInsetsInsets subtracted from child constraints and added around its size.
child: Box<LayoutNode>Sole retained child.
Stack
Overlays every child at offset (0, 0) and fills the maximum constraints.
Fields
children: Vec<LayoutNode>Children painted in stored order.
Column
Places children top-to-bottom, giving each the full maximum height.
Fields
children: Vec<LayoutNode>Children laid out in stored order; heights are summed then constrained.
Clip
Replaces one child’s bounds with a rectangular clip matching its size.
Fields
child: Box<LayoutNode>Sole clipped child.
ScrollY
Measures a vertically unbounded child inside a fixed viewport.
Fields
child: Box<LayoutNode>Content measured with infinite maximum height.
Implementations§
Source§impl LayoutNode
Provides the operations defined for LayoutNode.
impl LayoutNode
Provides the operations defined for LayoutNode.
Sourcepub fn layout(
&mut self,
_ctx: &LayoutCtx<'_>,
constraints: Constraints,
) -> LayoutResult
pub fn layout( &mut self, _ctx: &LayoutCtx<'_>, constraints: Constraints, ) -> LayoutResult
Recursively lays out this experimental node tree.
Leaf and Stack use the raw maximum constraints, so an unbounded axis
can produce an infinite size. Column does not reduce remaining height
between children. Padding preserves only child geometry, while child
clips, overlays, and artifacts are not propagated into its parent result.
ScrollY clips to the viewport but currently ignores its scroll_y
value and does not translate child geometry.
§Panics
Constraint operations may panic when normalized bounds contain NaN.
§Examples
use ailloli_ui_core::{Constraints, Scale, Size};
use ailloli_ui_runtime::layout::{LayoutCtx, LayoutNode};
let mut node = LayoutNode::Column {
children: vec![LayoutNode::Leaf, LayoutNode::Leaf],
};
let result = node.layout(&LayoutCtx::new(Scale::new(1.0)), Constraints::tight(10.0, 5.0));
assert_eq!(result.size, Size::new(10.0, 5.0));
assert_eq!(result.children[1].offset.y, 5.0);Trait Implementations§
Source§impl Clone for LayoutNode
impl Clone for LayoutNode
Source§fn clone(&self) -> LayoutNode
fn clone(&self) -> LayoutNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LayoutNode
impl RefUnwindSafe for LayoutNode
impl Send for LayoutNode
impl Sync for LayoutNode
impl Unpin for LayoutNode
impl UnwindSafe for LayoutNode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.