pub struct ExpandedNode {
pub id_chain: Vec<u32>,
pub instance_node: InstanceNodePtr,
pub parent_expanded_node: RefCell<Weak<ExpandedNode>>,
pub containing_component: Weak<ExpandedNode>,
pub stack: Rc<RuntimePropertiesStackFrame>,
pub properties: Rc<RefCell<dyn Any>>,
pub layout_properties: RefCell<Option<LayoutProperties>>,
pub expanded_slot_children: RefCell<Option<Vec<Rc<ExpandedNode>>>>,
pub expanded_and_flattened_slot_children: RefCell<Option<Vec<Rc<ExpandedNode>>>>,
pub attached: RefCell<u32>,
pub occlusion_id: RefCell<u32>,
/* private fields */
}
Fields§
§id_chain: Vec<u32>
Unique ID of this expanded node, roughly encoding an address in the tree, where the first u32 is the instance ID and the subsequent u32s represent addresses within an expanded tree via Repeat.
instance_node: InstanceNodePtr
Pointer to the unexpanded instance_node
underlying this ExpandedNode
parent_expanded_node: RefCell<Weak<ExpandedNode>>
Pointer (Weak
to avoid Rc cycle memory leaks) to the ExpandedNode directly above
this one. Used for e.g. event propagation.
containing_component: Weak<ExpandedNode>
Reference to the component for which this ExpandedNode
is a template member. Used at least for
getting a reference to slot_children for slot
. Option
al because the very root instance node (root component, root instance node)
has a corollary “root component expanded node.” That very root expanded node does not have a containing ExpandedNode component,
thus containing_component
is Option
al.
stack: Rc<RuntimePropertiesStackFrame>
Persistent clone of the state of the [PropertiesTreeShared#runtime_properties_stack
] at the time that this node was expanded (this is expected to remain immutable
through the lifetime of the program after the initial expansion; however, if that constraint changes, this should be
explicitly updated to accommodate.)
properties: Rc<RefCell<dyn Any>>
Each ExpandedNode has a unique “stamp” of computed properties
layout_properties: RefCell<Option<LayoutProperties>>
Properties that are currently re-computed each frame before rendering. Only contains computed_tab atm. Might be possible to retire if tab comp would be part of render pass?
expanded_slot_children: RefCell<Option<Vec<Rc<ExpandedNode>>>>
For component instances only, tracks the expanded slot_children in it’s non-collapsed form (repeat and conditionals still present). This allows repeat/conditionals to update their children (handled in component.rs update_children method)
expanded_and_flattened_slot_children: RefCell<Option<Vec<Rc<ExpandedNode>>>>
Flattened version of the above, where repeat/conditionals are removed recursively and replaced by their children. This is re-computed each frame from the non-collapsed expanded_slot_children after they have been updated.
attached: RefCell<u32>
Flag that is > 0 if this node is part of the root tree. If it is, updates to this nodes children also marks them as attached (+1), triggering mount and dismount on addition/removal. This is needed mainly for slot, since an entire “shadow tree” needs to be expanded and updated for each slot child, but only the ones that have a “connected” slot should trigger mount/dismount updates
occlusion_id: RefCell<u32>
Occlusion layer for this node. Used by canvas elements to decide what canvas to draw on, and by native elements to move to the correct native layer.
Implementations§
Source§impl ExpandedNode
impl ExpandedNode
pub fn root( template: Rc<ComponentInstance>, context: &mut RuntimeContext, ) -> Rc<Self>
pub fn create_children_detached( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &mut RuntimeContext, ) -> Vec<Rc<ExpandedNode>>
pub fn attach_children( self: &Rc<Self>, new_children: Vec<Rc<ExpandedNode>>, context: &mut RuntimeContext, )
pub fn set_children( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &mut RuntimeContext, )
Sourcepub fn recurse_update(self: &Rc<Self>, context: &mut RuntimeContext)
pub fn recurse_update(self: &Rc<Self>, context: &mut RuntimeContext)
This method recursively updates all node properties. When dirty-dag exists, this won’t need to be here since all property dependencies can be set up and removed during mount/unmount
pub fn recurse_render( &self, context: &mut RuntimeContext, rcs: &mut dyn RenderContext, )
Sourcepub fn with_properties_unwrapped<T: 'static, R>(
&self,
callback: impl FnOnce(&mut T) -> R,
) -> R
pub fn with_properties_unwrapped<T: 'static, R>( &self, callback: impl FnOnce(&mut T) -> R, ) -> R
Manages unpacking an Rc<RefCelltarget_type
, and executing a provided closure body
in the
context of that unwrapped variant (including support for mutable operations),
the closure is executed. Used at least by calculating properties in expand_node
and
passing &mut self
into event handlers (where the typed self
is retrieved from an instance of dyn Any
)
pub fn recurse_visit_postorder<T>( self: &Rc<Self>, func: &impl Fn(&Rc<Self>, &mut T), val: &mut T, )
pub fn get_node_context(&self, context: &RuntimeContext) -> NodeContext
pub fn get_common_properties(&self) -> Rc<RefCell<CommonProperties>>
Sourcepub fn ray_cast_test(&self, ray: &(f64, f64)) -> bool
pub fn ray_cast_test(&self, ray: &(f64, f64)) -> bool
Determines whether the provided ray, orthogonal to the view plane,
intersects this ExpandedNode
.
Sourcepub fn get_size(&self) -> (Size, Size)
pub fn get_size(&self) -> (Size, Size)
Returns the size of this node, or None
if this node
doesn’t have a size (e.g. Group
)
Sourcepub fn get_size_computed(&self, bounds: (f64, f64)) -> (f64, f64)
pub fn get_size_computed(&self, bounds: (f64, f64)) -> (f64, f64)
Returns the size of this node in pixels, requiring this node’s containing bounds
for calculation of Percent
values
Sourcepub fn get_clipping_size(&self) -> Option<(Size, Size)>
pub fn get_clipping_size(&self) -> Option<(Size, Size)>
Used at least by ray-casting; only nodes that clip content (and thus should not allow outside content to respond to ray-casting) should return a value
Sourcepub fn get_clipping_size_computed(&self, bounds: (f64, f64)) -> (f64, f64)
pub fn get_clipping_size_computed(&self, bounds: (f64, f64)) -> (f64, f64)
Returns the clipping bounds of this node in pixels, requiring
parent bounds for calculation of Percent
values
Sourcepub fn get_scroll_offset(&mut self) -> (f64, f64)
pub fn get_scroll_offset(&mut self) -> (f64, f64)
Returns the scroll offset from a Scroller component Used by the engine to transform its children