Skip to main content

SceneTree

Struct SceneTree 

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

Flat generation-indexed arena holding the entire retained UI scene graph.

Implementations§

Source§

impl SceneTree

Core retained scene graph mutation and traversal operations.

Source

pub fn create_node(&mut self, kind: NodeKind, style: Style) -> NodeId

Allocates a new node of kind with initial style.

§Arguments
  • &Self - Mutable scene tree.
  • NodeKind - Semantic node kind.
  • Style - Initial style.
§Returns
  • NodeId - Generation-checked node handle.
Source

pub fn create_view(&mut self, style: Style) -> NodeId

Creates a container View node.

§Arguments
  • &Self - Mutable scene tree.
  • Style - Initial box style.
§Returns
  • NodeId - Created node handle.
Source

pub fn create_text(&mut self, content: String, style: Style) -> NodeId

Creates a Text node holding content.

§Arguments
  • &Self - Mutable scene tree.
  • String - Initial UTF-8 text.
  • Style - Initial text and box style.
§Returns
  • NodeId - Created text node handle.
Source

pub fn create_input(&mut self, state: InputNodeState, style: Style) -> NodeId

Creates an editable Input node.

§Arguments
  • &Self - Mutable scene tree.
  • InputNodeState - Initial input state.
  • Style - Initial input style.
§Returns
  • NodeId - Created input node handle.
Source

pub fn create_image(&mut self, buffer: ImageBuffer, style: Style) -> NodeId

Creates an Image node displaying buffer.

§Arguments
  • &Self - Mutable scene tree.
  • ImageBuffer - Decoded RGBA8 image buffer.
  • Style - Initial image style.
§Returns
  • NodeId - Created image node handle.
Source

pub fn create_scroll_view(&mut self, style: Style) -> NodeId

Creates a ScrollView container with Overflow::Scroll.

§Arguments
  • &Self - Mutable scene tree.
  • Style - Initial scroll container style.
§Returns
  • NodeId - Created scroll view handle.
Source

pub fn create_canvas( &mut self, style: Style, painter: CanvasDrawCallback, ) -> NodeId

Creates a custom Canvas node bound to painter.

§Arguments
  • &Self - Mutable scene tree.
  • Style - Initial canvas style.
  • CanvasDrawCallback - Draw callback invoked on each paint pass.
§Returns
  • NodeId - Created canvas node handle.
Source

pub fn create_portal(&mut self, style: Style) -> NodeId

Creates an overlay Portal node rendered in the top stacking context.

§Arguments
  • &Self - Mutable scene tree.
  • Style - Initial portal style.
§Returns
  • NodeId - Created portal node handle.
Source

pub fn create_fragment(&mut self) -> NodeId

Creates a logical Fragment grouping node.

§Arguments
  • &Self - Mutable scene tree.
§Returns
  • NodeId - Created fragment node handle.
Source

pub fn get_node(&self, id: NodeId) -> Option<&SceneNode>

Returns an immutable reference to a live node matching id.

§Arguments
  • &Self - Scene tree reference.
  • NodeId - Node handle.
§Returns
  • Option<&SceneNode> - Live node reference if valid.
Source

pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut SceneNode>

Returns a mutable reference to a live node matching id.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Node handle.
§Returns
  • Option<&mut SceneNode> - Mutable live node reference if valid.
Source

pub fn live_node_count(&self) -> usize

Returns total count of live scene nodes.

§Arguments
  • &Self - Scene tree reference.
§Returns
  • usize - Number of live nodes in the arena.
Source

pub fn append_child(&mut self, parent: NodeId, child: NodeId)

Appends child to parent and marks layout and paint dirty upward.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Parent container node.
  • NodeId - Child node to attach.
Source

pub fn append_children(&mut self, parent: NodeId, children: &[NodeId])

Appends multiple children to parent in a single dirty-marking pass with pre-reserved capacity.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Parent container node.
  • &[NodeId] - Ordered child nodes to append.
Source

pub fn replace_children(&mut self, parent: NodeId, new_children: Vec<NodeId>)

Replaces all children of parent with new_children, disposing previous subtrees cleanly.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Parent container node.
  • Vec<NodeId> - Replacement ordered children.
Source

pub fn set_style(&mut self, id: NodeId, style: Style)

Surgically updates a node’s Style, only marking layout dirty when LayoutStyle changed.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target node handle.
  • Style - Replacement compiled style.
Source

pub fn set_text(&mut self, id: NodeId, text: String)

Surgically updates the UTF-8 string of a NodeKind::Text node.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target text node handle.
  • String - Replacement text string.
Source

pub fn set_scroll_offset(&mut self, id: NodeId, offset: Point)

Updates scroll offset on a scroll container without triggering full subtree re-layout.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target scroll container handle.
  • Point - New scroll offset clamped to content bounds.
Source

pub fn set_virtual_scroll( &mut self, id: NodeId, scroll_y: f32, content_height: f32, )

Records virtualized scroll progress (scroll_y, content_height) on id for overlay scrollbar rendering.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target virtualized scroll container.
  • f32 - Active virtual vertical scroll offset in logical pixels.
  • f32 - Full virtualized content height in logical pixels.
Source

pub fn node_screen_bounds(&self, id: NodeId) -> Option<Rect>

Computes screen-space logical bounds for id after subtracting ancestor scroll offsets.

§Arguments
  • &Self - Scene tree reference.
  • NodeId - Target node handle.
§Returns
  • Option<Rect> - Screen-space rectangle if the node is alive.
Source

