From fad164b88cbbbea1fa6bf791fca56c6317156c51 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Tue, 9 May 2023 16:54:09 +0200 Subject: [PATCH 1/3] NodeDataTrait::top_bar_ui fix doc comment --- egui_node_graph/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egui_node_graph/src/traits.rs b/egui_node_graph/src/traits.rs index 72a81e6..535ec0e 100644 --- a/egui_node_graph/src/traits.rs +++ b/egui_node_graph/src/traits.rs @@ -113,7 +113,7 @@ where where Self::Response: UserResponseTrait; - // UI to draw on the top bar of the node. + /// UI to draw on the top bar of the node. fn top_bar_ui( &self, _ui: &mut egui::Ui, From 297615304678fa5c3d234806c71bf25138fe7ab3 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Tue, 9 May 2023 16:58:08 +0200 Subject: [PATCH 2/3] Add NodeDataTrait::separator --- egui_node_graph/src/editor_ui.rs | 15 +++++++++++++++ egui_node_graph/src/traits.rs | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index d009e42..9d1bd9e 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -600,6 +600,13 @@ where responses.extend(node_responses.into_iter().map(NodeResponse::User)); } + self.graph[self.node_id].user_data.separator( + ui, + self.node_id, + self.graph, + user_state, + ); + self.graph[param_id].value = value; let height_after = ui.min_rect().bottom(); @@ -616,6 +623,14 @@ where .output_ui(ui, self.node_id, self.graph, user_state, ¶m_name) .into_iter(), ); + + self.graph[self.node_id].user_data.separator( + ui, + self.node_id, + self.graph, + user_state, + ); + let height_after = ui.min_rect().bottom(); output_port_heights.push((height_before + height_after) / 2.0); } diff --git a/egui_node_graph/src/traits.rs b/egui_node_graph/src/traits.rs index 535ec0e..8354035 100644 --- a/egui_node_graph/src/traits.rs +++ b/egui_node_graph/src/traits.rs @@ -158,6 +158,22 @@ where None } + /// Separator to put between elements in the node. + /// + /// Invoked between inputs, outputs and bottom UI. Useful for + /// complicated UIs that start to lose structure without explicit + /// separators. + /// + /// Default implementation does nothing. + fn separator( + &self, + _ui: &mut egui::Ui, + _node_id: NodeId, + _graph: &Graph, + _user_state: &mut Self::UserState, + ) { + } + fn can_delete( &self, _node_id: NodeId, From 02e625ccd7830419e4e96aff5d48374caa016437 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Sat, 13 May 2023 12:40:29 +0200 Subject: [PATCH 3/3] Add AnyParameterId argument to NodeDataTrait::separator --- egui_node_graph/src/editor_ui.rs | 4 +++- egui_node_graph/src/traits.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index 9d1bd9e..d8ef9af 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -603,6 +603,7 @@ where self.graph[self.node_id].user_data.separator( ui, self.node_id, + AnyParameterId::Input(param_id), self.graph, user_state, ); @@ -615,7 +616,7 @@ where } let outputs = self.graph[self.node_id].outputs.clone(); - for (param_name, _param) in outputs { + for (param_name, param_id) in outputs { let height_before = ui.min_rect().bottom(); responses.extend( self.graph[self.node_id] @@ -627,6 +628,7 @@ where self.graph[self.node_id].user_data.separator( ui, self.node_id, + AnyParameterId::Output(param_id), self.graph, user_state, ); diff --git a/egui_node_graph/src/traits.rs b/egui_node_graph/src/traits.rs index 8354035..209caf1 100644 --- a/egui_node_graph/src/traits.rs +++ b/egui_node_graph/src/traits.rs @@ -162,13 +162,15 @@ where /// /// Invoked between inputs, outputs and bottom UI. Useful for /// complicated UIs that start to lose structure without explicit - /// separators. + /// separators. The `param_id` argument is the id of input or output + /// *preceeding* the separator. /// /// Default implementation does nothing. fn separator( &self, _ui: &mut egui::Ui, _node_id: NodeId, + _param_id: AnyParameterId, _graph: &Graph, _user_state: &mut Self::UserState, ) {