From 4ce43f5521e87f5a21729e865e690d15e4f017a9 Mon Sep 17 00:00:00 2001 From: Okko Hakola Date: Sat, 22 Apr 2023 16:40:17 +0300 Subject: [PATCH] Update egui --- .gitignore | 1 + egui_node_graph/Cargo.toml | 4 ++-- egui_node_graph/src/editor_ui.rs | 24 +++++++++++++----------- egui_node_graph/src/node_finder.rs | 4 ++-- egui_node_graph_example/Cargo.toml | 2 +- egui_node_graph_example/src/main.rs | 3 ++- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 96ef6c0..408b8a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target Cargo.lock +.idea \ No newline at end of file diff --git a/egui_node_graph/Cargo.toml b/egui_node_graph/Cargo.toml index 25292d4..eb105e6 100644 --- a/egui_node_graph/Cargo.toml +++ b/egui_node_graph/Cargo.toml @@ -15,8 +15,8 @@ workspace = ".." persistence = ["serde", "slotmap/serde", "smallvec/serde", "egui/persistence"] [dependencies] -egui = { version = "0.19.0" } +egui = { version = "0.21.0" } slotmap = { version = "1.0" } -smallvec = { version = "1.7.0" } +smallvec = { version = "1.10.0" } serde = { version = "1.0", optional = true, features = ["derive"] } thiserror = "1.0" diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index dbc61a8..fe5751a 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -116,7 +116,9 @@ where let editor_rect = ui.max_rect(); ui.allocate_rect(editor_rect, Sense::hover()); - let cursor_pos = ui.ctx().input().pointer.hover_pos().unwrap_or(Pos2::ZERO); + let cursor_pos = ui + .ctx() + .input(|i| i.pointer.hover_pos().unwrap_or(Pos2::ZERO)); let mut cursor_in_editor = editor_rect.contains(cursor_pos); let mut cursor_in_finder = false; @@ -395,7 +397,7 @@ where /* Mouse input handling */ // This locks the context, so don't hold on to it for too long. - let mouse = &ui.ctx().input().pointer; + let mouse = &ui.ctx().input(|i| i.pointer.clone()); if mouse.any_released() && self.connection_in_progress.is_some() { self.connection_in_progress = None; @@ -404,12 +406,12 @@ where if mouse.secondary_released() && cursor_in_editor && !cursor_in_finder { self.node_finder = Some(NodeFinder::new_at(cursor_pos)); } - if ui.ctx().input().key_pressed(Key::Escape) { + if ui.ctx().input(|i| i.key_pressed(Key::Escape)) { self.node_finder = None; } - if r.dragged() && ui.ctx().input().pointer.middle_down() { - self.pan_zoom.pan += ui.ctx().input().pointer.delta(); + if r.dragged() && ui.ctx().input(|i| i.pointer.middle_down()) { + self.pan_zoom.pan += ui.ctx().input(|i| i.pointer.delta()); } // Deselect and deactivate finder if the editor backround is clicked, @@ -628,7 +630,7 @@ where port_type.data_type_color(user_state) }; ui.painter() - .circle(port_rect.center(), 5.0, port_color, Stroke::none()); + .circle(port_rect.center(), 5.0, port_color, Stroke::NONE); if resp.drag_started() { if is_connected_input { @@ -650,7 +652,7 @@ where // Don't allow self-loops if graph.any_param_type(origin_param).unwrap() == port_type && close_enough - && ui.input().pointer.any_released() + && ui.input(|i| i.pointer.any_released()) { match (param_id, origin_param) { (AnyParameterId::Input(input), AnyParameterId::Output(output)) @@ -734,7 +736,7 @@ where .user_data .titlebar_color(ui, self.node_id, self.graph, user_state) .unwrap_or_else(|| background_color.lighten(0.8)), - stroke: Stroke::none(), + stroke: Stroke::NONE, }); let body_rect = Rect::from_min_size( @@ -745,7 +747,7 @@ where rect: body_rect, rounding: Rounding::none(), fill: background_color, - stroke: Stroke::none(), + stroke: Stroke::NONE, }); let bottom_body_rect = Rect::from_min_size( @@ -756,7 +758,7 @@ where rect: bottom_body_rect, rounding, fill: background_color, - stroke: Stroke::none(), + stroke: Stroke::NONE, }); let node_rect = titlebar_rect.union(body_rect).union(bottom_body_rect); @@ -765,7 +767,7 @@ where rect: node_rect.expand(1.0), rounding, fill: Color32::WHITE.lighten(0.8), - stroke: Stroke::none(), + stroke: Stroke::NONE, }) } else { Shape::Noop diff --git a/egui_node_graph/src/node_finder.rs b/egui_node_graph/src/node_finder.rs index 87a9596..4225f9e 100644 --- a/egui_node_graph/src/node_finder.rs +++ b/egui_node_graph/src/node_finder.rs @@ -63,9 +63,9 @@ where self.just_spawned = false; } - let mut query_submit = resp.lost_focus() && ui.input().key_down(Key::Enter); + let mut query_submit = resp.lost_focus() && ui.input(|i| i.key_pressed(Key::Enter)); - let max_height = ui.input().screen_rect.height() * 0.5; + let max_height = ui.input(|i| i.screen_rect.height()); let scroll_area_width = resp.rect.width() - 30.0; Frame::default() diff --git a/egui_node_graph_example/Cargo.toml b/egui_node_graph_example/Cargo.toml index 7748d93..4094bfe 100644 --- a/egui_node_graph_example/Cargo.toml +++ b/egui_node_graph_example/Cargo.toml @@ -9,7 +9,7 @@ rust-version = "1.56" crate-type = ["cdylib", "rlib"] [dependencies] -eframe = "0.19.0" +eframe = "0.21.0" egui_node_graph = { path = "../egui_node_graph" } anyhow = "1.0" serde = { version = "1.0", optional = true } diff --git a/egui_node_graph_example/src/main.rs b/egui_node_graph_example/src/main.rs index 02d1528..0fe95af 100644 --- a/egui_node_graph_example/src/main.rs +++ b/egui_node_graph_example/src/main.rs @@ -19,5 +19,6 @@ fn main() { #[cfg(not(feature = "persistence"))] Box::new(egui_node_graph_example::NodeGraphExample::default()) }), - ); + ) + .expect("Failed to run native example"); }