pub struct UiTree { /* private fields */ }Expand description
A tree of UI nodes, stored as an arena.
Implementations§
Source§impl UiTree
impl UiTree
Sourcepub fn remove_node(&mut self, index: NodeIndex)
pub fn remove_node(&mut self, index: NodeIndex)
Remove a node and all of its children from the arena.
§Panics
If the index is invalid or the tree is malformed.
Also panics if the root node is removed.
Sourcepub fn get_cache(&self, index: NodeIndex) -> Option<&NodeCache>
pub fn get_cache(&self, index: NodeIndex) -> Option<&NodeCache>
Get a reference to the cached layout information for a node.
Sourcepub fn get_node_mut(&mut self, index: NodeIndex) -> Option<&mut dyn UiNode>
pub fn get_node_mut(&mut self, index: NodeIndex) -> Option<&mut dyn UiNode>
Get a mutable reference to a node.
Sourcepub fn get_root_mut(&mut self) -> &mut dyn UiNode
pub fn get_root_mut(&mut self) -> &mut dyn UiNode
Get a mutable reference to the root node.
Sourcepub fn calculate_layout(&mut self, root_rect: Rect) -> bool
pub fn calculate_layout(&mut self, root_rect: Rect) -> bool
Calculate the layout information for all nodes in the tree. This is equivalent to calling
calculate_layout_ex with the default configuration.
Returns true if root_rect preserves minimum size requirements. If the given
space is too small, false is returned, but the cache will still be updated. The root node
will be treated as having (Full, Full) alignment.
Nodes that are not visible will be given a minimum size of (0, 0).
§Panics
If the tree is malformed
Sourcepub fn calculate_layout_ex(
&mut self,
root_rect: Rect,
config: CalculateLayoutConfig,
) -> bool
pub fn calculate_layout_ex( &mut self, root_rect: Rect, config: CalculateLayoutConfig, ) -> bool
Calculate the layout information for all nodes in the tree, with additional control of the process.
If force_good is true, ensures that the minimum size of the root node is met, even if
that would exceed the provided rect. If false, returns whether the minimum size of the
root node is met.
If align_root is true, applies the root node’s alignment instead of ignoring it.
§Panics
If the tree is malformed
Sourcepub fn walk_root(&mut self, walker: &mut impl UiWalker, use_visible: bool)
pub fn walk_root(&mut self, walker: &mut impl UiWalker, use_visible: bool)
Walks the entire tree, starting from the root, with the given walker. See
walk_node.
If use_visible is true, only nodes that are visible will be visited.
Sourcepub fn walk_node(
&mut self,
index: NodeIndex,
walker: &mut impl UiWalker,
use_visible: bool,
)
pub fn walk_node( &mut self, index: NodeIndex, walker: &mut impl UiWalker, use_visible: bool, )
Walks a single node and its children, with the given walker.
First, the walker receives enter with the node and its cached rect and index.
Then, any and all children are walked in the order returned by
UiNode::get_visible_children
. Finally, the walker receives leave.
Parents are always visited before their children.
Every call to enter will be matched with a call to leave.
If use_visible is true, only nodes that are visible will be visited.