Skip to content

Commit 6f85ad6

Browse files
committed
wires and clip paths
1 parent 4c4a440 commit 6f85ad6

File tree

10 files changed

+232
-141
lines changed

10 files changed

+232
-141
lines changed

editor/src/messages/frontend/frontend_message.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,7 @@ pub enum FrontendMessage {
267267
UpdateMouseCursor {
268268
cursor: MouseCursorIcon,
269269
},
270-
UpdateNodeGraphSvelteRender {
271-
#[serde(rename = "nodesToRender")]
272-
nodes_to_render: Vec<FrontendNodeToRender>,
273-
open: bool,
274-
opacity: f64,
275-
#[serde(rename = "inSelectedNetwork")]
276-
in_selected_network: bool,
277-
// Displays a dashed border around the node
278-
#[serde(rename = "previewedNode")]
279-
previewed_node: Option<NodeId>,
280-
},
270+
RequestNativeNodeGraphRender,
281271
UpdateShouldRenderSvelteNodes {
282272
#[serde(rename = "shouldRenderSvelteNodes")]
283273
should_render_svelte_nodes: bool,

editor/src/messages/portfolio/document/node_graph/generate_node_graph_overlay.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ pub fn generate_node_graph_overlay(node_graph_overlay_data: NodeGraphOverlayData
2020
let merge_nodes_and_bg_id = NodeId::new();
2121
let render_overlay_id = NodeId::new();
2222
let send_overlay_id = NodeId::new();
23-
let _cache_output_id = NodeId::new();
23+
let cache_output_id = NodeId::new();
2424
// TODO: Replace with new cache node
25-
let memo_implementation = DocumentNodeImplementation::ProtoNode(graphene_std::ops::identity::IDENTIFIER);
25+
let identity_implementation = DocumentNodeImplementation::ProtoNode(graphene_std::ops::identity::IDENTIFIER);
26+
let memo_implementation = DocumentNodeImplementation::ProtoNode(graphene_std::memo::memo::IDENTIFIER);
2627

2728
DocumentNode {
2829
inputs: vec![
@@ -32,7 +33,7 @@ pub fn generate_node_graph_overlay(node_graph_overlay_data: NodeGraphOverlayData
3233
],
3334

3435
implementation: DocumentNodeImplementation::Network(NodeNetwork {
35-
exports: vec![NodeInput::node(send_overlay_id, 0)],
36+
exports: vec![NodeInput::node(cache_output_id, 0)],
3637
nodes: vec![
3738
// Create the nodes
3839
(
@@ -50,7 +51,7 @@ pub fn generate_node_graph_overlay(node_graph_overlay_data: NodeGraphOverlayData
5051
DocumentNode {
5152
call_argument: concrete!(UIContext),
5253
inputs: vec![NodeInput::node(generate_nodes_id, 0)],
53-
implementation: memo_implementation.clone(),
54+
implementation: identity_implementation.clone(),
5455
..Default::default()
5556
},
5657
),
@@ -80,7 +81,7 @@ pub fn generate_node_graph_overlay(node_graph_overlay_data: NodeGraphOverlayData
8081
DocumentNode {
8182
call_argument: concrete!(UIContext),
8283
inputs: vec![NodeInput::node(generate_node_graph_bg, 0)],
83-
implementation: memo_implementation.clone(),
84+
implementation: identity_implementation.clone(),
8485
..Default::default()
8586
},
8687
),
@@ -114,16 +115,16 @@ pub fn generate_node_graph_overlay(node_graph_overlay_data: NodeGraphOverlayData
114115
..Default::default()
115116
},
116117
),
117-
// Cache the full node graph so its not rerendered when the artwork changes
118-
// (
119-
// cache_nodes_id,
120-
// DocumentNode {
121-
// call_argument: concrete!(UIContext),
122-
// inputs: vec![NodeInput::node(send_overlay_id, 0)],
123-
// implementation: memo_implementation.clone(),
124-
// ..Default::default()
125-
// },
126-
// ),
118+
// Cache the full node graph so its not rerendered when nothing changes
119+
(
120+
cache_output_id,
121+
DocumentNode {
122+
call_argument: concrete!(UIContext),
123+
inputs: vec![NodeInput::node(send_overlay_id, 0)],
124+
implementation: memo_implementation.clone(),
125+
..Default::default()
126+
},
127+
),
127128
]
128129
.into_iter()
129130
.collect(),

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,13 +1631,6 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
16311631
let nodes_to_render = network_interface.collect_nodes(&self.node_graph_errors, preferences.graph_wire_style, breadcrumb_network_path);
16321632
self.frontend_nodes = nodes_to_render.iter().map(|node| node.metadata.node_id).collect();
16331633
let previewed_node = network_interface.previewed_node(breadcrumb_network_path);
1634-
responses.add(FrontendMessage::UpdateNodeGraphSvelteRender {
1635-
nodes_to_render,
1636-
open: graph_view_overlay_open,
1637-
opacity: graph_fade_artwork_percentage,
1638-
in_selected_network: selection_network_path == breadcrumb_network_path,
1639-
previewed_node,
1640-
});
16411634
}
16421635
responses.add(NodeGraphMessage::UpdateVisibleNodes);
16431636

editor/src/messages/portfolio/document/utility_types/network_interface/node_graph.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ impl NodeNetworkInterface {
111111
self.upstream_output_connector(&InputConnector::node(node_id, input_index), network_path)
112112
.is_some_and(|output| !matches!(output, OutputConnector::Import(_)))
113113
})
114-
.map(|path| path.to_svg())
115114
.map(|wire| {
116115
(
117116
wire,
@@ -401,7 +400,7 @@ impl NodeNetworkInterface {
401400
if exports.is_empty() {
402401
exports.push(None);
403402
}
404-
let preview_wire = self.wire_to_root(graph_wire_style, network_path);
403+
let preview_wire = self.wire_to_root(graph_wire_style, network_path).map(|wire| wire.to_svg());
405404
FrontendExports { exports, preview_wire }
406405
}
407406

@@ -512,7 +511,7 @@ impl NodeNetworkInterface {
512511
}
513512

514513
/// When previewing, there may be a second path to the root node.
515-
pub fn wire_to_root(&mut self, graph_wire_style: GraphWireStyle, network_path: &[NodeId]) -> Option<String> {
514+
pub fn wire_to_root(&mut self, graph_wire_style: GraphWireStyle, network_path: &[NodeId]) -> Option<BezPath> {
516515
let input = InputConnector::Export(0);
517516
let current_export = self.upstream_output_connector(&input, network_path)?;
518517

@@ -536,6 +535,6 @@ impl NodeNetworkInterface {
536535
let vertical_start = upstream_output.node_id().is_some_and(|node_id| self.is_layer(&node_id, network_path));
537536
let vector_wire = build_vector_wire(output_position, input_position, vertical_start, false, graph_wire_style);
538537

539-
Some(vector_wire.to_svg())
538+
Some(vector_wire)
540539
}
541540
}

editor/src/test_utils.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,7 @@ pub trait FrontendMessageTestUtils {
301301

302302
impl FrontendMessageTestUtils for FrontendMessage {
303303
fn check_node_graph_error(&self) {
304-
let FrontendMessage::UpdateNodeGraphSvelteRender { nodes_to_render, .. } = self else { return };
305-
306-
for node in nodes_to_render {
307-
if let Some(error) = &node.metadata.errors {
308-
panic!("error on {}: {}", node.metadata.display_name, error);
309-
}
310-
}
304+
// TODO: Implement
311305
}
312306
}
313307

node-graph/gcore/src/node_graph_overlay.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
Graphic,
55
node_graph_overlay::{
66
background::generate_background,
7-
nodes_and_wires::{draw_layers, draw_nodes},
7+
nodes_and_wires::{draw_layers, draw_nodes, draw_wires},
88
types::NodeGraphOverlayData,
99
ui_context::{UIContext, UIRuntimeResponse},
1010
},
@@ -19,11 +19,14 @@ pub mod types;
1919
pub mod ui_context;
2020

2121
#[node_macro::node(skip_impl)]
22-
pub fn generate_nodes(_: impl Ctx, node_graph_overlay_data: NodeGraphOverlayData) -> Table<Graphic> {
22+
pub fn generate_nodes(_: impl Ctx, mut node_graph_overlay_data: NodeGraphOverlayData) -> Table<Graphic> {
2323
let mut nodes_and_wires = Table::new();
2424
let layers = draw_layers(&node_graph_overlay_data.nodes_to_render);
2525
nodes_and_wires.extend(layers);
2626

27+
let wires = draw_wires(&mut node_graph_overlay_data.nodes_to_render);
28+
nodes_and_wires.extend(wires);
29+
2730
let nodes = draw_nodes(&node_graph_overlay_data.nodes_to_render);
2831
nodes_and_wires.extend(nodes);
2932

0 commit comments

Comments
 (0)