From 41abce845fc05c45323d78f3cbe1fb55408d88ba Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Fri, 21 Jul 2023 14:27:12 +0200 Subject: [PATCH 1/2] Expose center position in MultiTouchInfo --- crates/egui/src/input_state/touch_state.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index df39d961925..cc964a2d928 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -60,6 +60,9 @@ pub struct MultiTouchInfo { /// Note 2: Just increasing the physical pressure without actually moving the finger may not /// necessarily lead to a change of this value. pub force: f32, + + /// Center position of the current gesture (average of all touch points). + pub center_pos: Pos2, } /// The current state (for a specific touch device) of touch events and gestures. @@ -203,6 +206,8 @@ impl TouchState { PinchType::Proportional => Vec2::splat(zoom_delta), }; + let center_pos = state.current.avg_pos; + MultiTouchInfo { start_time: state.start_time, start_pos: state.start_pointer_pos, @@ -212,6 +217,7 @@ impl TouchState { rotation_delta: normalized_angle(state.current.heading - state_previous.heading), translation_delta: state.current.avg_pos - state_previous.avg_pos, force: state.current.avg_force, + center_pos, } }) } From 08187a176d722398d5ef98c48419d9ef23a68f39 Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Sat, 12 Oct 2024 15:34:44 +0200 Subject: [PATCH 2/2] Move below start_pos --- crates/egui/src/input_state/touch_state.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index cc964a2d928..1ff2dc388a3 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -15,6 +15,9 @@ pub struct MultiTouchInfo { /// Position of the pointer at the time the gesture started. pub start_pos: Pos2, + /// Center position of the current gesture (average of all touch points). + pub center_pos: Pos2, + /// Number of touches (fingers) on the surface. Value is ≥ 2 since for a single touch no /// [`MultiTouchInfo`] is created. pub num_touches: usize, @@ -60,9 +63,6 @@ pub struct MultiTouchInfo { /// Note 2: Just increasing the physical pressure without actually moving the finger may not /// necessarily lead to a change of this value. pub force: f32, - - /// Center position of the current gesture (average of all touch points). - pub center_pos: Pos2, } /// The current state (for a specific touch device) of touch events and gestures.