gdk/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::{Device, DevicePadFeature, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// [`DevicePad`][crate::DevicePad] is an interface implemented by devices of type
10 /// [`InputSource::TabletPad`][crate::InputSource::TabletPad], it allows querying the features provided
11 /// 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 the
17 /// 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
20 /// each individual pad feature to multiple actions. Only one mode is
21 /// effective (current) for each given group, different groups may have
22 /// different current modes. The number of available modes in a group can
23 /// be found out through [`DevicePadExt::group_n_modes()`][crate::prelude::DevicePadExt::group_n_modes()], and the current
24 /// mode for a given group will be notified through the [`EventPadGroupMode`][crate::EventPadGroupMode]
25 /// event.
26 ///
27 /// # Implements
28 ///
29 /// [`DevicePadExt`][trait@crate::prelude::DevicePadExt], [`DeviceExt`][trait@crate::prelude::DeviceExt], [`DeviceExtManual`][trait@crate::prelude::DeviceExtManual]
30 #[doc(alias = "GdkDevicePad")]
31 pub struct DevicePad(Interface<ffi::GdkDevicePad, ffi::GdkDevicePadInterface>) @requires Device;
32
33 match fn {
34 type_ => || ffi::gdk_device_pad_get_type(),
35 }
36}
37
38impl DevicePad {
39 pub const NONE: Option<&'static DevicePad> = None;
40}
41
42/// Trait containing all [`struct@DevicePad`] methods.
43///
44/// # Implementors
45///
46/// [`DevicePad`][struct@crate::DevicePad]
47pub trait DevicePadExt: IsA<DevicePad> + 'static {
48 /// Returns the group the given `feature` and `idx` belong to,
49 /// or -1 if feature/index do not exist in `self`.
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. Pads have
99 /// at least one group. A pad group is a subcollection of
100 /// buttons/strip/rings that is affected collectively by a same
101 /// current mode.
102 ///
103 /// # Returns
104 ///
105 /// The number of button/ring/strip groups in the pad.
106 #[doc(alias = "gdk_device_pad_get_n_groups")]
107 #[doc(alias = "get_n_groups")]
108 fn n_groups(&self) -> i32 {
109 unsafe { ffi::gdk_device_pad_get_n_groups(self.as_ref().to_glib_none().0) }
110 }
111}
112
113impl<O: IsA<DevicePad>> DevicePadExt for O {}