Enum LayoutNode

Source
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: EdgeInsets

Insets 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

§scroll_y: f32

Requested vertical offset in logical pixels; currently stored but ignored.

§child: Box<LayoutNode>

Content measured with infinite maximum height.

Implementations§

Source§

impl LayoutNode

Provides the operations defined for LayoutNode.

Source

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

Source§

fn clone(&self) -> LayoutNode

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutNode

Source§

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

Formats the value using the given formatter. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,