mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
Expose center position in MultiTouchInfo (#5247)
Expose the center / average position in MultiTouchInfo
This commit is contained in:
@@ -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,
|
||||
@@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user