nuit_core/event/gesture/
drag.rs1use serde::{Deserialize, Serialize};
2
3use crate::Vec2;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct DragEvent {
9 kind: DragEventKind,
10 start_location: Vec2<f64>,
11 location: Vec2<f64>,
12}
13
14impl DragEvent {
15 pub fn kind(&self) -> DragEventKind {
17 self.kind
18 }
19
20 pub fn start_location(&self) -> Vec2<f64> {
22 self.start_location
23 }
24
25 pub fn location(&self) -> Vec2<f64> {
27 self.location
28 }
29
30 pub fn translation(&self) -> Vec2<f64> {
32 self.location - self.start_location
33 }
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub enum DragEventKind {
39 Updated,
40 Ended,
41}