Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ComponentId + TemplateNodeId -> ExpandedNodes lookup #111

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs
Submodule docs updated from cd88f2 to 8569b2
3 changes: 2 additions & 1 deletion pax-runtime/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::rc::Rc;
use pax_message::{NativeMessage, OcclusionPatch};

use crate::api::{
CommonProperties, Interpolatable, Layer, NodeContext, OcclusionLayerGen, RenderContext,
log, CommonProperties, Interpolatable, Layer, NodeContext, OcclusionLayerGen, RenderContext,
TransitionManager,
};
use piet::InterpolationMode;
Expand Down Expand Up @@ -313,6 +313,7 @@ impl PaxEngine {
.into_iter()
.zip(iter::repeat(env));
p.set_children(new_templates, &mut self.runtime_context);
self.root_node.recurse_update(&mut self.runtime_context);
return;
}
}
Expand Down
21 changes: 21 additions & 0 deletions pax-runtime/src/properties.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::api::log;
use crate::numeric::Numeric;
use pax_message::NativeMessage;
use std::cell::RefCell;
Expand Down Expand Up @@ -54,6 +55,26 @@ impl RuntimeContext {
.collect()
}

pub fn get_expanded_nodes_by_global_ids(
&self,
component_id: &str,
template_id: usize,
) -> Vec<Rc<ExpandedNode>> {
self.node_cache
.values()
.filter(|val| {
let node_template_id = val.instance_node.base().template_node_id;
let containing_component_id = val
.containing_component
.upgrade()
.map(|n| n.instance_node.base().component_type_id.clone())
.unwrap_or_default();
component_id == containing_component_id && template_id == node_template_id
})
.cloned()
.collect()
}

/// 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
Expand Down
4 changes: 2 additions & 2 deletions pax-runtime/src/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::{Add, Div, Mul, Sub};
use std::rc::Rc;

use crate::api::{CommonProperties, RenderContext};
use kurbo::Affine;
pub use kurbo::Affine;
use piet::{Color, StrokeStyle};

use crate::api::{ArgsScroll, Layer, Size};
Expand All @@ -33,7 +33,7 @@ pub struct InstantiationArgs {
pub component_type_id: String,
}

#[derive(Copy, Clone, Default)]
#[derive(Copy, Clone, Default, Debug)]
pub struct Point2D {
pub x: f64,
pub y: f64,
Expand Down
Loading