Skip to content

Commit

Permalink
chore: upgrade egui and fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianBDev committed Aug 19, 2024
1 parent 37e2dc9 commit 941afec
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ generated_is.json
gui.bin

Cargo.lock

build.sh
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ description = "Draw graphs with egui."
license = "MIT OR Apache-2.0"

[dependencies]
egui = "0.23"
eframe = { version = "0.23", default-features = false, features = [
egui = "0.28"
eframe = { version = "0.28", default-features = false, features = [
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
"persistence", # Enable restoring app state when restarting the app.
] }

# You only need serde if you want app persistence:
serde = { version = "1", features = ["derive"] }
layout-rs = "0.1.1"
petgraph = { version = "0.6.3", features = ["serde-1"] }
rand = "0.8.5"
tracing = "0.1.37"
layout-rs = "0.1"
petgraph = { version = "0.6", features = ["serde-1"] }
rand = "0.8"
tracing = "0.1"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2024 NEVERHACK
Copyright (c) 2024 SILICOM/NEVERHACK

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
6 changes: 3 additions & 3 deletions examples/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
egui = "0.23"
eframe = { version = "0.23", default-features = false, features = [
egui = "0.28"
eframe = { version = "0.28", default-features = false, features = [
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
"persistence", # Enable restoring app state when restarting the app.
] }
petgraph = { version = "0.6.3", features = ["serde-1"] }
petgraph = { version = "0.6", features = ["serde-1"] }
egui-gdl = { path = "../.." }
2 changes: 1 addition & 1 deletion examples/hello-world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn main() {
options,
Box::new(|_| {
// This gives us image support:
Box::<MyApp>::default()
Ok(Box::<MyApp>::default())
}),
)
.unwrap();
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl<S, N, E, Ty: EdgeType, Ix: IndexType + Debug> Graph<S, N, E, Ty, Ix> {

// Handle zoom
if let Some(pos) = ui.ctx().pointer_latest_pos() {
let zoom = ui.input(|i| i.scroll_delta.y);
let zoom = ui.input(|i| i.raw_scroll_delta.y);
if zoom != 0. && transform.draw_rect.contains(pos) {
transform.user_modified = true;
let zoom = (zoom * ZOOM_STEP).exp();
Expand Down Expand Up @@ -431,7 +431,7 @@ impl<S, N, E, Ty: EdgeType, Ix: IndexType + Debug> Graph<S, N, E, Ty, Ix> {
);

// Here we draw the edge content (can be any widget)
let mut child_ui = ui.child_ui(rect, Layout::top_down(egui::Align::Center));
let mut child_ui = ui.child_ui(rect, Layout::top_down(egui::Align::Center), None);

// Regarding show edge value (which closure parameter to provide), call underlying closure
Self::show_transformed(&mut child_ui, transform, &self.inner.config, |ui| {
Expand Down Expand Up @@ -515,7 +515,7 @@ impl<S, N, E, Ty: EdgeType, Ix: IndexType + Debug> Graph<S, N, E, Ty, Ix> {
};

// Here we draw the node content (can be any widget)
let mut child_ui = ui.child_ui(rect, Layout::top_down(egui::Align::Center));
let mut child_ui = ui.child_ui(rect, Layout::top_down(egui::Align::Center), None);

// Regarding show node value (which closure parameter to provide), call underlying closure
Self::show_transformed(&mut child_ui, transform, &self.inner.config, |ui| {
Expand Down Expand Up @@ -631,10 +631,10 @@ impl<S, N, E, Ty: EdgeType, Ix: IndexType + Debug> Graph<S, N, E, Ty, Ix> {
ui.style_mut().spacing.icon_spacing *= transform.zoom_factor;
ui.style_mut().spacing.tooltip_width *= transform.zoom_factor;
ui.style_mut().spacing.combo_height *= transform.zoom_factor;
ui.style_mut().spacing.scroll_bar_width *= transform.zoom_factor;
ui.style_mut().spacing.scroll_handle_min_length *= transform.zoom_factor;
ui.style_mut().spacing.scroll_bar_inner_margin *= transform.zoom_factor;
ui.style_mut().spacing.scroll_bar_outer_margin *= transform.zoom_factor;
ui.style_mut().spacing.scroll.bar_width *= transform.zoom_factor;
ui.style_mut().spacing.scroll.handle_min_length *= transform.zoom_factor;
ui.style_mut().spacing.scroll.bar_inner_margin *= transform.zoom_factor;
ui.style_mut().spacing.scroll.bar_outer_margin *= transform.zoom_factor;

// Here we call the closure
(show)(ui);
Expand Down
2 changes: 1 addition & 1 deletion src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl TransformState {
self.update(new_position_offset, new_zoom);
}

/// Update the screen with position offset and zoom factor
/// Update the screen with position offset and zoom factor.
pub fn update(&mut self, position_offset: Vec2, zoom_factor: f32) {
self.position_offset = position_offset;
self.zoom_factor = zoom_factor;
Expand Down

0 comments on commit 941afec

Please sign in to comment.