Skip to content

Commit 9762f32

Browse files
committed
Add button
1 parent e2c4519 commit 9762f32

File tree

7 files changed

+288
-55
lines changed

7 files changed

+288
-55
lines changed

editor/src/messages/frontend/frontend_message.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ pub enum FrontendMessage {
281281
// Displays a dashed border around the node
282282
#[serde(rename = "previewedNode")]
283283
previewed_node: Option<NodeId>,
284+
#[serde(rename = "nativeNodeGraphRender")]
285+
native_node_graph_render: bool,
284286
},
285287
UpdateVisibleNodes {
286288
nodes: Vec<NodeId>,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ pub enum NodeGraphMessage {
185185
TogglePreviewImpl {
186186
node_id: NodeId,
187187
},
188+
ToggleNativeNodeGraphRender,
188189
SetImportExportName {
189190
name: String,
190191
index: ImportOrExport,

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pub struct NodeGraphMessageHandler {
9393
end_index: Option<usize>,
9494
/// Used to keep track of what nodes are sent to the front end so that only visible ones are sent to the frontend
9595
frontend_nodes: Vec<NodeId>,
96-
/// Used to keep track of what wires are sent to the front end so the old ones can be removed
97-
frontend_wires: HashSet<(NodeId, usize)>,
96+
/// Disables rendering nodes in Svelte
97+
native_node_graph_render: bool,
9898
}
9999

100100
/// NodeGraphMessageHandler always modifies the network which the selected nodes are in. No GraphOperationMessages should be added here, since those messages will always affect the document network.
@@ -1643,6 +1643,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
16431643
opacity: graph_fade_artwork_percentage,
16441644
in_selected_network: selection_network_path == breadcrumb_network_path,
16451645
previewed_node,
1646+
native_node_graph_render: self.native_node_graph_render,
16461647
});
16471648
responses.add(NodeGraphMessage::UpdateVisibleNodes);
16481649

@@ -1800,6 +1801,10 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
18001801
NodeGraphMessage::TogglePreviewImpl { node_id } => {
18011802
network_interface.toggle_preview(node_id, selection_network_path);
18021803
}
1804+
NodeGraphMessage::ToggleNativeNodeGraphRender => {
1805+
self.native_node_graph_render = !self.native_node_graph_render;
1806+
responses.add(NodeGraphMessage::SendGraph);
1807+
}
18031808
NodeGraphMessage::ToggleSelectedLocked => {
18041809
let Some(selected_nodes) = network_interface.selected_nodes_in_nested_network(selection_network_path) else {
18051810
log::error!("Could not get selected nodes in NodeGraphMessage::ToggleSelectedLocked");
@@ -2667,7 +2672,7 @@ impl Default for NodeGraphMessageHandler {
26672672
reordering_import: None,
26682673
end_index: None,
26692674
frontend_nodes: Vec::new(),
2670-
frontend_wires: HashSet::new(),
2675+
native_node_graph_render: false,
26712676
}
26722677
}
26732678
}

editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct MenuBarMessageHandler {
1818
pub has_selection_history: (bool, bool),
1919
pub message_logging_verbosity: MessageLoggingVerbosity,
2020
pub reset_node_definitions_on_open: bool,
21+
pub native_node_graph_render: bool,
2122
pub make_path_editable_is_allowed: bool,
2223
pub data_panel_open: bool,
2324
pub layers_panel_open: bool,
@@ -48,6 +49,7 @@ impl LayoutHolder for MenuBarMessageHandler {
4849
let message_logging_verbosity_names = self.message_logging_verbosity == MessageLoggingVerbosity::Names;
4950
let message_logging_verbosity_contents = self.message_logging_verbosity == MessageLoggingVerbosity::Contents;
5051
let reset_node_definitions_on_open = self.reset_node_definitions_on_open;
52+
let native_node_graph_render = self.native_node_graph_render;
5153
let make_path_editable_is_allowed = self.make_path_editable_is_allowed;
5254

5355
let menu_bar_entries = vec![
@@ -696,6 +698,12 @@ impl LayoutHolder for MenuBarMessageHandler {
696698
action: MenuBarEntry::create_action(|_| PortfolioMessage::ToggleResetNodesToDefinitionsOnOpen.into()),
697699
..MenuBarEntry::default()
698700
}],
701+
vec![MenuBarEntry {
702+
label: "Native Node Graph UI Render".into(),
703+
icon: Some(if native_node_graph_render { "CheckboxChecked" } else { "CheckboxUnchecked" }.into()),
704+
action: MenuBarEntry::create_action(|_| NodeGraphMessage::ToggleNativeNodeGraphRender.into()),
705+
..MenuBarEntry::default()
706+
}],
699707
vec![
700708
MenuBarEntry {
701709
label: "Print Trace Logs".into(),

0 commit comments

Comments
 (0)