Struct gtk4::PadController [−][src]
pub struct PadController(_);
Expand description
PadController
is an event controller for the pads found in drawing
tablets.
Pads are the collection of buttons and tactile sensors often found around the stylus-sensitive area.
These buttons and sensors have no implicit meaning, and by default they
perform no action. PadController
is provided to map those to
GAction
objects, thus letting the application give them a more
semantic meaning.
Buttons and sensors are not constrained to triggering a single action,
some GDK_SOURCE_TABLET_PAD
devices feature multiple “modes”. All these
input elements have one current mode, which may determine the final action
being triggered.
Pad devices often divide buttons and sensors into groups. All elements
in a group share the same current mode, but different groups may have
different modes. See Gdk::
DevicePad::get_n_groups() and `Gdk::`DevicePad::get_group_n_modes()
.
Each of the actions that a given button/strip/ring performs for a given
mode is defined by a PadActionEntry
. It contains an action
name that will be looked up in the given GActionGroup
and activated
whenever the specified input element and mode are triggered.
A simple example of PadController
usage: Assigning button 1 in all
modes and pad devices to an “invert-selection” action:
⚠️ The following code is in c ⚠️
GtkPadActionEntry *pad_actions[] = {
{ GTK_PAD_ACTION_BUTTON, 1, -1, "Invert selection", "pad-actions.invert-selection" },
…
};
…
action_group = g_simple_action_group_new ();
action = g_simple_action_new ("pad-actions.invert-selection", NULL);
g_signal_connect (action, "activate", on_invert_selection_activated, NULL);
g_action_map_add_action (G_ACTION_MAP (action_group), action);
…
pad_controller = gtk_pad_controller_new (action_group, NULL);
The actions belonging to rings/strips will be activated with a parameter
of type G_VARIANT_TYPE_DOUBLE
bearing the value of the given axis, it
is required that those are made stateful and accepting this GVariantType
.
Implements
Implementations
Creates a new PadController
that will associate events from pad
to
actions.
A None
pad may be provided so the controller manages all pad devices
generically, it is discouraged to mix PadController
objects with
None
and non-None
pad
argument on the same toplevel window, as execution
order is not guaranteed.
The PadController
is created with no mapped actions. In order to
map pad events to actions, use set_action_entries()
or set_action()
.
Be aware that pad events will only be delivered to Window
s, so adding
a pad controller to any other type of widget will not have an effect.
group
GActionGroup
to trigger actions from
pad
A GDK_SOURCE_TABLET_PAD
device, or None
to handle all pads
Returns
A newly created PadController
Creates a new builder-pattern struct instance to construct PadController
objects.
This method returns an instance of PadControllerBuilder
which can be used to create PadController
objects.
pub fn set_action(
&self,
type_: PadActionType,
index: i32,
mode: i32,
label: &str,
action_name: &str
)
pub fn set_action(
&self,
type_: PadActionType,
index: i32,
mode: i32,
label: &str,
action_name: &str
)
Adds an individual action to self
.
This action will only be activated if the given button/ring/strip number
in index
is interacted while the current mode is mode
. -1 may be used
for simple cases, so the action is triggered on all modes.
The given label
should be considered user-visible, so internationalization
rules apply. Some windowing systems may be able to use those for user
feedback.
type_
the type of pad feature that will trigger this action
index
the 0-indexed button/ring/strip number that will trigger this action
mode
the mode that will trigger this action, or -1 for all modes.
label
Human readable description of this action, this string should be deemed user-visible.
action_name
action name that will be activated in the GActionGroup
A convenience function to add a group of action entries on
self
.
See PadActionEntry
and set_action()
.
entries
the action entries to set on self
Trait Implementations
type Parent = EventController
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for PadController
impl !Send for PadController
impl !Sync for PadController
impl Unpin for PadController
impl UnwindSafe for PadController
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Same as emit
but takes Value
for the arguments.
Emit signal by its name.
Same as emit_by_name
but takes Value
for the arguments.
Emit signal with details by signal id.
Same as emit_with_details
but takes Value
for the arguments.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.