Serde feature: Add serde derives to input related structs (#4100)
We plan to store input data for creating automated tests, hence the need for more serde derives on input related structs. --------- Co-authored-by: Georg Weisert <georg.weisert@freshx.de>
This commit is contained in:
parent
5cf99c6308
commit
e8af6f38fc
|
|
@ -22,6 +22,7 @@ const MAX_DOUBLE_CLICK_DELAY: f64 = 0.3; // TODO(emilk): move to settings
|
|||
/// You can check if `egui` is using the inputs using
|
||||
/// [`crate::Context::wants_pointer_input`] and [`crate::Context::wants_keyboard_input`].
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct InputState {
|
||||
/// The raw input we got this frame from the backend.
|
||||
pub raw: RawInput,
|
||||
|
|
@ -546,6 +547,7 @@ impl InputState {
|
|||
|
||||
/// A pointer (mouse or touch) click.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct Click {
|
||||
pub pos: Pos2,
|
||||
|
||||
|
|
@ -567,6 +569,7 @@ impl Click {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) enum PointerEvent {
|
||||
Moved(Pos2),
|
||||
Pressed {
|
||||
|
|
@ -595,6 +598,7 @@ impl PointerEvent {
|
|||
|
||||
/// Mouse or touch state.
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct PointerState {
|
||||
/// Latest known time
|
||||
time: f64,
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ pub struct MultiTouchInfo {
|
|||
|
||||
/// The current state (for a specific touch device) of touch events and gestures.
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub(crate) struct TouchState {
|
||||
/// Technical identifier of the touch device. This is used to identify relevant touch events
|
||||
/// for this [`TouchState`] instance.
|
||||
|
|
@ -83,6 +84,7 @@ pub(crate) struct TouchState {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
struct GestureState {
|
||||
start_time: f64,
|
||||
start_pointer_pos: Pos2,
|
||||
|
|
@ -93,6 +95,7 @@ struct GestureState {
|
|||
|
||||
/// Gesture data that can change over time
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
struct DynGestureState {
|
||||
/// used for proportional zooming
|
||||
avg_distance: f32,
|
||||
|
|
@ -110,6 +113,7 @@ struct DynGestureState {
|
|||
/// Describes an individual touch (finger or digitizer) on the touch surface. Instances exist as
|
||||
/// long as the finger/pen touches the surface.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
struct ActiveTouch {
|
||||
/// Current position of this touch, in device coordinates (not necessarily screen position)
|
||||
pos: Pos2,
|
||||
|
|
@ -302,6 +306,7 @@ impl Debug for TouchState {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
enum PinchType {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use std::collections::VecDeque;
|
|||
/// or for smoothed velocity (e.g. mouse pointer speed).
|
||||
/// All times are in seconds.
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct History<T> {
|
||||
/// In elements, i.e. of `values.len()`.
|
||||
/// The length is initially zero, but once past `min_len` will not shrink below it.
|
||||
|
|
|
|||
Loading…
Reference in New Issue