gdk4/auto/device_pad.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Device, DevicePadFeature};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// An interface for tablet pad devices.
10 ///
11 /// It allows querying the features provided by the pad device.
12 ///
13 /// Tablet pads may contain one or more groups, each containing a subset
14 /// of the buttons/rings/strips available. [`DevicePadExt::n_groups()`][crate::prelude::DevicePadExt::n_groups()]
15 /// can be used to obtain the number of groups, [`DevicePadExt::n_features()`][crate::prelude::DevicePadExt::n_features()]
16 /// and [`DevicePadExt::feature_group()`][crate::prelude::DevicePadExt::feature_group()] can be combined to find out
17 /// the number of buttons/rings/strips the device has, and how are they grouped.
18 ///
19 /// Each of those groups have different modes, which may be used to map each
20 /// individual pad feature to multiple actions. Only one mode is effective
21 /// (current) for each given group, different groups may have different
22 /// current modes. The number of available modes in a group can be found
23 /// out through [`DevicePadExt::group_n_modes()`][crate::prelude::DevicePadExt::group_n_modes()], and the current mode
24 /// for a given group will be notified through events of type `GDK_PAD_GROUP_MODE`.
25 ///
26 /// # Implements
27 ///
28 /// [`DevicePadExt`][trait@crate::prelude::DevicePadExt], [`DeviceExt`][trait@crate::prelude::DeviceExt]
29 #[doc(alias = "GdkDevicePad")]
30 pub struct DevicePad(Interface<ffi::GdkDevicePad, ffi::GdkDevicePadInterface>) @requires Device;
31
32 match fn {
33 type_ => || ffi::gdk_device_pad_get_type(),
34 }
35}
36
37impl DevicePad {
38 pub const NONE: Option<&'static DevicePad> = None;
39}
40
41/// Trait containing all [`struct@DevicePad`] methods.
42///
43/// # Implementors
44///
45/// [`DevicePad`][struct@crate::DevicePad]
46pub trait DevicePadExt: IsA<DevicePad> + 'static {
47 /// Returns the group the given @feature and @idx belong to.
48 ///
49 /// f the feature or index do not exist in @self, -1 is returned.
50 /// ## `feature`
51 /// the feature type to get the group from
52 /// ## `feature_idx`
53 /// the index of the feature to get the group from
54 ///
55 /// # Returns
56 ///
57 /// The group number of the queried pad feature.
58 #[doc(alias = "gdk_device_pad_get_feature_group")]
59 #[doc(alias = "get_feature_group")]
60 fn feature_group(&self, feature: DevicePadFeature, feature_idx: i32) -> i32 {
61 unsafe {
62 ffi::gdk_device_pad_get_feature_group(
63 self.as_ref().to_glib_none().0,
64 feature.into_glib(),
65 feature_idx,
66 )
67 }
68 }
69
70 /// Returns the number of modes that @group may have.
71 /// ## `group_idx`
72 /// group to get the number of available modes from
73 ///
74 /// # Returns
75 ///
76 /// The number of modes available in @group.
77 #[doc(alias = "gdk_device_pad_get_group_n_modes")]
78 #[doc(alias = "get_group_n_modes")]
79 fn group_n_modes(&self, group_idx: i32) -> i32 {
80 unsafe { ffi::gdk_device_pad_get_group_n_modes(self.as_ref().to_glib_none().0, group_idx) }
81 }
82
83 /// Returns the number of features a tablet pad has.
84 /// ## `feature`
85 /// a pad feature
86 ///
87 /// # Returns
88 ///
89 /// The amount of elements of type @feature that this pad has.
90 #[doc(alias = "gdk_device_pad_get_n_features")]
91 #[doc(alias = "get_n_features")]
92 fn n_features(&self, feature: DevicePadFeature) -> i32 {
93 unsafe {
94 ffi::gdk_device_pad_get_n_features(self.as_ref().to_glib_none().0, feature.into_glib())
95 }
96 }
97
98 /// Returns the number of groups this pad device has.
99 ///
100 /// Pads have at least one group. A pad group is a subcollection of
101 /// buttons/strip/rings that is affected collectively by a same
102 /// current mode.
103 ///
104 /// # Returns
105 ///
106 /// The number of button/ring/strip groups in the pad.
107 #[doc(alias = "gdk_device_pad_get_n_groups")]
108 #[doc(alias = "get_n_groups")]
109 fn n_groups(&self) -> i32 {
110 unsafe { ffi::gdk_device_pad_get_n_groups(self.as_ref().to_glib_none().0) }
111 }
112}
113
114impl<O: IsA<DevicePad>> DevicePadExt for O {}