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. Optional 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 Optional.

§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

source

pub fn root( template: Rc<ComponentInstance>, ctx: &Rc<RuntimeContext>, ) -> Rc<Self>

source

pub fn recreate_with_new_data( self: &Rc<Self>, template: Rc<dyn InstanceNode>, context: &Rc<RuntimeContext>, )

source

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.

source

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

source

pub fn attach_children( self: &Rc<Self>, new_children: Vec<Rc<ExpandedNode>>, context: &Rc<RuntimeContext>, ) -> Vec<Rc<ExpandedNode>>

source

pub fn generate_children( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &Rc<RuntimeContext>, ) -> Vec<Rc<ExpandedNode>>

source

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

source

pub fn recurse_mount(self: &Rc<Self>, context: &Rc<RuntimeContext>)

source

pub fn recurse_unmount(self: Rc<Self>, context: &Rc<RuntimeContext>)

source

pub fn recurse_render( &self, ctx: &Rc<RuntimeContext>, rcs: &mut dyn RenderContext, )

source

pub fn with_properties_unwrapped<T: ToFromPaxAny, R>( &self, callback: impl FnOnce(&mut T) -> R, ) -> R

Manages unpacking an Rc<RefCell>, downcasting into the parameterized target_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)

source

pub fn try_with_properties_unwrapped<T: ToFromPaxAny, R>( &self, callback: impl FnOnce(&mut T) -> R, ) -> Option<R>

source

pub fn recurse_visit_postorder( self: &Rc<Self>, func: &mut impl FnMut(&Rc<Self>), )

source

pub fn get_node_context<'a>(&'a self, ctx: &Rc<RuntimeContext>) -> NodeContext

source

pub fn get_common_properties(&self) -> Rc<RefCell<CommonProperties>>

source

pub fn ray_cast_test(&self, ray: Point2<Window>) -> bool

Determines whether the provided ray, orthogonal to the view plane, intersects this ExpandedNode.

source

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

source

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

source

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

source

pub fn compute_flattened_slot_children(&self)

source

pub fn dispatch_scroll( &self, args: Scroll, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_clap( &self, args: Clap, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_touch_start( &self, args: TouchStart, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_touch_move( &self, args: TouchMove, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_touch_end( &self, args: TouchEnd, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_key_down( &self, args: KeyDown, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_key_up( &self, args: KeyUp, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_key_press( &self, args: KeyPress, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_checkbox_change( &self, args: CheckboxChange, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_textbox_change( &self, args: TextboxChange, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_text_input( &self, args: TextInput, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_textbox_input( &self, args: TextboxInput, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_button_click( &self, args: ButtonClick, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_mouse_down( &self, args: MouseDown, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_mouse_up( &self, args: MouseUp, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_mouse_move( &self, args: MouseMove, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_mouse_over( &self, args: MouseOver, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_mouse_out( &self, args: MouseOut, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_double_click( &self, args: DoubleClick, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_context_menu( &self, args: ContextMenu, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_click( &self, args: Click, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_wheel( &self, args: Wheel, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_drop( &self, args: Drop, globals: &Globals, ctx: &Rc<RuntimeContext>, ) -> bool

source

pub fn dispatch_custom_event( &self, identifier: &str, ctx: &Rc<RuntimeContext>, ) -> Result<(), String>

source

pub fn chassis_resize_request(self: &Rc<ExpandedNode>, width: f64, height: f64)

source

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

source§

fn clone(&self) -> ExpandedNode

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ExpandedNode

source§

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

Formats the value using the given formatter. Read more
source§

impl Interpolatable for ExpandedNode

source§

fn interpolate(&self, _other: &Self, _t: f64) -> Self

source§

impl ImplToFromPaxAny for ExpandedNode

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CoercionRules for T

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

source§

fn round_from(x: T) -> T

Performs the conversion.
source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

source§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T> ToFromPaxAny for T

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.