libadwaita/auto/
swipeable.rs1use crate::{ffi, NavigationDirection};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 #[doc(alias = "AdwSwipeable")]
11 pub struct Swipeable(Interface<ffi::AdwSwipeable, ffi::AdwSwipeableInterface>) @requires gtk::Widget, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
12
13 match fn {
14 type_ => || ffi::adw_swipeable_get_type(),
15 }
16}
17
18impl Swipeable {
19 pub const NONE: Option<&'static Swipeable> = None;
20}
21
22pub trait SwipeableExt: IsA<Swipeable> + 'static {
23 #[doc(alias = "adw_swipeable_get_cancel_progress")]
24 #[doc(alias = "get_cancel_progress")]
25 fn cancel_progress(&self) -> f64 {
26 unsafe { ffi::adw_swipeable_get_cancel_progress(self.as_ref().to_glib_none().0) }
27 }
28
29 #[doc(alias = "adw_swipeable_get_distance")]
30 #[doc(alias = "get_distance")]
31 fn distance(&self) -> f64 {
32 unsafe { ffi::adw_swipeable_get_distance(self.as_ref().to_glib_none().0) }
33 }
34
35 #[doc(alias = "adw_swipeable_get_progress")]
36 #[doc(alias = "get_progress")]
37 fn progress(&self) -> f64 {
38 unsafe { ffi::adw_swipeable_get_progress(self.as_ref().to_glib_none().0) }
39 }
40
41 #[doc(alias = "adw_swipeable_get_snap_points")]
42 #[doc(alias = "get_snap_points")]
43 fn snap_points(&self) -> Vec<f64> {
44 unsafe {
45 let mut n_snap_points = std::mem::MaybeUninit::uninit();
46 let ret = FromGlibContainer::from_glib_full_num(
47 ffi::adw_swipeable_get_snap_points(
48 self.as_ref().to_glib_none().0,
49 n_snap_points.as_mut_ptr(),
50 ),
51 n_snap_points.assume_init() as _,
52 );
53 ret
54 }
55 }
56
57 #[doc(alias = "adw_swipeable_get_swipe_area")]
58 #[doc(alias = "get_swipe_area")]
59 fn swipe_area(
60 &self,
61 navigation_direction: NavigationDirection,
62 is_drag: bool,
63 ) -> gdk::Rectangle {
64 unsafe {
65 let mut rect = gdk::Rectangle::uninitialized();
66 ffi::adw_swipeable_get_swipe_area(
67 self.as_ref().to_glib_none().0,
68 navigation_direction.into_glib(),
69 is_drag.into_glib(),
70 rect.to_glib_none_mut().0,
71 );
72 rect
73 }
74 }
75}
76
77impl<O: IsA<Swipeable>> SwipeableExt for O {}