Skip to main content

libadwaita/auto/
swipeable.rs

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