Skip to main content

LayoutTree

Enum LayoutTree 

Source
pub enum LayoutTree {
    Leaf {
        id: PaintId,
        chrome: Chrome,
        natural: Option<NaturalRef>,
    },
    Vbox {
        items: Vec<Item>,
        chrome: Chrome,
    },
    Hbox {
        items: Vec<Item>,
        chrome: Chrome,
    },
}

Variants§

§

Leaf

Terminal node; the host matches on PaintId in its paint dispatcher. Carries its own Chrome so leaves can have a border/title without a synthetic wrapper container. natural, when set, overrides the active LeafSizer for this leaf’s natural-size reporting.

Fields

§chrome: Chrome
§

Vbox

Vertical container; children stack top-to-bottom.

Fields

§items: Vec<Item>
§chrome: Chrome
§

Hbox

Horizontal container; children pack left-to-right.

Fields

§items: Vec<Item>
§chrome: Chrome

Implementations§

Source§

impl LayoutTree

Source

pub fn vbox(items: Vec<Item>) -> Self

Vertical container. Use .with_gap / .with_border / .with_title to add chrome.

Source

pub fn hbox(items: Vec<Item>) -> Self

Horizontal container. Use .with_gap / .with_border / .with_title to add chrome.

Source

pub fn leaf(id: impl Into<PaintId>) -> Self

Terminal leaf. Accepts anything Into<PaintId>.

Source

pub fn with_natural(self, n: NaturalRef) -> Self

Attach a Natural hook to a leaf node so it can drive its own Fit size. No-op for containers.

Source

pub fn chrome_mut(&mut self) -> &mut Chrome

Source

pub fn chrome(&self) -> &Chrome

Source

pub fn with_gap(self, g: u16) -> Self

Source

pub fn with_justify(self, justify: Justify) -> Self

Source

pub fn with_padding(self, p: u16) -> Self

Source

pub fn with_border(self, b: Border) -> Self

Source

pub fn with_title(self, t: impl Into<Line<'static>>) -> Self

Source

pub fn set_title(&mut self, t: Option<Line<'static>>)

Replace the root chrome’s title in place.

Source

pub fn set_border(&mut self, b: Option<Border>)

Replace the root chrome’s border.

Source

pub fn contains_leaf(&self, id: impl Into<PaintId>) -> bool

Whether id appears as a leaf in this tree (depth-first structural check).

Source

pub fn leaves_in_order(&self) -> Vec<PaintId>

All leaf PaintIds in depth-first declaration order.

Source

pub fn natural_size(&self, cap: (u16, u16)) -> (u16, u16)

Natural (width, height) bounded by cap. Fill contributes 0; Fit contributes the leaf’s natural size from the default NoopSizer (also 0); chrome (border, gap) is added on top. Result is always <= cap.

Source

pub fn natural_size_with( &self, cap: (u16, u16), sizer: &dyn LeafSizer, ) -> (u16, u16)

Natural (width, height) bounded by cap, asking sizer for each leaf’s intrinsic size. Fit contributes the sizer’s reported size on the primary axis; Fill always contributes 0. Chrome (border, gap) is added on top. Result is always <= cap.

Trait Implementations§

Source§

impl Clone for LayoutTree

Source§

fn clone(&self) -> LayoutTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutTree

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<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.