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

Expose center position in MultiTouchInfo #5247

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions crates/egui/src/input_state/touch_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
lucasmerlin marked this conversation as resolved.
Show resolved Hide resolved
}

/// The current state (for a specific touch device) of touch events and gestures.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}
})
}
Expand Down
Loading