pub struct ComponentInstance<R: 'static + RenderContext> {
    pub template: RenderNodePtrList<R>,
    pub children: RenderNodePtrList<R>,
    pub handler_registry: Option<Rc<RefCell<HandlerRegistry<R>>>>,
    pub properties: Rc<RefCell<PropertiesCoproduct>>,
    pub timeline: Option<Rc<RefCell<Timeline>>>,
    pub compute_properties_fn: Box<dyn FnMut(Rc<RefCell<PropertiesCoproduct>>, &mut RenderTreeContext<'_, R>)>,
    pub common_properties: CommonProperties,
    /* private fields */
}
Expand description

A render node with its own runtime context. Will push a frame to the runtime stack including the specified adoptees and PropertiesCoproduct 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: RenderNodePtrList<R>§children: RenderNodePtrList<R>§handler_registry: Option<Rc<RefCell<HandlerRegistry<R>>>>§properties: Rc<RefCell<PropertiesCoproduct>>§timeline: Option<Rc<RefCell<Timeline>>>§compute_properties_fn: Box<dyn FnMut(Rc<RefCell<PropertiesCoproduct>>, &mut RenderTreeContext<'_, R>)>§common_properties: CommonProperties

Trait Implementations§

source§

impl<R: 'static + RenderContext> RenderNode<R> for ComponentInstance<R>

source§

fn get_common_properties(&self) -> &CommonProperties

source§

fn get_instance_id(&self) -> u32

Returns unique integer ID of this RenderNode instance. Note that individual rendered elements may share an instance_id, for example inside of Repeat. See also RenderTreeContext::get_id_chain, which enables globally unique node addressing in the context of an in-progress render tree traversal.
source§

fn get_rendering_children(&self) -> RenderNodePtrList<R>

Return the list of nodes that are children of this node at render-time. Note that “children” is somewhat overloaded, hence “rendering_children” here. “Children” may indicate a.) a template root, b.) adoptees, c.) primitive children Each RenderNode is responsible for determining at render-time which of these concepts to pass to the engine for rendering, and that distinction occurs inside get_rendering_children
source§

fn get_handler_registry(&self) -> Option<Rc<RefCell<HandlerRegistry<R>>>>

source§

fn handle_did_render( &mut self, rtc: &mut RenderTreeContext<'_, R>, _rcs: &mut HashMap<String, R> )

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 instantiate(args: InstantiationArgs<R>) -> Rc<RefCell<Self>>

source§

fn get_size(&self) -> Option<(Size, Size)>

Returns the size of this node, or None if this node doesn’t have a size (e.g. Group)
source§

fn compute_size_within_bounds(&self, bounds: (f64, f64)) -> (f64, f64)

Returns the size of this node in pixels, requiring parent bounds for calculation of Percent values
source§

fn compute_properties(&mut self, rtc: &mut RenderTreeContext<'_, R>)

First lifecycle method during each render loop, used to compute properties in advance of rendering. Occurs in a pre-order traversal of the render tree.
source§

fn get_layer_type(&mut self) -> Layer

Returns the layer type (Layer::Native or Layer::Canvas) for this RenderNode. Default is Layer::Canvas, and must be overwritten for native rendering
source§

fn pop_cleanup_children(&mut self) -> RenderNodePtrList<R>

Consumes the children of this node at render-time that should be removed. This occurs when they were mounted in some previous frame but now need to be removed after a property change This function resets this list once returned
source§

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

Determines whether the provided ray, orthogonal to the view plane, intersects this rendernode. tab must also be passed because these are specific to a RepeatExpandedNode
source§

fn get_clipping_bounds(&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 true
source§

fn should_flatten(&self) -> bool

Used for exotic tree traversals, e.g. for Stacker > Repeat > Rectangle where the repeated Rectangles need to be be considered direct children of Stacker. Repeat overrides should_flatten to return true, which Engine interprets to mean “ignore this node and consume its children” during traversal. Read more
source§

fn compute_clipping_within_bounds(&self, bounds: (f64, f64)) -> (f64, f64)

Returns the clipping bounds of this node in pixels, requiring parent bounds for calculation of Percent values
source§

fn compute_native_patches( &mut self, _rtc: &mut RenderTreeContext<'_, R>, _computed_size: (f64, f64), _transform_coeffs: Vec<f64>, _z_index: u32, _subtree_depth: u32 )

Used by elements that need to communicate across native rendering bridge (for example: Text, Clipping masks, scroll containers) Called by engine after compute_properties, 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_will_render( &mut self, _rtc: &mut RenderTreeContext<'_, R>, _rcs: &mut HashMap<String, R> )

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 handle_render(&mut self, _rtc: &mut RenderTreeContext<'_, R>, _rc: &mut R)

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_did_mount( &mut self, _rtc: &mut RenderTreeContext<'_, R>, _z_index: u32 )

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 handle_will_unmount(&mut self, _rtc: &mut RenderTreeContext<'_, R>)

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(&mut self, _args_scroll: ArgsScroll)

Invoked by event interrupts to pass scroll information to render node
source§

fn get_scroll_offset(&mut self) -> (f64, f64)

Returns the scroll offset from a Scroller component Used by the engine to transform its children

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: RoundFrom<T>,

source§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.