Skip to main content

UiTree

Struct UiTree 

Source
pub struct UiTree { /* private fields */ }
Expand description

A tree of UI nodes, stored as an arena.

Implementations§

Source§

impl UiTree

Source

pub fn new(root: impl UiNode) -> Self

Create a new UI tree with the given root node.

Source

pub fn add_node(&mut self, node: impl UiNode) -> NodeIndex

Add a node to the arena.

Source

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.

Source

pub fn get_cache(&self, index: NodeIndex) -> Option<&NodeCache>

Get a reference to the cached layout information for a node.

Source

pub fn get_node(&self, index: NodeIndex) -> Option<&dyn UiNode>

Get a reference to a node.

Source

pub fn get_node_mut(&mut self, index: NodeIndex) -> Option<&mut dyn UiNode>

Get a mutable reference to a node.

Source

pub fn get_root(&self) -> &dyn UiNode

Get a reference to the root node.

Source

pub fn get_root_mut(&mut self) -> &mut dyn UiNode

Get a mutable reference to the root node.

Source

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

Source

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

Source

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.

Source

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.

Auto Trait Implementations§

§

impl Freeze for UiTree

§

impl !RefUnwindSafe for UiTree

§

impl !Send for UiTree

§

impl !Sync for UiTree

§

impl Unpin for UiTree

§

impl UnsafeUnpin for UiTree

§

impl !UnwindSafe for UiTree

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