Struct ComponentInstance

Source
pub struct ComponentInstance {
    pub template: InstanceNodePtrList,
    pub timeline: Option<Rc<RefCell<Timeline>>>,
    pub compute_properties_fn: Box<dyn Fn(&ExpandedNode, &ExpressionTable, &Globals)>,
    /* private fields */
}
Expand description

A render node with its own runtime context. Will push a frame to the runtime stack including the specified slot_children and a dyn Any properties object. Component is used at the root of applications, at the root of reusable components like Stacker, and in special applications like Repeat where it houses the RepeatItem properties attached to each of Repeat’s virtual nodes.

Fields§

§template: InstanceNodePtrList§timeline: Option<Rc<RefCell<Timeline>>>§compute_properties_fn: Box<dyn Fn(&ExpandedNode, &ExpressionTable, &Globals)>

Trait Implementations§

Source§

impl InstanceNode for ComponentInstance

Source§

fn instantiate(args: InstantiationArgs) -> Rc<Self>

Source§

fn update( self: Rc<Self>, expanded_node: &Rc<ExpandedNode>, context: &mut RuntimeContext, )

Updates the expanded node, recomputing it’s properties and possibly updating it’s children
Source§

fn handle_mount( &self, expanded_node: &Rc<ExpandedNode>, context: &mut RuntimeContext, )

Fires during the tick when a node is first attached to the render tree. For example, this event fires by all nodes on the global first tick, and by all nodes in a subtree when a Conditional subsequently turns on a subtree (i.e. when the Conditionals criterion becomes true after being false through the end of at least 1 frame.) A use-case: send a message to native renderers that a Text element should be rendered and tracked
Source§

fn resolve_debug( &self, f: &mut Formatter<'_>, _expanded_node: Option<&ExpandedNode>, ) -> Result

Source§

fn base(&self) -> &BaseInstance

Retrieves the base instance, containing common functionality that all instances share
Source§

fn get_size(&self, expanded_node: &ExpandedNode) -> (Size, Size)

Returns the bounds of an InstanceNode. This computation requires a stateful ExpandedNode, yet requires customization at the trait-implementor level (dyn InstanceNode), thus this method accepts an expanded_node parameter. The default implementation retrieves the expanded_node’s pax_runtime_api::CommonProperties and pax_runtime_api::CommonProperties
Source§

fn get_clipping_size( &self, expanded_node: &ExpandedNode, ) -> Option<(Size, Size)>

Source§

fn handle_native_patches( &self, expanded_node: &ExpandedNode, context: &mut RuntimeContext, )

Used by elements that need to communicate across native rendering bridge (for example: Text, Clipping masks, scroll containers) Called by engine after [expand_node], passed calculated size and transform matrix coefficients for convenience Expected to induce side-effects (if appropriate) via enqueueing messages to the native message queue Read more
Source§

fn handle_pre_render( &self, expanded_node: &ExpandedNode, context: &mut RuntimeContext, rcs: &mut dyn RenderContext, )

Second lifecycle method during each render loop, occurs after properties have been computed, but before rendering Example use-case: perform side-effects to the drawing contexts. This is how [Frame] performs clipping, for example. Occurs in a pre-order traversal of the render tree.
Source§

fn render( &self, expanded_node: &ExpandedNode, context: &mut RuntimeContext, rcs: &mut dyn RenderContext, )

Third lifecycle method during each render loop, occurs after all descendents have been rendered. Occurs in a post-order traversal of the render tree. Most primitives are expected to draw their contents to the rendering context during this event.
Source§

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

Fourth and final lifecycle method during each render loop, occurs after all descendents have been rendered AND the current node has been rendered. Useful for clean-up, e.g. this is where Frame cleans up the drawing contexts to stop clipping. Occurs in a post-order traversal of the render tree.
Source§

fn handle_unmount( &self, expanded_node: &Rc<ExpandedNode>, context: &mut RuntimeContext, )

Fires during element unmount, when an element is about to be removed from the render tree (e.g. by a Conditional) A use-case: send a message to native renderers that a Text element should be removed
Source§

fn handle_scroll(&self, args_scroll: ArgsScroll)

Invoked by event interrupts to pass scroll information to render node

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.