ViewTree

Struct ViewTree 

Source
pub struct ViewTree {
    pub stats: TreeStats,
    pub removed_ids: Vec<NodeId>,
    /* private fields */
}
Expand description

A persistent view tree that supports incremental updates.

Fields§

§stats: TreeStats

Statistics for the last reconcile operation.

§removed_ids: Vec<NodeId>

Nodes removed during the last update (needed to sync external systems like Taffy).

Implementations§

Source§

impl ViewTree

Source

pub fn new() -> Self

Create a new empty tree.

Source

pub fn generation(&self) -> u64

Get the current generation.

Source

pub fn root(&self) -> Option<NodeId>

Get the root node ID.

Source

pub fn get(&self, id: NodeId) -> Option<&TreeNode>

Get a node by ID.

Source

pub fn get_mut(&mut self, id: NodeId) -> Option<&mut TreeNode>

Get a mutable node by ID.

Source

pub fn get_by_view_id(&self, view_id: ViewId) -> Option<&TreeNode>

Get a node by ViewId.

Source

pub fn len(&self) -> usize

Get the number of nodes in the tree.

Source

pub fn is_empty(&self) -> bool

Check if the tree is empty.

Source

pub fn is_dirty(&self, id: NodeId) -> bool

Check if a node is marked dirty.

Source

pub fn dirty_nodes(&self) -> &FxHashSet<NodeId>

Get the set of dirty nodes.

Source

pub fn clear_dirty(&mut self)

Clear the dirty set (after layout).

Source

pub fn mark_dirty(&mut self, id: NodeId)

Mark a node as needing re-layout.

Source

pub fn update(&mut self, new_root: &View) -> NodeId

Update the tree from a new View, performing incremental reconciliation. Returns the root NodeId.

Source

pub fn set_layout( &mut self, id: NodeId, rect: Rect, screen_rect: Rect, constraints: LayoutConstraints, )

Set cached layout for a node.

Source

pub fn iter(&self) -> impl Iterator<Item = &TreeNode>

Iterate over all nodes (parent before children).

Source

pub fn iter_with_ids(&self) -> impl Iterator<Item = (NodeId, &TreeNode)>

Iterate over all nodes with their IDs.

Source

pub fn walk<F>(&self, f: F)
where F: FnMut(&TreeNode, u32) -> bool,

Walk the tree from root, calling f for each node. Returns early if f returns false.

Source

pub fn children(&self, id: NodeId) -> Option<&[NodeId]>

Get children of a node.

Trait Implementations§

Source§

impl Default for ViewTree

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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.