Skip to content

Commit

Permalink
Upgrade egui to 0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
Swoorup committed Jul 4, 2024
1 parent cb34194 commit 78640f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ required-features = ["render"]

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_asset"] }
egui = { version = "0.27", default-features = false, features = ["bytemuck"] }
egui = { version = "0.28", default-features = false, features = ["bytemuck"] }
webbrowser = { version = "0.8.2", optional = true }

[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion examples/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl Default for Painting {
impl Painting {
pub fn ui_control(&mut self, ui: &mut egui::Ui) -> egui::Response {
ui.horizontal(|ui| {
egui::stroke_ui(ui, &mut self.stroke, "Stroke");
ui.add(&mut self.stroke);
ui.separator();
if ui.button("Clear Painting").clicked() {
self.lines.clear();
Expand Down
39 changes: 14 additions & 25 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,32 +211,21 @@ pub fn process_input_system(
continue;
};

let mut delta = egui::vec2(event.x, event.y);
if let MouseScrollUnit::Line = event.unit {
// https://github.com/emilk/egui/blob/a689b623a669d54ea85708a8c748eb07e23754b0/egui-winit/src/lib.rs#L449
delta *= 50.0;
}
let delta = egui::vec2(event.x, event.y);

if ctrl || mac_cmd {
// Treat as zoom instead.
let factor = (delta.y / 200.0).exp();
window_context
.egui_input
.events
.push(egui::Event::Zoom(factor));
} else if shift {
// Treat as horizontal scrolling.
// Note: Mac already fires horizontal scroll events when shift is down.
window_context
.egui_input
.events
.push(egui::Event::Scroll(egui::vec2(delta.x + delta.y, 0.0)));
} else {
window_context
.egui_input
.events
.push(egui::Event::Scroll(delta));
}
let unit = match event.unit {
MouseScrollUnit::Line => egui::MouseWheelUnit::Line,
MouseScrollUnit::Pixel => egui::MouseWheelUnit::Point,
};

window_context
.egui_input
.events
.push(egui::Event::MouseWheel {
unit,
delta,
modifiers,
});
}

if !command && !win || !*context_params.is_macos && ctrl && alt {
Expand Down

0 comments on commit 78640f8

Please sign in to comment.