Skip to content

Commit a0551c3

Browse files
committed
Native node graph render toggle
1 parent 7c0f8e5 commit a0551c3

File tree

27 files changed

+2292
-1439
lines changed

27 files changed

+2292
-1439
lines changed

editor/src/dispatcher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
5353
/// Since we don't need to update the frontend multiple times per frame,
5454
/// we have a set of messages which we will buffer until the next frame is requested.
5555
const FRONTEND_UPDATE_MESSAGES: &[MessageDiscriminant] = &[
56+
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(NodeGraphMessageDiscriminant::SendGraph))),
5657
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
5758
PropertiesPanelMessageDiscriminant::Refresh,
5859
))),

editor/src/messages/frontend/frontend_message.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use super::utility_types::{DocumentDetails, MouseCursorIcon, OpenDocument};
22
use crate::messages::app_window::app_window_message_handler::AppWindowPlatform;
33
use crate::messages::layout::utility_types::widget_prelude::*;
44
use crate::messages::portfolio::document::node_graph::utility_types::{
5-
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, NodeGraphError, Transform
5+
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendExports, FrontendImport, FrontendNodeOld, FrontendNodeType, NodeGraphError,
66
};
77
use crate::messages::portfolio::document::utility_types::nodes::{JsRawBuffer, LayerPanelEntry, RawBuffer};
8-
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate};
8+
use crate::messages::portfolio::document::utility_types::wires::{WirePathInProgress, WirePathUpdateOld};
99
use crate::messages::prelude::*;
1010
use crate::messages::tool::utility_types::HintData;
11-
use glam::IVec2;
1211
use graph_craft::document::NodeId;
12+
use graphene_std::node_graph_overlay::types::{FrontendXY, NodeGraphTransform};
1313
use graphene_std::raster::Image;
1414
use graphene_std::raster::color::Color;
1515
use graphene_std::text::{Font, TextAlign};
@@ -131,24 +131,23 @@ pub enum FrontendMessage {
131131
},
132132
UpdateImportsExports {
133133
/// If the primary import is not visible, then it is None.
134-
imports: Vec<Option<FrontendGraphOutput>>,
135-
/// If the primary export is not visible, then it is None.
136-
exports: Vec<Option<FrontendGraphInput>>,
134+
imports: Vec<Option<FrontendImport>>,
135+
exports: FrontendExports,
137136
/// The primary import location.
138137
#[serde(rename = "importPosition")]
139-
import_position: IVec2,
138+
import_position: FrontendXY,
140139
/// The primary export location.
141140
#[serde(rename = "exportPosition")]
142-
export_position: IVec2,
141+
export_position: FrontendXY,
143142
/// The document network does not have an add import or export button.
144143
#[serde(rename = "addImportExport")]
145144
add_import_export: bool,
146145
},
147-
UpdateInSelectedNetwork {
146+
UpdateInSelectedNetworkOld {
148147
#[serde(rename = "inSelectedNetwork")]
149148
in_selected_network: bool,
150149
},
151-
UpdateBox {
150+
UpdateNodeGraphSelectionBox {
152151
#[serde(rename = "box")]
153152
box_selection: Option<BoxSelection>,
154153
},
@@ -185,7 +184,7 @@ pub enum FrontendMessage {
185184
#[serde(rename = "exportIndex")]
186185
index: Option<usize>,
187186
},
188-
UpdateLayerWidths {
187+
UpdateLayerWidthsOld {
189188
#[serde(rename = "layerWidths")]
190189
layer_widths: HashMap<NodeId, u32>,
191190
#[serde(rename = "chainWidths")]
@@ -256,7 +255,7 @@ pub enum FrontendMessage {
256255
#[serde(rename = "setColorChoice")]
257256
set_color_choice: Option<String>,
258257
},
259-
UpdateGraphFadeArtwork {
258+
UpdateGraphFadeArtworkOld {
260259
percentage: f64,
261260
},
262261
UpdateInputHints {
@@ -286,29 +285,37 @@ pub enum FrontendMessage {
286285
UpdateMouseCursor {
287286
cursor: MouseCursorIcon,
288287
},
289-
UpdateNodeGraphNodes {
290-
nodes: Vec<FrontendNode>,
288+
UpdateNodeGraphNodesOld {
289+
nodes: Vec<FrontendNodeOld>,
290+
},
291+
UpdateNativeNodeGraphSVG {
292+
#[serde(rename = "svgString")]
293+
svg_string: String,
294+
},
295+
UpdateRenderNativeNodeGraph {
296+
#[serde(rename = "renderNativeNodeGraph")]
297+
render_native_node_graph: bool,
291298
},
292299
UpdateNodeGraphError {
293300
error: Option<NodeGraphError>,
294301
},
295-
UpdateVisibleNodes {
302+
UpdateVisibleNodesOld {
296303
nodes: Vec<NodeId>,
297304
},
298-
UpdateNodeGraphWires {
299-
wires: Vec<WirePathUpdate>,
305+
UpdateNodeGraphWiresOld {
306+
wires: Vec<WirePathUpdateOld>,
300307
},
301-
ClearAllNodeGraphWires,
308+
ClearAllNodeGraphWiresOld,
302309
UpdateNodeGraphControlBarLayout {
303310
#[serde(rename = "layoutTarget")]
304311
layout_target: LayoutTarget,
305312
diff: Vec<WidgetDiff>,
306313
},
307-
UpdateNodeGraphSelection {
314+
UpdateNodeGraphSelectionOld {
308315
selected: Vec<NodeId>,
309316
},
310317
UpdateNodeGraphTransform {
311-
transform: Transform,
318+
transform: NodeGraphTransform,
312319
},
313320
UpdateNodeThumbnail {
314321
id: NodeId,
@@ -334,8 +341,8 @@ pub enum FrontendMessage {
334341
diff: Vec<WidgetDiff>,
335342
},
336343
UpdateWirePathInProgress {
337-
#[serde(rename = "wirePath")]
338-
wire_path: Option<WirePath>,
344+
#[serde(rename = "wirePathInProgress")]
345+
wire_path_in_progress: Option<WirePathInProgress>,
339346
},
340347
UpdateWorkingColorsLayout {
341348
#[serde(rename = "layoutTarget")]

editor/src/messages/layout/utility_types/widgets/button_widgets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
22
use crate::messages::layout::utility_types::widget_prelude::*;
3-
use crate::messages::portfolio::document::node_graph::utility_types::FrontendGraphDataType;
43
use crate::messages::tool::tool_messages::tool_prelude::WidgetCallback;
54
use derivative::*;
5+
use graphene_std::node_graph_overlay::types::FrontendGraphDataType;
66
use graphene_std::vector::style::FillChoice;
77
use graphite_proc_macros::WidgetBuilder;
88

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::node_graph::document_node_definitions;
2-
use super::node_graph::utility_types::Transform;
32
use super::overlays::utility_types::Pivot;
43
use super::utility_types::error::EditorError;
54
use super::utility_types::misc::{GroupFolderType, SNAP_FUNCTIONS_FOR_BOUNDING_BOXES, SNAP_FUNCTIONS_FOR_PATHS, SnappingOptions, SnappingState};
@@ -31,6 +30,7 @@ use glam::{DAffine2, DVec2, IVec2};
3130
use graph_craft::document::value::TaggedValue;
3231
use graph_craft::document::{NodeId, NodeInput, NodeNetwork, OldNodeNetwork};
3332
use graphene_std::math::quad::Quad;
33+
use graphene_std::node_graph_overlay::types::NodeGraphTransform;
3434
use graphene_std::path_bool::{boolean_intersect, path_bool_lib};
3535
use graphene_std::raster::BlendMode;
3636
use graphene_std::raster_types::Raster;
@@ -55,6 +55,7 @@ pub struct DocumentMessageContext<'a> {
5555
pub data_panel_open: bool,
5656
pub layers_panel_open: bool,
5757
pub properties_panel_open: bool,
58+
pub render_native_node_graph: bool,
5859
pub viewport: &'a ViewportMessageHandler,
5960
}
6061

@@ -201,6 +202,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
201202
data_panel_open,
202203
layers_panel_open,
203204
properties_panel_open,
205+
render_native_node_graph,
204206
} = context;
205207

206208
match message {
@@ -263,6 +265,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
263265
preferences,
264266
layers_panel_open,
265267
viewport,
268+
render_native_node_graph,
266269
},
267270
);
268271
}
@@ -470,7 +473,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
470473
DocumentMessage::EnterNestedNetwork { node_id } => {
471474
self.breadcrumb_network_path.push(node_id);
472475
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
473-
responses.add(NodeGraphMessage::UnloadWires);
476+
responses.add(NodeGraphMessage::UnloadWiresOld);
474477
responses.add(NodeGraphMessage::SendGraph);
475478
responses.add(DocumentMessage::ZoomCanvasToFitAll);
476479
responses.add(NodeGraphMessage::UpdateNodeGraphWidth);
@@ -490,7 +493,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
490493
responses.add(FrontendMessage::UpdateContextMenuInformation { context_menu_information: None });
491494
self.node_graph_handler.wire_in_progress_from_connector = None;
492495
self.node_graph_handler.wire_in_progress_to_connector = None;
493-
responses.add(FrontendMessage::UpdateWirePathInProgress { wire_path: None });
496+
responses.add(FrontendMessage::UpdateWirePathInProgress { wire_path_in_progress: None });
494497
} else if !self.breadcrumb_network_path.is_empty() {
495498
// Exit one level up if inside a nested network
496499
responses.add(DocumentMessage::ExitNestedNetwork { steps_back: 1 });
@@ -503,7 +506,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
503506
self.breadcrumb_network_path.pop();
504507
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
505508
}
506-
responses.add(NodeGraphMessage::UnloadWires);
509+
responses.add(NodeGraphMessage::UnloadWiresOld);
507510
responses.add(NodeGraphMessage::SendGraph);
508511
responses.add(DocumentMessage::PTZUpdate);
509512
responses.add(NodeGraphMessage::UpdateNodeGraphWidth);
@@ -560,7 +563,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
560563
self.graph_view_overlay_open = open;
561564

562565
responses.add(FrontendMessage::UpdateGraphViewOverlay { open });
563-
responses.add(FrontendMessage::UpdateGraphFadeArtwork {
566+
responses.add(FrontendMessage::UpdateGraphFadeArtworkOld {
564567
percentage: self.graph_fade_artwork_percentage,
565568
});
566569

@@ -570,20 +573,21 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
570573
responses.add(DocumentMessage::RenderRulers);
571574
responses.add(DocumentMessage::RenderScrollbars);
572575
if opened {
573-
responses.add(NodeGraphMessage::UnloadWires);
576+
responses.add(NodeGraphMessage::UnloadWiresOld);
574577
}
575578
if open {
576579
responses.add(ToolMessage::DeactivateTools);
577580
responses.add(OverlaysMessage::Draw); // Clear the overlays
578581
responses.add(NavigationMessage::CanvasTiltSet { angle_radians: 0. });
579582
responses.add(NodeGraphMessage::UpdateGraphBarRight);
580-
responses.add(NodeGraphMessage::SendGraph);
581583
responses.add(NodeGraphMessage::UpdateHints);
582584
responses.add(NodeGraphMessage::UpdateEdges);
583585
} else {
584586
responses.add(ToolMessage::ActivateTool { tool_type: *current_tool });
585587
responses.add(OverlaysMessage::Draw); // Redraw overlays when graph is closed
586588
}
589+
590+
responses.add(NodeGraphMessage::SendGraph);
587591
}
588592
DocumentMessage::GraphViewOverlayToggle => {
589593
responses.add(DocumentMessage::GraphViewOverlay { open: !self.graph_view_overlay_open });
@@ -1196,7 +1200,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
11961200
}
11971201
responses.add(PropertiesPanelMessage::Refresh);
11981202
responses.add(NodeGraphMessage::UpdateLayerPanel);
1199-
responses.add(NodeGraphMessage::UpdateInSelectedNetwork);
1203+
responses.add(NodeGraphMessage::SendGraph);
12001204
}
12011205
DocumentMessage::SetBlendModeForSelectedLayers { blend_mode } => {
12021206
for layer in self.network_interface.selected_nodes().selected_layers_except_artboards(&self.network_interface) {
@@ -1205,7 +1209,10 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
12051209
}
12061210
DocumentMessage::SetGraphFadeArtwork { percentage } => {
12071211
self.graph_fade_artwork_percentage = percentage;
1208-
responses.add(FrontendMessage::UpdateGraphFadeArtwork { percentage });
1212+
responses.add(FrontendMessage::UpdateGraphFadeArtworkOld { percentage });
1213+
if render_native_node_graph {
1214+
responses.add(NodeGraphMessage::SendGraph);
1215+
}
12091216
}
12101217
DocumentMessage::SetNodePinned { node_id, pinned } => {
12111218
responses.add(DocumentMessage::AddTransaction);
@@ -1507,7 +1514,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
15071514
responses.add(NodeGraphMessage::UpdateImportsExports);
15081515

15091516
responses.add(FrontendMessage::UpdateNodeGraphTransform {
1510-
transform: Transform {
1517+
transform: NodeGraphTransform {
15111518
scale: transform.matrix2.x_axis.x,
15121519
x: transform.translation.x,
15131520
y: transform.translation.y,
@@ -1971,7 +1978,7 @@ impl DocumentMessageHandler {
19711978
responses.add(NodeGraphMessage::ForceRunDocumentGraph);
19721979

19731980
// TODO: Remove once the footprint is used to load the imports/export distances from the edge
1974-
responses.add(NodeGraphMessage::UnloadWires);
1981+
responses.add(NodeGraphMessage::UnloadWiresOld);
19751982

19761983
Some(previous_network)
19771984
}
@@ -2002,8 +2009,8 @@ impl DocumentMessageHandler {
20022009
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
20032010
responses.add(NodeGraphMessage::SelectedNodesUpdated);
20042011
responses.add(NodeGraphMessage::ForceRunDocumentGraph);
2005-
responses.add(NodeGraphMessage::UnloadWires);
2006-
responses.add(NodeGraphMessage::SendWires);
2012+
responses.add(NodeGraphMessage::UnloadWiresOld);
2013+
responses.add(NodeGraphMessage::SendWiresOld);
20072014
Some(previous_network)
20082015
}
20092016

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,12 @@ pub enum NodeGraphMessage {
141141
},
142142
SendClickTargets,
143143
EndSendClickTargets,
144-
UnloadWires,
145-
SendWires,
146-
UpdateVisibleNodes,
144+
UnloadWiresOld,
145+
SendWiresOld,
146+
UpdateVisibleNodesOld,
147147
SendGraph,
148+
SendGraphOld,
149+
SendGraphNew,
148150
SetInputValue {
149151
node_id: NodeId,
150152
input_index: usize,
@@ -232,7 +234,7 @@ pub enum NodeGraphMessage {
232234
},
233235
UpdateActionButtons,
234236
UpdateGraphBarRight,
235-
UpdateInSelectedNetwork,
237+
UpdateInSelectedNetworkOld,
236238
UpdateHints,
237-
SendSelectedNodes,
239+
SendSelectedNodesOld,
238240
}

0 commit comments

Comments
 (0)