Skip to content
Open
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
4 changes: 4 additions & 0 deletions editor/src/messages/portfolio/document/document_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use graphene_std::Color;
use graphene_std::raster::BlendMode;
use graphene_std::raster::Image;
use graphene_std::transform::Footprint;
use graphene_std::vector::Vector;
use graphene_std::vector::click_target::ClickTarget;
use graphene_std::vector::style::RenderMode;

Expand Down Expand Up @@ -209,6 +210,9 @@ pub enum DocumentMessage {
UpdateClipTargets {
clip_targets: HashSet<NodeId>,
},
UpdateVectorData {
vector_data: HashMap<NodeId, Arc<Vector>>,
},
Undo,
UngroupSelectedLayers,
UngroupLayer {
Expand Down
14 changes: 14 additions & 0 deletions editor/src/messages/portfolio/document/document_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,20 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
DocumentMessage::UpdateClipTargets { clip_targets } => {
self.network_interface.update_clip_targets(clip_targets);
}
DocumentMessage::UpdateVectorData { vector_data } => {
// Convert NodeId keys to LayerNodeIdentifier keys, filtering to only layers
let layer_vector_data = vector_data
.into_iter()
.filter(|(node_id, _)| self.network_interface.document_network().nodes.contains_key(node_id))
.filter_map(|(node_id, vector)| {
self.network_interface.is_layer(&node_id, &[]).then(|| {
let layer = LayerNodeIdentifier::new(node_id, &self.network_interface);
(layer, vector)
})
})
.collect();
self.network_interface.update_vector_data(layer_vector_data);
}
DocumentMessage::Undo => {
if self.network_interface.transaction_status() != TransactionStatus::Finished {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct DocumentMetadata {
pub click_targets: HashMap<LayerNodeIdentifier, Vec<Arc<ClickTarget>>>,
pub clip_targets: HashSet<NodeId>,
pub vector_modify: HashMap<NodeId, Vector>,
/// Vector data keyed by layer ID, used as fallback when no Path node exists.
/// This provides accurate SegmentIds for layers without explicit Path nodes.
pub layer_vector_data: HashMap<LayerNodeIdentifier, Arc<Vector>>,
/// Transform from document space to viewport space.
pub document_to_viewport: DAffine2,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3076,11 +3076,7 @@ impl NodeNetworkInterface {
return Some(modified);
}

self.document_metadata
.click_targets
.get(&layer)
.map(|click| click.iter().map(|x| x.target_type()))
.map(|target_types| Vector::from_target_types(target_types, true))
self.document_metadata.layer_vector_data.get(&layer).map(|arc| arc.as_ref().clone())
}

/// Loads the structure of layer nodes from a node graph.
Expand Down Expand Up @@ -3194,6 +3190,11 @@ impl NodeNetworkInterface {
pub fn update_vector_modify(&mut self, new_vector_modify: HashMap<NodeId, Vector>) {
self.document_metadata.vector_modify = new_vector_modify;
}

/// Update the layer vector data (for layers without Path nodes)
pub fn update_vector_data(&mut self, new_layer_vector_data: HashMap<LayerNodeIdentifier, Arc<Vector>>) {
self.document_metadata.layer_vector_data = new_layer_vector_data;
}
}

// Public mutable methods
Expand Down
2 changes: 2 additions & 0 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ impl NodeGraphExecutor {
first_element_source_id,
click_targets,
clip_targets,
vector_data,
} = render_output.metadata;

// Run these update state messages immediately
Expand All @@ -422,6 +423,7 @@ impl NodeGraphExecutor {
});
responses.add(DocumentMessage::UpdateClickTargets { click_targets });
responses.add(DocumentMessage::UpdateClipTargets { clip_targets });
responses.add(DocumentMessage::UpdateVectorData { vector_data });
responses.add(DocumentMessage::RenderScrollbars);
responses.add(DocumentMessage::RenderRulers);
responses.add(OverlaysMessage::Draw);
Expand Down
3 changes: 3 additions & 0 deletions node-graph/libraries/rendering/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub struct RenderMetadata {
pub first_element_source_id: HashMap<NodeId, Option<NodeId>>,
pub click_targets: HashMap<NodeId, Vec<Arc<ClickTarget>>>,
pub clip_targets: HashSet<NodeId>,
pub vector_data: HashMap<NodeId, Arc<Vector>>,
}

impl RenderMetadata {
Expand Down Expand Up @@ -1187,6 +1188,8 @@ impl Render for Table<Vector> {
.collect::<Vec<_>>();

metadata.click_targets.entry(element_id).or_insert(click_targets);
// Store the full vector data including segment IDs for accurate segment modification
metadata.vector_data.entry(element_id).or_insert_with(|| Arc::new(vector.clone()));
}

if let Some(upstream_nested_layers) = &vector.upstream_data {
Expand Down
Loading