gdk4/auto/
scroll_event.rs1#[cfg(feature = "v4_20")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
7use crate::ScrollRelativeDirection;
8#[cfg(feature = "v4_8")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
10use crate::ScrollUnit;
11use crate::{ffi, ScrollDirection};
12use glib::{prelude::*, translate::*};
13
14glib::wrapper! {
15 #[doc(alias = "GdkScrollEvent")]
17 pub struct ScrollEvent(Shared<ffi::GdkScrollEvent>);
18
19 match fn {
20 ref => |ptr| ffi::gdk_event_ref(ptr as *mut ffi::GdkEvent),
21 unref => |ptr| ffi::gdk_event_unref(ptr as *mut ffi::GdkEvent),
22 }
23}
24
25impl StaticType for ScrollEvent {
26 fn static_type() -> glib::Type {
27 unsafe { from_glib(ffi::gdk_scroll_event_get_type()) }
28 }
29}
30
31impl ScrollEvent {
32 #[doc(alias = "gdk_scroll_event_get_deltas")]
49 #[doc(alias = "get_deltas")]
50 pub fn deltas(&self) -> (f64, f64) {
51 unsafe {
52 let mut delta_x = std::mem::MaybeUninit::uninit();
53 let mut delta_y = std::mem::MaybeUninit::uninit();
54 ffi::gdk_scroll_event_get_deltas(
55 self.to_glib_none().0,
56 delta_x.as_mut_ptr(),
57 delta_y.as_mut_ptr(),
58 );
59 (delta_x.assume_init(), delta_y.assume_init())
60 }
61 }
62
63 #[doc(alias = "gdk_scroll_event_get_direction")]
69 #[doc(alias = "get_direction")]
70 pub fn direction(&self) -> ScrollDirection {
71 unsafe { from_glib(ffi::gdk_scroll_event_get_direction(self.to_glib_none().0)) }
72 }
73
74 #[cfg(feature = "v4_20")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
81 #[doc(alias = "gdk_scroll_event_get_relative_direction")]
82 #[doc(alias = "get_relative_direction")]
83 pub fn relative_direction(&self) -> ScrollRelativeDirection {
84 unsafe {
85 from_glib(ffi::gdk_scroll_event_get_relative_direction(
86 self.to_glib_none().0,
87 ))
88 }
89 }
90
91 #[cfg(feature = "v4_8")]
100 #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
101 #[doc(alias = "gdk_scroll_event_get_unit")]
102 #[doc(alias = "get_unit")]
103 pub fn unit(&self) -> ScrollUnit {
104 unsafe { from_glib(ffi::gdk_scroll_event_get_unit(self.to_glib_none().0)) }
105 }
106
107 #[doc(alias = "gdk_scroll_event_is_stop")]
121 pub fn is_stop(&self) -> bool {
122 unsafe { from_glib(ffi::gdk_scroll_event_is_stop(self.to_glib_none().0)) }
123 }
124}