From a91dbce1c4b9f105f5ab1e5ef08e4c160dc3ad85 Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:30:52 -0800 Subject: [PATCH 1/6] try right --- egui_node_graph2/src/editor_ui.rs | 61 ++++++++++++++++--------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/egui_node_graph2/src/editor_ui.rs b/egui_node_graph2/src/editor_ui.rs index 9c3323b..465f69b 100644 --- a/egui_node_graph2/src/editor_ui.rs +++ b/egui_node_graph2/src/editor_ui.rs @@ -709,6 +709,38 @@ where title_height = ui.min_size().y; // First pass: Draw the inner fields. Compute port heights + let outputs = self.graph[self.node_id].outputs.clone(); + for (param_name, param_id) in outputs { + let height_before = ui.min_rect().bottom(); + + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + responses.extend( + self.graph[self.node_id] + .user_data + .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, + AnyParameterId::Output(param_id), + self.graph, + user_state, + ); + + let height_after = ui.min_rect().bottom(); + output_port_heights.push((height_before + height_after) / 2.0); + } + + responses.extend(self.graph[self.node_id].user_data.bottom_ui( + ui, + self.node_id, + self.graph, + user_state, + )); + let inputs = self.graph[self.node_id].inputs.clone(); for (param_name, param_id) in inputs { if self.graph[param_id].shown_inline { @@ -783,35 +815,6 @@ where input_port_heights.push((height_before + height_after) / 2.0); } } - - let outputs = self.graph[self.node_id].outputs.clone(); - for (param_name, param_id) in outputs { - let height_before = ui.min_rect().bottom(); - responses.extend( - self.graph[self.node_id] - .user_data - .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, - AnyParameterId::Output(param_id), - self.graph, - user_state, - ); - - let height_after = ui.min_rect().bottom(); - output_port_heights.push((height_before + height_after) / 2.0); - } - - responses.extend(self.graph[self.node_id].user_data.bottom_ui( - ui, - self.node_id, - self.graph, - user_state, - )); }); // Second pass, iterate again to draw the ports. This happens outside From 1de640123744a7f44be26c5b9e18486d149587ea Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:32:24 -0800 Subject: [PATCH 2/6] try fix --- egui_node_graph2/src/editor_ui.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/egui_node_graph2/src/editor_ui.rs b/egui_node_graph2/src/editor_ui.rs index 465f69b..7247614 100644 --- a/egui_node_graph2/src/editor_ui.rs +++ b/egui_node_graph2/src/editor_ui.rs @@ -713,14 +713,19 @@ where for (param_name, param_id) in outputs { let height_before = ui.min_rect().bottom(); - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - responses.extend( - self.graph[self.node_id] - .user_data - .output_ui(ui, self.node_id, self.graph, user_state, ¶m_name) - .into_iter(), - ); - }); + let response = ui.scope(|ui| { + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + responses.extend( + self.graph[self.node_id] + .user_data + .output_ui(ui, self.node_id, self.graph, user_state, ¶m_name) + .into_iter(), + ); + }); + }).response; + + let rect = response.rect; + output_port_heights.push(rect.center().y); self.graph[self.node_id].user_data.separator( ui, @@ -729,9 +734,6 @@ where self.graph, user_state, ); - - let height_after = ui.min_rect().bottom(); - output_port_heights.push((height_before + height_after) / 2.0); } responses.extend(self.graph[self.node_id].user_data.bottom_ui( From 6987d91a2e371bdf9c8073051b406cafc0bf2590 Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:33:44 -0800 Subject: [PATCH 3/6] try fix2 --- egui_node_graph2/src/editor_ui.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/egui_node_graph2/src/editor_ui.rs b/egui_node_graph2/src/editor_ui.rs index 7247614..374891a 100644 --- a/egui_node_graph2/src/editor_ui.rs +++ b/egui_node_graph2/src/editor_ui.rs @@ -713,19 +713,16 @@ where for (param_name, param_id) in outputs { let height_before = ui.min_rect().bottom(); - let response = ui.scope(|ui| { - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - responses.extend( - self.graph[self.node_id] - .user_data - .output_ui(ui, self.node_id, self.graph, user_state, ¶m_name) - .into_iter(), - ); - }); - }).response; - - let rect = response.rect; - output_port_heights.push(rect.center().y); + ui.horizontal(|ui| { + ui.allocate_space(ui.available_size()); // Push everything to the right + + responses.extend( + self.graph[self.node_id] + .user_data + .output_ui(ui, self.node_id, self.graph, user_state, ¶m_name) + .into_iter(), + ); + }); self.graph[self.node_id].user_data.separator( ui, @@ -734,6 +731,9 @@ where self.graph, user_state, ); + + let height_after = ui.min_rect().bottom(); + output_port_heights.push((height_before + height_after) / 2.0); } responses.extend(self.graph[self.node_id].user_data.bottom_ui( From c961186dd484b9f6ff0eadd740c073fc22de0b32 Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:40:44 -0800 Subject: [PATCH 4/6] Replace deprecated egui methods. Fix example --- egui_node_graph2/src/editor_ui.rs | 10 +++------- egui_node_graph2/src/graph_impls.rs | 4 ++-- egui_node_graph2_example/src/app.rs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/egui_node_graph2/src/editor_ui.rs b/egui_node_graph2/src/editor_ui.rs index 374891a..aa11981 100644 --- a/egui_node_graph2/src/editor_ui.rs +++ b/egui_node_graph2/src/editor_ui.rs @@ -617,12 +617,8 @@ where ui: &mut Ui, user_state: &mut UserState, ) -> Vec> { - let mut child_ui = ui.child_ui_with_id_source( - Rect::from_min_size(*self.position + self.pan, Self::MAX_NODE_SIZE.into()), - Layout::default(), - self.node_id, - None, - ); + let max_rect = Rect::from_min_size(*self.position + self.pan, Self::MAX_NODE_SIZE.into()); + let mut child_ui = ui.new_child(UiBuilder::new().max_rect(max_rect).id_salt(self.node_id)); Self::show_graph_node(self, pan_zoom, &mut child_ui, user_state) } @@ -666,7 +662,7 @@ where inner_rect.max.x = inner_rect.max.x.max(inner_rect.min.x); inner_rect.max.y = inner_rect.max.y.max(inner_rect.min.y); - let mut child_ui = ui.child_ui(inner_rect, *ui.layout(), None); + let mut child_ui = ui.new_child(UiBuilder::new().max_rect(inner_rect).layout(*ui.layout())); // Get interaction rect from memory, it may expand after the window response on resize. let interaction_rect = ui diff --git a/egui_node_graph2/src/graph_impls.rs b/egui_node_graph2/src/graph_impls.rs index a117b95..9ab0e3e 100644 --- a/egui_node_graph2/src/graph_impls.rs +++ b/egui_node_graph2/src/graph_impls.rs @@ -241,14 +241,14 @@ impl Node { pub fn inputs<'a, DataType, DataValue>( &'a self, graph: &'a Graph, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'a { self.input_ids().map(|id| graph.get_input(id)) } pub fn outputs<'a, DataType, DataValue>( &'a self, graph: &'a Graph, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + 'a { self.output_ids().map(|id| graph.get_output(id)) } diff --git a/egui_node_graph2_example/src/app.rs b/egui_node_graph2_example/src/app.rs index e5daf74..aeeb756 100644 --- a/egui_node_graph2_example/src/app.rs +++ b/egui_node_graph2_example/src/app.rs @@ -412,7 +412,7 @@ impl eframe::App for NodeGraphExample { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { egui::TopBottomPanel::top("top").show(ctx, |ui| { egui::menu::bar(ui, |ui| { - egui::widgets::global_dark_light_mode_switch(ui); + egui::widgets::global_theme_preference_switch(ui); }); }); let graph_response = egui::CentralPanel::default() From e19ce71bf00724089661329708af9aa26bd2af20 Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:42:59 -0800 Subject: [PATCH 5/6] . --- egui_node_graph2/src/editor_ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egui_node_graph2/src/editor_ui.rs b/egui_node_graph2/src/editor_ui.rs index aa11981..b4a8daf 100644 --- a/egui_node_graph2/src/editor_ui.rs +++ b/egui_node_graph2/src/editor_ui.rs @@ -710,7 +710,7 @@ where let height_before = ui.min_rect().bottom(); ui.horizontal(|ui| { - ui.allocate_space(ui.available_size()); // Push everything to the right + ui.allocate_space(ui.available_size()); responses.extend( self.graph[self.node_id] From e74fe3a1f8daa8864c163c76839a09ae793cfce7 Mon Sep 17 00:00:00 2001 From: cybersoulK Date: Sun, 29 Dec 2024 23:44:09 -0800 Subject: [PATCH 6/6] . --- egui_node_graph2/src/graph_impls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/egui_node_graph2/src/graph_impls.rs b/egui_node_graph2/src/graph_impls.rs index 9ab0e3e..fa2a91e 100644 --- a/egui_node_graph2/src/graph_impls.rs +++ b/egui_node_graph2/src/graph_impls.rs @@ -241,14 +241,14 @@ impl Node { pub fn inputs<'a, DataType, DataValue>( &'a self, graph: &'a Graph, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> { self.input_ids().map(|id| graph.get_input(id)) } pub fn outputs<'a, DataType, DataValue>( &'a self, graph: &'a Graph, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> { self.output_ids().map(|id| graph.get_output(id)) }