Struct ExpandedNode

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

§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

Source

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

Source

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

Source

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

Source

pub fn set_children( self: &Rc<Self>, templates: impl IntoIterator<Item = (Rc<dyn InstanceNode>, Rc<RuntimePropertiesStackFrame>)>, context: &mut RuntimeContext, )

Source

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

Source

pub fn recurse_render( &self, context: &mut RuntimeContext, rcs: &mut dyn RenderContext, )

Source

pub fn with_properties_unwrapped<T: 'static, 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 dyn Any)

Source

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

Source

pub fn get_node_context(&self, context: &RuntimeContext) -> NodeContext

Source

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

Source

pub fn ray_cast_test(&self, ray: &(f64, f64)) -> bool

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

Source

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)

Source

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

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: ArgsScroll, globals: &Globals)

Source

pub fn dispatch_clap(&self, args: ArgsClap, globals: &Globals)

Source

pub fn dispatch_touch_start(&self, args: ArgsTouchStart, globals: &Globals)

Source

pub fn dispatch_touch_move(&self, args: ArgsTouchMove, globals: &Globals)

Source

pub fn dispatch_touch_end(&self, args: ArgsTouchEnd, globals: &Globals)

Source

pub fn dispatch_key_down(&self, args: ArgsKeyDown, globals: &Globals)

Source

pub fn dispatch_key_up(&self, args: ArgsKeyUp, globals: &Globals)

Source

pub fn dispatch_key_press(&self, args: ArgsKeyPress, globals: &Globals)

Source

pub fn dispatch_checkbox_change( &self, args: ArgsCheckboxChange, globals: &Globals, )

Source

pub fn dispatch_textbox_change( &self, args: ArgsTextboxChange, globals: &Globals, )

Source

pub fn dispatch_button_click(&self, args: ArgsButtonClick, globals: &Globals)

Source

pub fn dispatch_mouse_down(&self, args: ArgsMouseDown, globals: &Globals)

Source

pub fn dispatch_mouse_up(&self, args: ArgsMouseUp, globals: &Globals)

Source

pub fn dispatch_mouse_move(&self, args: ArgsMouseMove, globals: &Globals)

Source

pub fn dispatch_mouse_over(&self, args: ArgsMouseOver, globals: &Globals)

Source

pub fn dispatch_mouse_out(&self, args: ArgsMouseOut, globals: &Globals)

Source

pub fn dispatch_double_click(&self, args: ArgsDoubleClick, globals: &Globals)

Source

pub fn dispatch_context_menu(&self, args: ArgsContextMenu, globals: &Globals)

Source

pub fn dispatch_click(&self, args: ArgsClick, globals: &Globals)

Source

pub fn dispatch_wheel(&self, args: ArgsWheel, globals: &Globals)

Trait Implementations§

Source§

impl Debug for ExpandedNode

Source§

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

Formats the value using the given formatter. 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.