1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use super::mouse::*;
///
/// The device that caused a painting event
///
#[derive(Clone, Copy, PartialEq, Hash, Serialize, Deserialize, Debug)]
pub enum PaintDevice {
/// Unknown paint device
Other,
/// Mouse with a particular button held down
Mouse(MouseButton),
/// Pen (with a particular stylus ID in case the user has multiple styluses)
Pen,
/// Eraser (with a particular stylus ID in case the user has multiple styluses)
Eraser,
/// Finger input on a touch display
Touch
}
///
/// Possible actions for a paint stroke
///
#[derive(Clone, Copy, PartialEq, Serialize, Deserialize, Debug)]
pub enum PaintAction {
/// Start of a paint stroke (mouse/stylus/touch down)
Start,
/// Continuation of a paint stroke previously started (drag)
Continue,
/// End of a paint stroke (mouse/stylus/touch up)
Finish,
/// Paint stroke was cancelled
Cancel
}
///
/// Data for a painting event
///
#[derive(Clone, Copy, PartialEq, Serialize, Deserialize, Debug)]
pub struct Painting {
/// Action for this painting event
pub action: PaintAction,
/// In the event the user has multiple pointers (eg, multiple styluses on a tablet), this is the ID of the stylus that the user is using
pub pointer_id: i32,
/// Coordinates relative to the control that was painted upon
pub location: (f32, f32),
/// Pressure of this event
pub pressure: f32,
/// X tilt (-90 to 90)
pub tilt_x: f32,
/// Y tilt (-90 to 90)
pub tilt_y: f32
}