use std::rc::Rc;
use_RefCell!();
use crate::RuntimeContext;
pub use pax_runtime_api::*;
#[cfg(feature = "designtime")]
use {
crate::api::math::Point2, crate::node_interface::NodeInterface,
pax_designtime::DesigntimeManager, pax_manifest::UniqueTemplateNodeIdentifier,
};
#[derive(Clone)]
pub struct NodeContext {
pub frames_elapsed: Property<u64>,
pub bounds_parent: Property<(f64, f64)>,
pub bounds_self: Property<(f64, f64)>,
pub platform: Platform,
pub os: OS,
pub slot_children_count: Property<usize>,
#[allow(unused)]
pub(crate) runtime_context: Rc<RuntimeContext>,
#[cfg(feature = "designtime")]
pub designtime: Rc<RefCell<DesigntimeManager>>,
}
#[cfg(feature = "designtime")]
impl NodeContext {
pub fn raycast(&self, point: Point2<Window>) -> Vec<NodeInterface> {
let expanded_nodes = self
.runtime_context
.get_elements_beneath_ray(point, false, vec![]);
expanded_nodes
.into_iter()
.map(Into::<NodeInterface>::into)
.collect()
}
pub fn get_nodes_by_global_id(&self, uni: UniqueTemplateNodeIdentifier) -> Vec<NodeInterface> {
let expanded_nodes = self.runtime_context.get_expanded_nodes_by_global_ids(&uni);
expanded_nodes
.into_iter()
.map(Into::<NodeInterface>::into)
.collect()
}
pub fn get_nodes_by_id(&self, id: &str) -> Vec<NodeInterface> {
let expanded_nodes = self.runtime_context.get_expanded_nodes_by_id(id);
expanded_nodes
.into_iter()
.map(Into::<NodeInterface>::into)
.collect()
}
}