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