Skip to main content

WidgetTree

Struct WidgetTree 

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

The widget tree: a thin, typed wrapper over tree_arena::TreeArena.

Implementations§

Source§

impl WidgetTree

Source

pub fn new() -> Self

Create an empty tree.

Source

pub fn insert_root(&mut self, pod: WidgetPod) -> WidgetId

Insert pod as a root of the tree, returning its id.

Source

pub fn insert_child( &mut self, parent: WidgetId, pod: WidgetPod, ) -> Option<WidgetId>

Insert pod as a child of parent; None if parent is not in the tree.

Source

pub fn pod(&self, id: WidgetId) -> Option<&WidgetPod>

Shared access to the pod with the given id, anywhere in the tree.

Source

pub fn pod_mut(&mut self, id: WidgetId) -> Option<&mut WidgetPod>

Mutable access to the pod with the given id, anywhere in the tree.

Source

pub fn roots(&self) -> Vec<WidgetId>

The tree’s root ids, in insertion order.

Source

pub fn children(&self, id: WidgetId) -> Vec<WidgetId>

The children of id in insertion order; empty if id is absent or childless.

Source

pub fn inspect(&self) -> Vec<InspectNode>

A read-only pre-order snapshot of the whole retained tree (siblings in declaration order).

Covers both child mechanisms: arena children, then the ChildPods a widget publishes through Widget::visit_children (a container that does not override it reads as a leaf). Bounds come from the last layout pass, so call it after one or the rects are zero-sized.

Source

pub fn inspect_layout_dirty(&self) -> Vec<(WidgetId, bool)>

Per-node layout-dirty state for tooling and tests: one (id, layout_dirty) pair per node WidgetTree::inspect reports, in its order, so the two zip.

A ChildPod reports ChildPod::is_layout_dirty; an arena WidgetPod always reports false (the root lays it out unconditionally). Kept beside inspect so the plain InspectNode shape does not change.

Source

pub fn inspect_paint_dirty(&self) -> Vec<(WidgetId, bool)>

Per-node paint-dirty state: the twin of WidgetTree::inspect_layout_dirty reporting ChildPod::is_paint_dirty; an arena WidgetPod reports false.

Trait Implementations§

Source§

impl Default for WidgetTree

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> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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.