From 0cb69436c8fa10f4dc65669329b1f9cbbaac5d7c Mon Sep 17 00:00:00 2001 From: Adesh Gupta Date: Mon, 7 Jul 2025 19:44:48 +0530 Subject: [PATCH 1/5] Fix showing only compatible nodes --- .../utility_types/widgets/input_widgets.rs | 3 +++ .../document/document_message_handler.rs | 18 ++++++++++++++++-- .../node_graph/node_graph_message_handler.rs | 14 +++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/editor/src/messages/layout/utility_types/widgets/input_widgets.rs b/editor/src/messages/layout/utility_types/widgets/input_widgets.rs index b76f23a067..be30d368ec 100644 --- a/editor/src/messages/layout/utility_types/widgets/input_widgets.rs +++ b/editor/src/messages/layout/utility_types/widgets/input_widgets.rs @@ -332,6 +332,9 @@ pub enum NumberInputMode { pub struct NodeCatalog { pub disabled: bool, + #[serde(rename = "initialSearchTerm")] + pub intial_search: String, + // Callbacks #[serde(skip)] #[derivative(Debug = "ignore", PartialEq = "ignore")] diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 81f631dfe0..3ba94a9581 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -16,7 +16,7 @@ use crate::messages::portfolio::document::overlays::utility_types::{OverlaysType use crate::messages::portfolio::document::properties_panel::utility_types::PropertiesPanelMessageHandlerData; use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier}; use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, DocumentMode, FlipAxis, PTZ}; -use crate::messages::portfolio::document::utility_types::network_interface::{FlowType, InputConnector, NodeTemplate}; +use crate::messages::portfolio::document::utility_types::network_interface::{FlowType, InputConnector, NodeTemplate, OutputConnector}; use crate::messages::portfolio::document::utility_types::nodes::RawBuffer; use crate::messages::portfolio::utility_types::PersistentData; use crate::messages::prelude::*; @@ -2704,7 +2704,21 @@ impl DocumentMessageHandler { .tooltip("Add an operation to the end of this layer's chain of nodes") .disabled(!has_selection || has_multiple_selection) .popover_layout({ - let node_chooser = NodeCatalog::new() + // Showing only compatible types + let compatible_type = selected_layer.and_then(|layer| { + let input_connector = InputConnector::node(layer.to_node(), 1); + if let Some(OutputConnector::Node { node_id, .. }) = self.network_interface.upstream_output_connector(&input_connector, &self.selection_network_path) { + let (output_type, _) = self.network_interface.output_type(&node_id, 0, &self.selection_network_path); + Some(format!("type:{}", output_type.nested_type())) + } else { + None + } + }); + + let mut node_chooser = NodeCatalog::new(); + node_chooser.intial_search = compatible_type.unwrap_or("".to_string()); + + let node_chooser = node_chooser .on_update(move |node_type| { if let Some(layer) = selected_layer { NodeGraphMessage::CreateNodeInLayerWithTransaction { diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index b3f1596cd2..6b0a13af1f 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -2112,7 +2112,19 @@ impl NodeGraphMessageHandler { .icon(Some("Node".to_string())) .tooltip("Add an operation to the end of this layer's chain of nodes") .popover_layout({ - let node_chooser = NodeCatalog::new() + let input_connector = InputConnector::node(layer, 1); + let compatible_type = + if let Some(OutputConnector::Node { node_id, .. }) = context.network_interface.upstream_output_connector(&input_connector, &context.selection_network_path) { + let (output_type, _) = context.network_interface.output_type(&node_id, 0, &context.selection_network_path); + Some(format!("type:{}", output_type.nested_type())) + } else { + None + }; + + let mut node_chooser = NodeCatalog::new(); + node_chooser.intial_search = compatible_type.unwrap_or("".to_string()); + + let node_chooser = node_chooser .on_update(move |node_type| { NodeGraphMessage::CreateNodeInLayerWithTransaction { node_type: node_type.clone(), From c615f72f2f39b5fa4eefba9510628c39da6b0b8c Mon Sep 17 00:00:00 2001 From: Adesh Gupta Date: Thu, 10 Jul 2025 10:45:37 +0530 Subject: [PATCH 2/5] Implement search on Add Node button --- .../node_graph/node_graph_message_handler.rs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 6b0a13af1f..23bce62521 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -1823,12 +1823,33 @@ impl NodeGraphMessageHandler { let selection_all_locked = network_interface.selected_nodes().selected_unlocked_layers(network_interface).count() == 0; let selection_all_visible = selected_nodes.selected_nodes().all(|node_id| network_interface.is_visible(node_id, breadcrumb_network_path)); + let mut selected_layers = selected_nodes.selected_layers(network_interface.document_metadata()); + let selected_layer = selected_layers.next(); + let has_multiple_selection = selected_layers.next().is_some(); + let mut widgets = vec![ PopoverButton::new() .icon(Some("Node".to_string())) .tooltip("New Node (Right Click)") .popover_layout({ - let node_chooser = NodeCatalog::new() + // Showing only compatible types + let compatible_type = match (selection_includes_layers, has_multiple_selection, selected_layer) { + (true, false, Some(layer)) => { + let input_connector = InputConnector::node(layer.to_node(), 1); + if let Some(OutputConnector::Node { node_id, .. }) = network_interface.upstream_output_connector(&input_connector, &breadcrumb_network_path) { + let (output_type, _) = network_interface.output_type(&node_id, 0, &breadcrumb_network_path); + Some(format!("type:{}", output_type.nested_type())) + } else { + None + } + } + _ => None, + }; + + let mut node_chooser = NodeCatalog::new(); + node_chooser.intial_search = compatible_type.unwrap_or("".to_string()); + + let node_chooser = node_chooser .on_update(move |node_type| { let node_id = NodeId::new(); From 0dd61ef588b7863770f64b03e493559629837d26 Mon Sep 17 00:00:00 2001 From: Adesh Gupta Date: Tue, 15 Jul 2025 18:57:58 +0530 Subject: [PATCH 3/5] Fix add node behaviour --- .../node_graph/node_graph_message_handler.rs | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 891d51ab1d..ebf283ac20 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -1847,24 +1847,33 @@ impl NodeGraphMessageHandler { _ => None, }; + let single_layer_selected = selection_includes_layers && !has_multiple_selection; + let mut node_chooser = NodeCatalog::new(); node_chooser.intial_search = compatible_type.unwrap_or("".to_string()); let node_chooser = node_chooser .on_update(move |node_type| { - let node_id = NodeId::new(); - - Message::Batched { - messages: Box::new([ - NodeGraphMessage::CreateNodeFromContextMenu { - node_id: Some(node_id), - node_type: node_type.clone(), - xy: None, - add_transaction: true, - } - .into(), - NodeGraphMessage::SelectedNodesSet { nodes: vec![node_id] }.into(), - ]), + if let (true, Some(layer)) = (single_layer_selected, selected_layer) { + NodeGraphMessage::CreateNodeInLayerWithTransaction { + node_type: node_type.clone(), + layer: LayerNodeIdentifier::new_unchecked(layer.to_node()), + } + .into() + } else { + let node_id = NodeId::new(); + Message::Batched { + messages: Box::new([ + NodeGraphMessage::CreateNodeFromContextMenu { + node_id: Some(node_id), + node_type: node_type.clone(), + xy: None, + add_transaction: true, + } + .into(), + NodeGraphMessage::SelectedNodesSet { nodes: vec![node_id] }.into(), + ]), + } } }) .widget_holder(); From 0f99f27b3e582df7e6f5afe1a0fe42d63908d7c7 Mon Sep 17 00:00:00 2001 From: Adesh Gupta Date: Fri, 18 Jul 2025 03:12:11 +0530 Subject: [PATCH 4/5] Improve type identification logic --- .../portfolio/document/document_message_handler.rs | 7 ++++--- .../document/node_graph/node_graph_message_handler.rs | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index 0dd4b6e921..48e9d322ce 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -16,7 +16,7 @@ use crate::messages::portfolio::document::overlays::utility_types::{OverlaysType use crate::messages::portfolio::document::properties_panel::properties_panel_message_handler::PropertiesPanelMessageContext; use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier}; use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate, AlignAxis, DocumentMode, FlipAxis, PTZ}; -use crate::messages::portfolio::document::utility_types::network_interface::{FlowType, InputConnector, NodeTemplate, OutputConnector}; +use crate::messages::portfolio::document::utility_types::network_interface::{FlowType, InputConnector, NodeTemplate}; use crate::messages::portfolio::document::utility_types::nodes::RawBuffer; use crate::messages::portfolio::utility_types::PersistentData; use crate::messages::prelude::*; @@ -2743,8 +2743,9 @@ impl DocumentMessageHandler { .popover_layout({ // Showing only compatible types let compatible_type = selected_layer.and_then(|layer| { - let input_connector = InputConnector::node(layer.to_node(), 1); - if let Some(OutputConnector::Node { node_id, .. }) = self.network_interface.upstream_output_connector(&input_connector, &self.selection_network_path) { + let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer, &self.network_interface); + let node_type = graph_layer.horizontal_layer_flow().nth(1); + if let Some(node_id) = node_type { let (output_type, _) = self.network_interface.output_type(&node_id, 0, &self.selection_network_path); Some(format!("type:{}", output_type.nested_type())) } else { diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index ebf283ac20..0551d3ef76 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -16,7 +16,7 @@ use crate::messages::portfolio::document::utility_types::nodes::{CollapsedLayers use crate::messages::portfolio::document::utility_types::wires::{GraphWireStyle, WirePath, WirePathUpdate, build_vector_wire}; use crate::messages::prelude::*; use crate::messages::tool::common_functionality::auto_panning::AutoPanning; -use crate::messages::tool::common_functionality::graph_modification_utils::get_clip_mode; +use crate::messages::tool::common_functionality::graph_modification_utils::{self, get_clip_mode}; use crate::messages::tool::tool_messages::tool_prelude::{Key, MouseMotion}; use crate::messages::tool::utility_types::{HintData, HintGroup, HintInfo}; use glam::{DAffine2, DVec2, IVec2}; @@ -1836,9 +1836,10 @@ impl NodeGraphMessageHandler { // Showing only compatible types let compatible_type = match (selection_includes_layers, has_multiple_selection, selected_layer) { (true, false, Some(layer)) => { - let input_connector = InputConnector::node(layer.to_node(), 1); - if let Some(OutputConnector::Node { node_id, .. }) = network_interface.upstream_output_connector(&input_connector, &breadcrumb_network_path) { - let (output_type, _) = network_interface.output_type(&node_id, 0, &breadcrumb_network_path); + let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer, network_interface); + let node_type = graph_layer.horizontal_layer_flow().nth(1); + if let Some(node_id) = node_type { + let (output_type, _) = network_interface.output_type(&node_id, 0, &[]); Some(format!("type:{}", output_type.nested_type())) } else { None From 65d621eb2673de68e028e6516a72684438281ef7 Mon Sep 17 00:00:00 2001 From: Adesh Gupta Date: Fri, 18 Jul 2025 03:21:50 +0530 Subject: [PATCH 5/5] Fix input type identification --- .../node_graph/node_graph_message_handler.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 0551d3ef76..56cebadd49 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -2146,14 +2146,17 @@ impl NodeGraphMessageHandler { .icon(Some("Node".to_string())) .tooltip("Add an operation to the end of this layer's chain of nodes") .popover_layout({ - let input_connector = InputConnector::node(layer, 1); - let compatible_type = - if let Some(OutputConnector::Node { node_id, .. }) = context.network_interface.upstream_output_connector(&input_connector, &context.selection_network_path) { - let (output_type, _) = context.network_interface.output_type(&node_id, 0, &context.selection_network_path); + let layer_identifier = LayerNodeIdentifier::new(layer, &context.network_interface, context.selection_network_path); + let compatible_type = { + let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer_identifier, &context.network_interface); + let node_type = graph_layer.horizontal_layer_flow().nth(1); + if let Some(node_id) = node_type { + let (output_type, _) = context.network_interface.output_type(&node_id, 0, &[]); Some(format!("type:{}", output_type.nested_type())) } else { None - }; + } + }; let mut node_chooser = NodeCatalog::new(); node_chooser.intial_search = compatible_type.unwrap_or("".to_string());