Skip to main content

gdk/
event_touchpad_pinch.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ffi;
4use glib::translate::*;
5
6/// Generated during touchpad swipe gestures.
7#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct EventTouchpadPinch(crate::Event);
9
10event_wrapper!(EventTouchpadPinch, GdkEventTouchpadPinch);
11event_subtype!(EventTouchpadPinch, ffi::GDK_TOUCHPAD_PINCH);
12
13impl EventTouchpadPinch {
14    pub fn is_phase(&self) -> bool {
15        unsafe { from_glib(self.as_ref().phase as _) }
16    }
17
18    #[doc(alias = "get_n_fingers")]
19    pub fn n_fingers(&self) -> i8 {
20        self.as_ref().n_fingers
21    }
22
23    #[doc(alias = "get_time")]
24    pub fn time(&self) -> u32 {
25        self.as_ref().time
26    }
27
28    #[doc(alias = "get_position")]
29    pub fn position(&self) -> (f64, f64) {
30        let x = self.as_ref().x;
31        let y = self.as_ref().y;
32        (x, y)
33    }
34
35    #[doc(alias = "get_delta")]
36    pub fn delta(&self) -> (f64, f64) {
37        let dx = self.as_ref().dx;
38        let dy = self.as_ref().dy;
39        (dx, dy)
40    }
41
42    #[doc(alias = "get_angle_delta")]
43    pub fn angle_delta(&self) -> f64 {
44        self.as_ref().angle_delta
45    }
46
47    #[doc(alias = "get_scale")]
48    pub fn scale(&self) -> f64 {
49        self.as_ref().scale
50    }
51
52    #[doc(alias = "get_root")]
53    pub fn root(&self) -> (f64, f64) {
54        let x_root = self.as_ref().x_root;
55        let y_root = self.as_ref().y_root;
56        (x_root, y_root)
57    }
58
59    #[doc(alias = "get_state")]
60    pub fn state(&self) -> crate::ModifierType {
61        unsafe { from_glib(self.as_ref().state) }
62    }
63}