Skip to main content

Tree

Struct Tree 

Source
pub struct Tree {
Show 40 fields pub keys: Vec<Key>, pub origins: Vec<OriginId>, pub specs: Vec<NodeSpec>, pub content: Vec<NodeContent>, pub parent: Vec<u32>, pub first_child: Vec<u32>, pub last_child: Vec<u32>, pub next_sibling: Vec<u32>, pub size: Vec<Size>, pub pos: Vec<Vec2>, pub scroll_max: Vec<Vec2>, pub line: Vec<u32>, pub baseline: Vec<f32>, pub any_float: bool, pub any_calc_bound: bool, pub any_node_float: bool, pub any_wrap: bool, pub any_baseline: bool, pub any_table: bool, pub any_gradient: bool, pub any_text: bool, pub any_line: bool, pub grow_scratch: Vec<u8>, pub any_clip: bool, pub any_rounded_clip: bool, pub any_opacity: bool, pub any_modal: bool, pub any_region: bool, pub any_slide: bool, pub any_layout: bool, pub any_context_menu: bool, pub any_scroll_handler: bool, pub any_drop: bool, pub any_exit: bool, pub any_animate: bool, pub indexed: Vec<(u32, u64)>, pub row_counts: Vec<(u32, u64)>, pub fills: Vec<(Key, u32, u32)>, pub any_selectable: bool, pub host_area: Rect, /* private fields */
}
Expand description

One frame’s nodes as parallel arrays in preorder; see the module docs.

Fields§

§keys: Vec<Key>§origins: Vec<OriginId>§specs: Vec<NodeSpec>§content: Vec<NodeContent>§parent: Vec<u32>§first_child: Vec<u32>§last_child: Vec<u32>§next_sibling: Vec<u32>§size: Vec<Size>§pos: Vec<Vec2>§scroll_max: Vec<Vec2>

Max scroll offset per axis (zero for non-scroll nodes).

§line: Vec<u32>

Which wrap line of its parent a node sits on, from the main-axis pass. Zero everywhere but under a wrapping container, and the in-flow children of one line are always a contiguous sibling run, so a line is a range rather than a list.

§baseline: Vec<f32>

Each node’s first baseline below its top, logical px, where text measured one (NaN elsewhere). Filled by the fit-height pass, and only on a frame with a baseline row (any_baseline); empty otherwise.

§any_float: bool

Whether any node declares float.

§any_calc_bound: bool

Whether any node declares a size expression as a clamp (a negative max_w, a Min::calc): layout resolves them only then.

§any_node_float: bool

Whether any float is anchored to a node by key (FloatAnchor::Node): the sixth layout pass runs only then.

§any_wrap: bool

Whether any node declares wrap_children.

§any_baseline: bool

Whether any node lines its children up by their baselines (cross_align: Baseline): the layout measures baselines only then.

§any_table: bool

Whether any node is a table (LayoutSpec::table): the column alignment in the layout passes runs only on a frame that has one.

§any_gradient: bool

Whether any node declares a gradient: emission looks for one only on a frame that has one.

§any_text: bool

Whether any node is text (a Text or Edit content).

§any_line: bool

Whether any node is a role="line" row — what a pointer payload inside a key sink is resolved against, so a frame without a custom editor never walks a sink’s subtree for one.

§grow_scratch: Vec<u8>

Scratch for the layout pass’s freeze loop (distribute_run): one byte per in-flow child of the run being resolved, in child order. Sized per run and never cleared, so the allocation is made once and reused by every run of every frame.

§any_clip: bool

Whether any node clips (clip, or an overflow that scrolls).

§any_rounded_clip: bool

Whether any node clips and has a radius, so the clip its descendants inherit is rounded. Separate from any_clip: the per-corner bookkeeping is skipped for the ordinary square clip.

§any_opacity: bool

Whether any node fades (opacity below one).

§any_modal: bool

Whether any node declares modal.

§any_region: bool

Whether any node declares focus_region.

§any_slide: bool

