mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-16 08:18:28 +00:00
Update to egui 0.18
This commit is contained in:
parent
bf86623866
commit
0ca71cec86
@ -15,7 +15,7 @@ workspace = ".."
|
|||||||
persistence = ["serde", "slotmap/serde", "smallvec/serde", "egui/persistence"]
|
persistence = ["serde", "slotmap/serde", "smallvec/serde", "egui/persistence"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = { version = "0.17" }
|
egui = { version = "0.18" }
|
||||||
slotmap = { version = "1.0" }
|
slotmap = { version = "1.0" }
|
||||||
smallvec = { version = "1.7.0" }
|
smallvec = { version = "1.7.0" }
|
||||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||||
|
|||||||
@ -63,8 +63,7 @@ where
|
|||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
|
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
|
||||||
) -> GraphResponse<UserResponse> {
|
) -> GraphResponse<UserResponse> {
|
||||||
let mouse = &ctx.input().pointer;
|
let cursor_pos = ctx.input().pointer.hover_pos().unwrap_or(Pos2::ZERO);
|
||||||
let cursor_pos = mouse.hover_pos().unwrap_or(Pos2::ZERO);
|
|
||||||
|
|
||||||
// Gets filled with the port locations as nodes are drawn
|
// Gets filled with the port locations as nodes are drawn
|
||||||
let mut port_locations = PortLocations::new();
|
let mut port_locations = PortLocations::new();
|
||||||
@ -224,6 +223,9 @@ where
|
|||||||
|
|
||||||
/* Mouse input handling */
|
/* Mouse input handling */
|
||||||
|
|
||||||
|
// This locks the context, so don't hold on to it for too long.
|
||||||
|
let mouse = &ctx.input().pointer;
|
||||||
|
|
||||||
if mouse.any_released() && self.connection_in_progress.is_some() {
|
if mouse.any_released() && self.connection_in_progress.is_some() {
|
||||||
self.connection_in_progress = None;
|
self.connection_in_progress = None;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@ where
|
|||||||
|
|
||||||
let frame = Frame::dark_canvas(ui.style())
|
let frame = Frame::dark_canvas(ui.style())
|
||||||
.fill(background_color)
|
.fill(background_color)
|
||||||
.margin(vec2(5.0, 5.0));
|
.inner_margin(vec2(5.0, 5.0));
|
||||||
|
|
||||||
// The archetype that will be returned.
|
// The archetype that will be returned.
|
||||||
let mut submitted_archetype = None;
|
let mut submitted_archetype = None;
|
||||||
@ -55,19 +55,21 @@ where
|
|||||||
|
|
||||||
let mut query_submit = resp.lost_focus() && ui.input().key_down(Key::Enter);
|
let mut query_submit = resp.lost_focus() && ui.input().key_down(Key::Enter);
|
||||||
|
|
||||||
Frame::default().margin(vec2(10.0, 10.0)).show(ui, |ui| {
|
Frame::default()
|
||||||
for kind in all_kinds.all_kinds() {
|
.inner_margin(vec2(10.0, 10.0))
|
||||||
let kind_name = kind.node_finder_label().to_string();
|
.show(ui, |ui| {
|
||||||
if kind_name.contains(self.query.as_str()) {
|
for kind in all_kinds.all_kinds() {
|
||||||
if ui.selectable_label(false, kind_name).clicked() {
|
let kind_name = kind.node_finder_label().to_string();
|
||||||
submitted_archetype = Some(kind);
|
if kind_name.contains(self.query.as_str()) {
|
||||||
} else if query_submit {
|
if ui.selectable_label(false, kind_name).clicked() {
|
||||||
submitted_archetype = Some(kind);
|
submitted_archetype = Some(kind);
|
||||||
query_submit = false;
|
} else if query_submit {
|
||||||
|
submitted_archetype = Some(kind);
|
||||||
|
query_submit = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ rust-version = "1.56"
|
|||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = "0.17.0"
|
eframe = "0.18.0"
|
||||||
egui_node_graph = { path = "../egui_node_graph" }
|
egui_node_graph = { path = "../egui_node_graph" }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use eframe::{
|
use eframe::egui::{self, DragValue, TextStyle};
|
||||||
egui::{self, DragValue, TextStyle},
|
|
||||||
epi,
|
|
||||||
};
|
|
||||||
use egui_node_graph::*;
|
use egui_node_graph::*;
|
||||||
|
|
||||||
// ========= First, define your user data types =============
|
// ========= First, define your user data types =============
|
||||||
@ -352,14 +349,10 @@ impl Default for NodeGraphExample {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl epi::App for NodeGraphExample {
|
impl eframe::App for NodeGraphExample {
|
||||||
fn name(&self) -> &str {
|
|
||||||
"Egui node graph example"
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called each time the UI needs repainting, which may be many times per second.
|
/// Called each time the UI needs repainting, which may be many times per second.
|
||||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
let graph_response = self.state.draw_graph_editor(ctx, AllMyNodeTemplates);
|
let graph_response = self.state.draw_graph_editor(ctx, AllMyNodeTemplates);
|
||||||
for node_response in graph_response.node_responses {
|
for node_response in graph_response.node_responses {
|
||||||
// Here, we ignore all other graph events. But you may find
|
// Here, we ignore all other graph events. But you may find
|
||||||
|
|||||||
@ -5,7 +5,14 @@
|
|||||||
// When compiling natively:
|
// When compiling natively:
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = egui_node_graph_example::NodeGraphExample::default();
|
use eframe::egui::Visuals;
|
||||||
let native_options = eframe::NativeOptions::default();
|
|
||||||
eframe::run_native(Box::new(app), native_options);
|
eframe::run_native(
|
||||||
|
"Egui node graph example",
|
||||||
|
eframe::NativeOptions::default(),
|
||||||
|
Box::new(|cc| {
|
||||||
|
cc.egui_ctx.set_visuals(Visuals::dark());
|
||||||
|
Box::new(egui_node_graph_example::NodeGraphExample::default())
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user