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.
Vbox
Vertical container; children stack top-to-bottom.
Hbox
Horizontal container; children pack left-to-right.
Implementations§
Source§impl LayoutTree
impl LayoutTree
Sourcepub fn vbox(items: Vec<Item>) -> Self
pub fn vbox(items: Vec<Item>) -> Self
Vertical container. Use .with_gap / .with_border / .with_title to add chrome.
Sourcepub fn hbox(items: Vec<Item>) -> Self
pub fn hbox(items: Vec<Item>) -> Self
Horizontal container. Use .with_gap / .with_border / .with_title to add chrome.
Sourcepub fn with_natural(self, n: NaturalRef) -> Self
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.
pub fn chrome_mut(&mut self) -> &mut Chrome
pub fn chrome(&self) -> &Chrome
pub fn with_gap(self, g: u16) -> Self
pub fn with_justify(self, justify: Justify) -> Self
pub fn with_padding(self, p: u16) -> Self
pub fn with_border(self, b: Border) -> Self
pub fn with_title(self, t: impl Into<Line<'static>>) -> Self
Sourcepub fn set_title(&mut self, t: Option<Line<'static>>)
pub fn set_title(&mut self, t: Option<Line<'static>>)
Replace the root chrome’s title in place.
Sourcepub fn set_border(&mut self, b: Option<Border>)
pub fn set_border(&mut self, b: Option<Border>)
Replace the root chrome’s border.
Sourcepub fn contains_leaf(&self, id: impl Into<PaintId>) -> bool
pub fn contains_leaf(&self, id: impl Into<PaintId>) -> bool
Whether id appears as a leaf in this tree (depth-first structural check).
Sourcepub fn leaves_in_order(&self) -> Vec<PaintId>
pub fn leaves_in_order(&self) -> Vec<PaintId>
All leaf PaintIds in depth-first declaration order.
Sourcepub fn natural_size(&self, cap: (u16, u16)) -> (u16, u16)
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.
Sourcepub fn natural_size_with(
&self,
cap: (u16, u16),
sizer: &dyn LeafSizer,
) -> (u16, u16)
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
impl Clone for LayoutTree
Source§fn clone(&self) -> LayoutTree
fn clone(&self) -> LayoutTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more