Whether any node eases its position (slide, or an enter with an offset) under a transition.

§any_layout: bool

Whether any node declares on_layout, so the rect report can skip the walk.

§any_context_menu: bool

Whether any node declares on_context_menu, so a hit region’s walk for the menu it inherits is skipped wholesale on a frame that offers none.

§any_scroll_handler: bool

Some node declared on_scroll; emission reads the row per node only then.

§any_drop: bool

Some node declared on_drop: a hit region’s walk for the zone it inherits is skipped wholesale on a frame with none.

§any_exit: bool

Whether any node declares a workable exit (one under a transition). Gates the tree swap and the key diff.

§any_animate: bool

Whether any node asked for the next frame (animate): one node asking is the whole window asking.

§indexed: Vec<(u32, u64)>

The data index of every node opened with one (open_indexed), by node. A side list rather than a column, because it is a virtual list’s rows and nothing else: a frame that builds none is one empty Vec.

What it is for: a selection endpoint in a row that is not built can still be ordered against the rows that are, because a row’s index says where it sits in the data even when nothing on screen says where it sits in the frame.

§row_counts: Vec<(u32, u64)>

How many indexed rows a node’s virtual list has, built or not (rowCount), by node. A side list for the reason indexed is one. What it is for: Select All inside a selectable virtual list is the data, rows 0..count, not the rows the frame happened to build — and the count is the one thing about the data the core cannot see.

§fills: Vec<(Key, u32, u32)>

The node range every slot fill opened, by the slot’s key: (slot, first, end) over node indices, innermost fill first (a fill records itself after the fills inside it). A side list for the reason indexed is one — a frame with no extension is one empty Vec — and what stamps UiEvent::slot, so a host that fills many slots from one extension can route an event by the slot it came from without stamping every payload.

§any_selectable: bool

Whether any node declares selectable. False on every frame of an app that never asks for one, which is what keeps the scope walk and the off-screen places of tier 2 off those frames entirely.

§host_area: Rect

The box a FloatConfig::viewport() float of the host’s resolves against, in window coordinates: the whole window, or what the devtools’ dock leaves of it. A zero rect means the window. The devtools’ own nodes always use the window.

Implementations§

Source§

impl Tree

Source

pub fn subtree_end(&self, i: usize) -> usize

One past the last node of i’s subtree. Preorder storage makes a subtree a contiguous index range ending at the next node that is a sibling of i or of one of its ancestors.

Source§

impl Tree

Source

pub fn new() -> Tree

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn index_of(&self, key: Key) -> Option<usize>

The index of the node key names in this frame, if it is here. A linear scan: the one place to swap it for a map if a profile asks.

Source

pub fn region_parent(&self, i: usize) -> u32

The parent an ancestor walk that means “where is this shown” takes: the node’s parent, except for a float anchored to a node by key, whose walk continues from the anchor (FloatAnchor::Node). NIL past the root, and for an anchor the frame does not have.

Source

pub fn clear(&mut self)

Clears contents but keeps allocations for the next frame.

Source

pub fn slot_of(&self, i: usize) -> Option<Key>

The innermost slot fill node i was opened inside, if any.

Source

pub fn note(&mut self, spec: &NodeSpec, content: &NodeContent)

Notes what a spec asks of the frame, so a pass whose work exists for one feature can skip it when no node declared that feature. Called by push for every node, and by the root paths that replace a spec in place — the one door, so a leaf cannot forget a flag a box would have set (an image once set two of these and painted opaque when it was the frame’s only fade).

Each boxed group is tested once, not once per flag it can set: a node declaring no events and no animation is done after two null checks (C15).

Source

pub fn push( &mut self, parent: u32, key: Key, origin: OriginId, spec: NodeSpec, content: NodeContent, ) -> u32

Source

pub fn children(&self, i: u32) -> ChildIter<'_> ⓘ

Trait Implementations§

Source§

impl Default for Tree

Source§

fn default() -> Tree

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnsafeUnpin for Tree

§

impl UnwindSafe for Tree

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more