Skip to main content

euv_ui/component/touch/hook/
struct.rs

1use crate::*;
2
3/// Represents a single touch point from a multi-touch event.
4///
5/// Each `NativeTouchPoint` corresponds to one finger or stylus currently
6/// touching the screen. The `identifier` field distinguishes between
7/// simultaneous touch points, enabling multi-finger gesture tracking.
8#[derive(Clone, Data, Debug, Default, Eq, PartialEq)]
9pub struct NativeTouchPoint {
10    /// A unique identifier for this touch point.
11    ///
12    /// The browser assigns a distinct `identifier` to each active touch.
13    /// It remains constant for the duration of the touch (from
14    /// `touchstart` to `touchend`), allowing the same finger to be
15    /// tracked across `touchmove` events.
16    #[get(type(copy))]
17    pub identifier: i32,
18    /// The X coordinate of the touch relative to the viewport.
19    #[get(type(copy))]
20    pub client_x: i32,
21    /// The Y coordinate of the touch relative to the viewport.
22    #[get(type(copy))]
23    pub client_y: i32,
24    /// The X coordinate of the touch relative to the screen.
25    #[get(type(copy))]
26    pub screen_x: i32,
27    /// The Y coordinate of the touch relative to the screen.
28    #[get(type(copy))]
29    pub screen_y: i32,
30    /// The X coordinate of the touch relative to the target element.
31    #[get(type(copy))]
32    pub offset_x: i32,
33    /// The Y coordinate of the touch relative to the target element.
34    #[get(type(copy))]
35    pub offset_y: i32,
36    /// The X coordinate of the touch relative to the page.
37    #[get(type(copy))]
38    pub page_x: i32,
39    /// The Y coordinate of the touch relative to the page.
40    #[get(type(copy))]
41    pub page_y: i32,
42}
43
44/// Represents a single touch point with high-precision `f64` coordinates.
45///
46/// Used for pixel-precise interactions such as canvas drawing, where
47/// sub-pixel accuracy matters. The `identifier` field distinguishes
48/// between simultaneous touch points, enabling multi-finger gesture
49/// tracking.
50#[derive(Clone, Data, Debug, Default, PartialEq)]
51pub struct NativeTouchPointF64 {
52    /// A unique identifier for this touch point.
53    #[get(type(copy))]
54    pub identifier: i32,
55    /// The X coordinate of the touch relative to the viewport.
56    #[get(type(copy))]
57    pub client_x: f64,
58    /// The Y coordinate of the touch relative to the viewport.
59    #[get(type(copy))]
60    pub client_y: f64,
61    /// The X coordinate of the touch relative to the screen.
62    #[get(type(copy))]
63    pub screen_x: f64,
64    /// The Y coordinate of the touch relative to the screen.
65    #[get(type(copy))]
66    pub screen_y: f64,
67    /// The X coordinate of the touch relative to the target element.
68    #[get(type(copy))]
69    pub offset_x: f64,
70    /// The Y coordinate of the touch relative to the target element.
71    #[get(type(copy))]
72    pub offset_y: f64,
73    /// The X coordinate of the touch relative to the page.
74    #[get(type(copy))]
75    pub page_x: f64,
76    /// The Y coordinate of the touch relative to the page.
77    #[get(type(copy))]
78    pub page_y: f64,
79}