Struct pax_runtime::engine::PaxEngine
source · pub struct PaxEngine {
pub runtime_context: RuntimeContext,
pub root_node: Rc<ExpandedNode>,
pub z_index_node_cache: Vec<Rc<ExpandedNode>>,
}Expand description
Singleton struct storing everything related to properties computation & rendering
Fields§
§runtime_context: RuntimeContext§root_node: Rc<ExpandedNode>§z_index_node_cache: Vec<Rc<ExpandedNode>>Implementations§
source§impl PaxEngine
impl PaxEngine
Central instance of the PaxEngine and runtime, intended to be created by a particular chassis. Contains all rendering and runtime logic.
pub fn new( main_component_instance: Rc<ComponentInstance>, expression_table: ExpressionTable, logger: PlatformSpecificLogger, viewport_size: (f64, f64) ) -> Self
sourcepub fn tick(&mut self) -> Vec<NativeMessage>
pub fn tick(&mut self) -> Vec<NativeMessage>
Workhorse methods of every tick. Will be executed up to 240 Hz. Three phases:
- Expand nodes & compute properties; recurse entire instance tree and evaluate ExpandedNodes, stitching together parent/child relationships between ExpandedNodes along the way.
- Compute layout (z-index & TransformAndBounds) by visiting ExpandedNode tree in rendering order, writing computed rendering-specific values to ExpandedNodes
- Render: a. find lowest node (last child of last node) b. start rendering, from lowest node on-up, throughout tree
pub fn render(&mut self, rcs: &mut dyn RenderContext)
sourcepub fn get_topmost_element_beneath_ray(
&self,
ray: (f64, f64)
) -> Option<Rc<ExpandedNode>>
pub fn get_topmost_element_beneath_ray( &self, ray: (f64, f64) ) -> Option<Rc<ExpandedNode>>
Simple 2D raycasting: the coordinates of the ray represent a
ray running orthogonally to the view plane, intersecting at
the specified point ray. Areas outside of clipping bounds will
not register a hit, nor will elements that suppress input events.
pub fn get_expanded_node(&self, id: u32) -> Option<&Rc<ExpandedNode>>
pub fn get_focused_element(&self) -> Option<Rc<ExpandedNode>>
sourcepub fn set_viewport_size(&mut self, new_viewport_size: (f64, f64))
pub fn set_viewport_size(&mut self, new_viewport_size: (f64, f64))
Called by chassis when viewport size changes, e.g. with native window resizes
Auto Trait Implementations§
impl !RefUnwindSafe for PaxEngine
impl !Send for PaxEngine
impl !Sync for PaxEngine
impl Unpin for PaxEngine
impl !UnwindSafe for PaxEngine
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
Mutably borrows from an owned value. Read more
source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.