1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

Add rotation gesture support for trackpad sources (#7453)

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Co-authored-by: Lucas Meurer <hi@lucasmerlin.me>
This commit is contained in:
Alan Everett
2025-09-11 06:44:17 -04:00
committed by GitHub
parent 802d307e4a
commit b0c568a78e
7 changed files with 174 additions and 22 deletions

View File

@@ -491,9 +491,7 @@ impl State {
// Things we completely ignore:
WindowEvent::ActivationTokenDone { .. }
| WindowEvent::AxisMotion { .. }
| WindowEvent::DoubleTapGesture { .. }
| WindowEvent::RotationGesture { .. }
| WindowEvent::PanGesture { .. } => EventResponse {
| WindowEvent::DoubleTapGesture { .. } => EventResponse {
repaint: false,
consumed: false,
},
@@ -508,6 +506,33 @@ impl State {
consumed: self.egui_ctx.wants_pointer_input(),
}
}
WindowEvent::RotationGesture { delta, .. } => {
// Positive delta values indicate counterclockwise rotation
// Negative delta values indicate clockwise rotation
// This is opposite of egui's sign convention for angles
self.egui_input
.events
.push(egui::Event::Rotate(-delta.to_radians()));
EventResponse {
repaint: true,
consumed: self.egui_ctx.wants_pointer_input(),
}
}
WindowEvent::PanGesture { delta, .. } => {
let pixels_per_point = pixels_per_point(&self.egui_ctx, window);
self.egui_input.events.push(egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Point,
delta: Vec2::new(delta.x, delta.y) / pixels_per_point,
modifiers: self.egui_input.modifiers,
});
EventResponse {
repaint: true,
consumed: self.egui_ctx.wants_pointer_input(),
}
}
}
}