Struct gtk::PadController[][src]

pub struct PadController(_);
Expand description

PadController is an event controller for the pads found in drawing tablets (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, this event controller is provided to map those to GAction objects, thus letting the application give those 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_device_pad_get_n_groups() and gdk_device_pad_get_group_n_modes().

Each of the actions that a given button/strip/ring performs for a given mode is defined by PadActionEntry, it contains an action name that will be looked up in the given gio::ActionGroup 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:

  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 (window, 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 glib::VariantType.

Implements

EventControllerExt, glib::ObjectExt

Implementations

This is supported on crate feature v3_22 only.

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 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().

window

a Window

group

gio::ActionGroup to trigger actions from

pad

A GDK_SOURCE_TABLET_PAD device, or None to handle all pads

Returns

A newly created PadController

This is supported on crate feature v3_22 only.

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.

This is supported on crate feature v3_22 only.

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 gio::ActionGroup

This is supported on crate feature v3_22 only.
This is supported on crate feature v3_22 only.

This is 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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

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

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Emit signal with details by signal id.

Emit signal by it’s name.

Same as emit but takes Value for the arguments.

Same as emit_by_name but takes Value for the arguments.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.