Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to [email protected] #71

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 0.14.1 - 2024-07-07
* Update `egui` to `0.28.0`
* Update `miniquad` to `0.4.0`

# 0.14.0 - 2023-02-08
* Update egui to `0.21.0`.
* Fix scroll speed (it was way too fast).
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "egui-miniquad"
version = "0.14.0"
version = "0.14.1"
authors = [
"Logachev Fedor <[email protected]>",
"Emil Ernerfeldt <[email protected]>",
Expand All @@ -18,7 +18,7 @@ include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]

[dependencies]
bytemuck = "1.9"
egui = { version = "0.27", features = ["bytemuck"] }
egui = { version = "0.28", features = ["bytemuck"] }
miniquad = { version = "=0.4.0" }
quad-url = "0.1"

Expand All @@ -31,7 +31,7 @@ quad-rand = "0.2.1"
copypasta = "0.8.1"

[dev-dependencies]
egui_demo_lib = { version = "0.27", default-features = false }
egui_demo_lib = { version = "0.28", default-features = false }
glam = "0.22.0"

[profile.release]
Expand Down
13 changes: 6 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,13 @@ impl EguiMq {
/// Call from your [`miniquad::EventHandler`].
pub fn mouse_wheel_event(&mut self, dx: f32, dy: f32) {
let delta = egui::vec2(dx, dy);
let modifiers = self.egui_input.modifiers;

let event = if self.egui_input.modifiers.ctrl {
// Treat as zoom instead:
egui::Event::Zoom((delta.y / 200.0).exp())
} else {
egui::Event::Scroll(delta)
};
self.egui_input.events.push(event);
self.egui_input.events.push(egui::Event::MouseWheel {
modifiers,
unit: egui::MouseWheelUnit::Line,
Copy link
Collaborator

@emilk emilk Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the unit miniquad uses, always? Sadly it is not documented: https://docs.rs/miniquad/latest/src/miniquad/event.rs.html#170

Maybe @not-fl3 knows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also noticed that it's not documented there.

I ended up doing some testing and adding dbg!(delta) inside the event handler, which ended up printing multiples of one every time I scrolled: [1.0, 0.0], [-1.0, 0.0], [0.0, 1.0] (every single event was +- 1.0). I tested using both my mouse and trackpad, and got a consistent [1.0, 0.0] for every 'click' of the scroll wheel, so I'm, fairly confident it's in lines.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't :|
On most platforms its just a raw data from an OS message, on some its fixed 1.0/-1.0.
We do not normalize it in any way.

delta,
});
}

/// Call from your [`miniquad::EventHandler`].
Expand Down
Loading