pub struct LayoutEngine { /* private fields */ }Implementations§
Source§impl LayoutEngine
impl LayoutEngine
pub fn new() -> Self
Sourcepub fn set_direction(&mut self, direction: Direction) -> bool
pub fn set_direction(&mut self, direction: Direction) -> bool
Re-resolves every direction-dependent node against direction, returning whether anything changed.
The caller still has to mark the tree dirty and recompute — this only rewrites styles.
This is what lets one build serve both directions: rather than rebuilding the widget tree, each node that was authored logically is resolved again from the intent recorded when it was created.
pub fn new_leaf(&mut self, style: LayoutStyle) -> Result<NodeId, LayoutError>
pub fn new_measured_leaf( &mut self, style: LayoutStyle, measure: MeasureFn, ) -> Result<NodeId, LayoutError>
pub fn new_container( &mut self, style: LayoutStyle, children: &[NodeId], ) -> Result<NodeId, LayoutError>
Sourcepub fn set_style(
&mut self,
node: NodeId,
style: LayoutStyle,
) -> Result<(), LayoutError>
pub fn set_style( &mut self, node: NodeId, style: LayoutStyle, ) -> Result<(), LayoutError>
Replaces node’s declared style, carrying forward whatever the out-of-band mutators below set — a freshly-built style (e.g. from a styled_by closure reacting to an unrelated signal) has no way to know about them.
Sourcepub fn set_children(
&mut self,
parent: NodeId,
children: &[NodeId],
) -> Result<(), LayoutError>
pub fn set_children( &mut self, parent: NodeId, children: &[NodeId], ) -> Result<(), LayoutError>
Replaces parent’s children with children, in order. Used by reactive lists to insert, move,
and drop item nodes as their source collection changes.
Sourcepub fn add_child(
&mut self,
parent: NodeId,
child: NodeId,
) -> Result<(), LayoutError>
pub fn add_child( &mut self, parent: NodeId, child: NodeId, ) -> Result<(), LayoutError>
Appends child to parent’s existing children (unlike [set_children], which replaces them). Used
to attach an overlay’s out-of-flow content to the layout root without touching the root’s other children.
Sourcepub fn remove_child(
&mut self,
parent: NodeId,
child: NodeId,
) -> Result<(), LayoutError>
pub fn remove_child( &mut self, parent: NodeId, child: NodeId, ) -> Result<(), LayoutError>
Detaches child from parent (does not free it — call [remove] afterwards to release the node).
Sourcepub fn remove(&mut self, node: NodeId)
pub fn remove(&mut self, node: NodeId)
Frees a node (and its measure context) from the tree. The caller must have already detached it from
its parent (via [set_children]); a removed node id must not be used again.
pub fn mark_dirty(&mut self, node: NodeId) -> Result<(), LayoutError>
Sourcepub fn is_size_auto(&self, node: NodeId) -> (bool, bool)
pub fn is_size_auto(&self, node: NodeId) -> (bool, bool)
Whether the node’s width/height are auto (i.e. content-sized).
Sourcepub fn set_width(&mut self, node: NodeId, width: Option<f32>)
pub fn set_width(&mut self, node: NodeId, width: Option<f32>)
Sets the node’s width to a definite length, or back to auto when None.
Sourcepub fn set_height(&mut self, node: NodeId, height: Option<f32>)
pub fn set_height(&mut self, node: NodeId, height: Option<f32>)
Sets the node’s height to a definite length, or back to auto when None.
Sourcepub fn set_min_height(&mut self, node: NodeId, height: Option<f32>)
pub fn set_min_height(&mut self, node: NodeId, height: Option<f32>)
Sets the node’s minimum height to a definite length, or clears it (auto) when None. Lets a
content-measured leaf (e.g. a code editor’s text area) fill a viewport it would otherwise underflow.
Sourcepub fn make_flex_row(&mut self, node: NodeId)
pub fn make_flex_row(&mut self, node: NodeId)
Turns node into a flex row after construction, registering it as direction-following so a later
RTL flip reverses it like an authored flex_row. What a reconciling list calls when it learns —
from the container it is being attached to — that its items run horizontally.
Sourcepub fn is_row(&self, node: NodeId) -> bool
pub fn is_row(&self, node: NodeId) -> bool
Whether the node lays its children along the main (horizontal) axis — a flex row. A column, or any
non-row node (missing / errored), is false. A transparent fragment reads its host’s axis to know
which margin edge a per-item gap sits on.
Sourcepub fn set_leading_margin(&mut self, node: NodeId, is_row: bool, px: f32)
pub fn set_leading_margin(&mut self, node: NodeId, is_row: bool, px: f32)
Sets the node’s leading margin on the host’s main axis (top for a column; for a row, whichever
horizontal edge the host lays out from) to px, leaving the other edges untouched. A transparent
for … gap:N uses this to space its items by a gap without a container of its own: the item cell
carries the gap as a margin instead.
Sourcepub fn is_display_none(&self, node: NodeId) -> bool
pub fn is_display_none(&self, node: NodeId) -> bool
Whether this node is itself out of layout flow. Says nothing about its ancestors — walk
carries that down as it descends, and a caller asking about one node has to climb for itself.
Sourcepub fn set_display(&mut self, node: NodeId, visible: bool)
pub fn set_display(&mut self, node: NodeId, visible: bool)
Toggles a node in or out of layout flow. A hidden node (Display::None) takes no space and lays out none of its subtree; a visible node returns to whichever display it declared. Used for responsive show/hide (e.g. collapsing a sidebar on narrow windows).