Struct pax_runtime::engine::ExpandedNode
source · pub struct ExpandedNode {Show 19 fields
pub id: ExpandedNodeIdentifier,
pub instance_node: RefCell<InstanceNodePtr>,
pub render_parent: RefCell<Weak<ExpandedNode>>,
pub template_parent: Weak<ExpandedNode>,
pub parent_frame: Cell<Option<ExpandedNodeIdentifier>>,
pub containing_component: Weak<ExpandedNode>,
pub stack: Rc<RuntimePropertiesStackFrame>,
pub children: Property<Vec<Rc<ExpandedNode>>>,
pub mounted_children: RefCell<Vec<Rc<ExpandedNode>>>,
pub properties: RefCell<Rc<RefCell<PaxAny>>>,
pub rendered_size: Property<Option<(f64, f64)>>,
pub transform_and_bounds: Property<TransformAndBounds<NodeLocal, Window>>,
pub expanded_slot_children: RefCell<Option<Vec<Rc<ExpandedNode>>>>,
pub expanded_and_flattened_slot_children: Property<Vec<Rc<ExpandedNode>>>,
pub flattened_slot_children_count: Property<usize>,
pub attached: RefCell<u32>,
pub occlusion_id: RefCell<u32>,
pub properties_scope: RefCell<HashMap<String, UntypedProperty>>,
pub slot_index: Property<Option<usize>>,
/* private fields */
}
Fields§
§id: ExpandedNodeIdentifier
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: RefCell<InstanceNodePtr>
Pointer to the unexpanded instance_node
underlying this ExpandedNode
render_parent: RefCell<Weak<ExpandedNode>>
Pointer (Weak
to avoid Rc cycle memory leaks) to the ExpandedNode
redered directly above this one.
template_parent: Weak<ExpandedNode>
Pointer (Weak
to avoid Rc cycle memory leaks) to the ExpandedNode
in the template directy aboe this one.
parent_frame: Cell<Option<ExpandedNodeIdentifier>>
Id of closest frame present in the node tree. included as a parameter on AnyCreatePatch when creating a native element to know what clipping context to attach to
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.)
children: Property<Vec<Rc<ExpandedNode>>>
Pointers to the ExpandedNode beneath this one. Used for e.g. rendering recursion.
mounted_children: RefCell<Vec<Rc<ExpandedNode>>>
A list of mounted children that need to be dismounted when children is recalculated
properties: RefCell<Rc<RefCell<PaxAny>>>
Each ExpandedNode has a unique “stamp” of computed properties
rendered_size: Property<Option<(f64, f64)>>
Set by chassis, for for example text nodes that get resize info from an interrupt if a node doesn’t have fixed bounds(width/height specified), this value is used instead.
transform_and_bounds: Property<TransformAndBounds<NodeLocal, Window>>
The layout information (width, height, transform) used to render this node. computed property based on parent bounds + common properties
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: Property<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.
flattened_slot_children_count: Property<usize>
§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.
properties_scope: RefCell<HashMap<String, UntypedProperty>>
A map of all properties available on this expanded node. Used by the RuntimePropertiesStackFrame to resolve symbols.
slot_index: Property<Option<usize>>
The flattened index of this node in it’s container (if this container cares about slot children, ex: component, path).
Implementations§
source§impl ExpandedNode
impl ExpandedNode
pub fn root( template: Rc<ComponentInstance>, ctx: &Rc<RuntimeContext>, ) -> Rc<Self>
pub fn recreate_with_new_data( self: &Rc<Self>, template: Rc<dyn InstanceNode>, context: &Rc<RuntimeContext>, )
sourcepub fn is_descendant_of(
&self,
other_expanded_node_id: &ExpandedNodeIdentifier,
) -> bool
pub fn is_descendant_of( &self, other_expanded_node_id: &ExpandedNodeIdentifier, ) -> bool
Returns whether this node is a descendant of the ExpandedNode described by other_expanded_node_id
(id)
Currently requires traversing linked list of ancestory, incurring a O(log(n)) cost for a tree of n
elements.
This could be mitigated with caching/memoization, perhaps by storing a HashSet on each ExpandedNode describing its ancestory chain.
pub fn create_children_detached( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &Rc<RuntimeContext>, template_parent: &Weak<ExpandedNode>, ) -> Vec<Rc<ExpandedNode>>
pub fn attach_children( self: &Rc<Self>, new_children: Vec<Rc<ExpandedNode>>, context: &Rc<RuntimeContext>, ) -> Vec<Rc<ExpandedNode>>
pub fn generate_children( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &Rc<RuntimeContext>, ) -> Vec<Rc<ExpandedNode>>
sourcepub fn recurse_update(self: &Rc<Self>, context: &Rc<RuntimeContext>)
pub fn recurse_update(self: &Rc<Self>, context: &Rc<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_mount(self: &Rc<Self>, context: &Rc<RuntimeContext>)
pub fn recurse_unmount(self: Rc<Self>, context: &Rc<RuntimeContext>)
pub fn recurse_render( &self, ctx: &Rc<RuntimeContext>, rcs: &mut dyn RenderContext, )
sourcepub fn with_properties_unwrapped<T: ToFromPaxAny, R>(
&self,
callback: impl FnOnce(&mut T) -> R,
) -> R
pub fn with_properties_unwrapped<T: ToFromPaxAny, 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 PaxValue
)
pub fn try_with_properties_unwrapped<T: ToFromPaxAny, R>( &self, callback: impl FnOnce(&mut T) -> R, ) -> Option<R>
pub fn recurse_visit_postorder( self: &Rc<Self>, func: &mut impl FnMut(&Rc<Self>), )
pub fn get_node_context<'a>(&'a self, ctx: &Rc<RuntimeContext>) -> NodeContext
pub fn get_common_properties(&self) -> Rc<RefCell<CommonProperties>>
sourcepub fn ray_cast_test(&self, ray: Point2<Window>) -> bool
pub fn ray_cast_test(&self, ray: Point2<Window>) -> bool
Determines whether the provided ray, orthogonal to the view plane,
intersects this ExpandedNode
.
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
pub fn compute_flattened_slot_children(&self)
pub fn dispatch_scroll( &self, args: Scroll, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_clap( &self, args: Clap, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_touch_start( &self, args: TouchStart, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_touch_move( &self, args: TouchMove, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_touch_end( &self, args: TouchEnd, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_key_down( &self, args: KeyDown, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_key_up( &self, args: KeyUp, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_key_press( &self, args: KeyPress, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_checkbox_change( &self, args: CheckboxChange, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_textbox_change( &self, args: TextboxChange, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_text_input( &self, args: TextInput, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_textbox_input( &self, args: TextboxInput, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_mouse_down( &self, args: MouseDown, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_mouse_up( &self, args: MouseUp, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_mouse_move( &self, args: MouseMove, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_mouse_over( &self, args: MouseOver, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_mouse_out( &self, args: MouseOut, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_double_click( &self, args: DoubleClick, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_click( &self, args: Click, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_wheel( &self, args: Wheel, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_drop( &self, args: Drop, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool
pub fn dispatch_custom_event( &self, identifier: &str, ctx: &Rc<RuntimeContext>, ) -> Result<(), String>
pub fn chassis_resize_request(self: &Rc<ExpandedNode>, width: f64, height: f64)
sourcepub fn layout_properties(self: &Rc<ExpandedNode>) -> Property<LayoutProperties>
pub fn layout_properties(self: &Rc<ExpandedNode>) -> Property<LayoutProperties>
Helper method that returns a collection of common properties related to layout (position, size, scale, anchor, etc),
Trait Implementations§
source§impl Clone for ExpandedNode
impl Clone for ExpandedNode
source§fn clone(&self) -> ExpandedNode
fn clone(&self) -> ExpandedNode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExpandedNode
impl Debug for ExpandedNode
source§impl Interpolatable for ExpandedNode
impl Interpolatable for ExpandedNode
fn interpolate(&self, _other: &Self, _t: f64) -> Self
impl ImplToFromPaxAny for ExpandedNode
Auto Trait Implementations§
impl !Freeze for ExpandedNode
impl !RefUnwindSafe for ExpandedNode
impl !Send for ExpandedNode
impl !Sync for ExpandedNode
impl Unpin for ExpandedNode
impl !UnwindSafe for ExpandedNode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)