Skip to content

Commit

Permalink
Fix egui integration after event positions are defined in physical pi…
Browse files Browse the repository at this point in the history
…xels
  • Loading branch information
asny committed Feb 26, 2024
1 parent c12de08 commit 9595a89
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/gui/egui_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ impl GUI {
if !handled {
Some(egui::Event::PointerButton {
pos: egui::Pos2 {
x: position.x,
y: position.y,
x: position.x / device_pixel_ratio as f32,
y: (viewport.height as f32 - position.y)
/ device_pixel_ratio as f32,
},
button: button.into(),
pressed: true,
Expand All @@ -143,8 +144,9 @@ impl GUI {
if !handled {
Some(egui::Event::PointerButton {
pos: egui::Pos2 {
x: position.x,
y: position.y,
x: position.x / device_pixel_ratio as f32,
y: (viewport.height as f32 - position.y)
/ device_pixel_ratio as f32,
},
button: button.into(),
pressed: false,
Expand All @@ -159,8 +161,9 @@ impl GUI {
} => {
if !handled {
Some(egui::Event::PointerMoved(egui::Pos2 {
x: position.x,
y: position.y,
x: position.x / device_pixel_ratio as f32,
y: (viewport.height as f32 - position.y)
/ device_pixel_ratio as f32,
}))
} else {
None
Expand Down

0 comments on commit 9595a89

Please sign in to comment.