pub fn start_transition(&mut self, transition: NodeTransition)

Starts or smoothly retargets a paint/transform transition on transition.get_node().

§Arguments
  • &Self - Mutable scene tree.
  • NodeTransition - Transition specification to run.
Source

pub fn tick_transitions(&mut self, dt_secs: f32) -> bool

Advances all active transitions by dt_secs and returns true if any node updated.

§Arguments
  • &Self - Mutable scene tree.
  • f32 - Elapsed frame time in seconds.
§Returns
  • bool - Whether at least one transition ticked on this frame.
Source

pub fn has_active_transitions(&self) -> bool

Returns true while one or more node transitions are still running.

§Arguments
  • &Self - Scene tree reference.
§Returns
  • bool - Whether animations are active.
Source

pub fn attach_lifecycle(&mut self, id: NodeId, hook: Rc<dyn Lifecycle>)

Attaches a Lifecycle hook observer onto id for mount, activate, freeze, resume, unmount, and destroy dispatch.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target scene node handle.
  • Rc<dyn Lifecycle> - Shared lifecycle hook observer.
Source

pub fn collect_subtree_lifecycles( &self, root: NodeId, ) -> Vec<(NodeId, Rc<dyn Lifecycle>)>

Collects all (NodeId, Rc<dyn Lifecycle>) observers in the subtree rooted at root.

§Arguments
  • &Self - Scene tree reference.
  • NodeId - Subtree root handle.
§Returns
  • Vec<(NodeId, Rc<dyn Lifecycle>)> - Ordered observers in pre-order traversal.
Source

pub fn cancel_subtree_transitions(&mut self, root: NodeId)

Cancels any active paint/transform transitions targeting nodes within the subtree rooted at root.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Subtree root handle.
Source

pub fn attach_scope(&mut self, id: NodeId, scope: Scope)

Attaches a reactive Scope to id so it automatically disposes when the node unmounts.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Target node handle.
  • Scope - Reactive ownership scope.
Source

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

Marks id dirty with mask and propagates subtree dirty bits to ancestors in O(depth).

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Mutated node handle.
  • u16 - Dirty flag bits to set.
Source

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

Returns true when id and every ancestor up to the root are alive, non-Display::None, and have positive opacity.

§Arguments
  • &Self - Scene tree reference.
  • NodeId - Target node handle.
§Returns
  • bool - Whether the node is visibly rendered in the scene.
Source

pub fn collect_paint_damage(&mut self, scale: f32) -> DamageRegion

Collects the tight physical damage region from dirty paint/scroll nodes and clears paint dirty flags.

§Arguments
  • &Self - Mutable scene tree.
  • f32 - Active display scale factor.
§Returns
  • DamageRegion - Minimal damaged region, full damage on structural/layout change, or clean when idle.
Source

pub fn dispose_subtree_collect(&mut self, id: NodeId) -> DisposedSubtreePayload

Recursively detaches and recycles id, returning all owned Scopes and Lifecycle observers for borrow-safe finalization.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Subtree root handle to dispose.
§Returns
  • DisposedSubtreePayload - Collected scopes and lifecycle observers to finalize outside any borrow.
Source

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

Recursively removes and disposes id, recycling all arena slots, running lifecycle hooks, and disposing scopes.

§Arguments
  • &Self - Mutable scene tree.
  • NodeId - Subtree root handle to dispose.
Source

pub fn update_focus( &mut self, target: Option<NodeId>, ) -> Vec<(UiEventHandler, UiEvent)>

Updates keyboard focus to target, emitting Blur and Focus events.

§Arguments
  • &Self - Mutable scene tree.
  • Option<NodeId> - Newly focused node, or None to clear focus.
§Returns
  • Vec<(UiEventHandler, UiEvent)> - Callbacks to invoke outside the tree borrow.
Source§

impl SceneTree

Source

pub fn get_nodes(&self) -> &Vec<SceneNode>

Source

pub fn get_mut_nodes(&mut self) -> &mut Vec<SceneNode>

Source

pub fn set_nodes(&mut self, val: Vec<SceneNode>) -> &mut Self

Source

pub fn get_root(&self) -> NodeId

Source

pub fn get_mut_root(&mut self) -> &mut NodeId

Source

pub fn set_root(&mut self, val: NodeId) -> &mut Self

Source

pub fn get_focus(&self) -> FocusManager

Source

pub fn get_mut_focus(&mut self) -> &mut FocusManager

Source

pub fn set_focus(&mut self, val: FocusManager) -> &mut Self

Source

pub fn get_revision(&self) -> u64

Source

pub fn get_mut_revision(&mut self) -> &mut u64

Source

pub fn set_revision(&mut self, val: u64) -> &mut Self

Source

pub fn get_transitions(&self) -> &Vec<NodeTransition>

Source

pub fn get_mut_transitions(&mut self) -> &mut Vec<NodeTransition>

Source

pub fn set_transitions(&mut self, val: Vec<NodeTransition>) -> &mut Self

Source

pub fn get_caret_visible(&self) -> bool

Source

pub fn get_mut_caret_visible(&mut self) -> &mut bool

Source

pub fn set_caret_visible(&mut self, val: bool) -> &mut Self

Trait Implementations§

Source§

impl Debug for SceneTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • std::fmt::Result - Success or failure of the formatting operation.
Source§

impl Default for SceneTree

Default scene tree with a pre-created root View node.

Source§

fn default() -> Self

Allocates a new SceneTree containing a root container node.

§Returns
  • Self - Initialized scene tree.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.