package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gtk/Ocgtk_gtk/Gtk/Wrappers/Gesture/index.html

Module Wrappers.Gesture

type t = [ `gesture | `event_controller | `object_ ] Gobject.obj
val ungroup : t -> unit

Separates @gesture into an isolated group.

val set_state : t -> Gtk_enums.eventsequencestate -> bool

Sets the state of all sequences that @gesture is currently interacting with.

Sequences start in state %GTK_EVENT_SEQUENCE_NONE, and whenever they change state, they can never go back to that state. Likewise, sequences in state %GTK_EVENT_SEQUENCE_DENIED cannot turn back to a not denied state. With these rules, the lifetime of an event sequence is constrained to the next four:

* None * None → Denied * None → Claimed * None → Claimed → Denied

Note: Due to event handling ordering, it may be unsafe to set the state on another gesture within a signal@Gtk.Gesture::begin signal handler, as the callback might be executed before the other gesture knows about the sequence. A safe way to perform this could be:

```c static void first_gesture_begin_cb (GtkGesture *first_gesture, GdkEventSequence *sequence, gpointer user_data) gtk_gesture_set_state (first_gesture, GTK_EVENT_SEQUENCE_CLAIMED); gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED);

static void second_gesture_begin_cb (GtkGesture *second_gesture, GdkEventSequence *sequence, gpointer user_data) if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED) gtk_gesture_set_state (second_gesture, GTK_EVENT_SEQUENCE_DENIED); ```

If both gestures are in the same group, just set the state on the gesture emitting the event, the sequence will be already be initialized to the group's global state when the second gesture processes the event.

Sets the state of @sequence in @gesture.

Sequences start in state %GTK_EVENT_SEQUENCE_NONE, and whenever they change state, they can never go back to that state. Likewise, sequences in state %GTK_EVENT_SEQUENCE_DENIED cannot turn back to a not denied state. With these rules, the lifetime of an event sequence is constrained to the next four:

* None * None → Denied * None → Claimed * None → Claimed → Denied

Note: Due to event handling ordering, it may be unsafe to set the state on another gesture within a signal@Gtk.Gesture::begin signal handler, as the callback might be executed before the other gesture knows about the sequence. A safe way to perform this could be:

```c static void first_gesture_begin_cb (GtkGesture *first_gesture, GdkEventSequence *sequence, gpointer user_data) gtk_gesture_set_sequence_state (first_gesture, sequence, GTK_EVENT_SEQUENCE_CLAIMED); gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED);

static void second_gesture_begin_cb (GtkGesture *second_gesture, GdkEventSequence *sequence, gpointer user_data) if (gtk_gesture_get_sequence_state (first_gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED) gtk_gesture_set_sequence_state (second_gesture, sequence, GTK_EVENT_SEQUENCE_DENIED); ```

If both gestures are in the same group, just set the state on the gesture emitting the event, the sequence will be already be initialized to the group's global state when the second gesture processes the event.

val is_recognized : t -> bool

Returns %TRUE if the gesture is currently recognized.

A gesture is recognized if there are as many interacting touch sequences as required by @gesture.

val is_grouped_with : t -> t -> bool

Returns %TRUE if both gestures pertain to the same group.

val is_active : t -> bool

Returns %TRUE if the gesture is currently active.

A gesture is active while there are touch sequences interacting with it.

val handles_sequence : t -> Ocgtk_gdk.Gdk.Wrappers.Event_sequence.t option -> bool

Returns %TRUE if @gesture is currently handling events corresponding to @sequence.

val group : t -> t -> unit

Adds @gesture to the same group than @group_gesture.

Gestures are by default isolated in their own groups.

Both gestures must have been added to the same widget before they can be grouped.

When gestures are grouped, the state of `GdkEventSequences` is kept in sync for all of those, so calling method@Gtk.Gesture.set_sequence_state, on one will transfer the same value to the others.

Groups also perform an "implicit grabbing" of sequences, if a `GdkEventSequence` state is set to %GTK_EVENT_SEQUENCE_CLAIMED on one group, every other gesture group attached to the same `GtkWidget` will switch the state for that sequence to %GTK_EVENT_SEQUENCE_DENIED.

val get_sequences : t -> Ocgtk_gdk.Gdk.Wrappers.Event_sequence.t list

Returns the list of `GdkEventSequences` currently being interpreted by @gesture.

Returns the @sequence state, as seen by @gesture.

val get_point : t -> Ocgtk_gdk.Gdk.Wrappers.Event_sequence.t option -> bool * float * float

If @sequence is currently being interpreted by @gesture, returns %TRUE and fills in @x and @y with the last coordinates stored for that event sequence.

The coordinates are always relative to the widget allocation.

val get_last_updated_sequence : t -> Ocgtk_gdk.Gdk.Wrappers.Event_sequence.t option

Returns the `GdkEventSequence` that was last updated on @gesture.

Returns the last event that was processed for @sequence.

Note that the returned pointer is only valid as long as the @sequence is still interpreted by the @gesture. If in doubt, you should make a copy of the event.

val get_group : t -> t list

Returns all gestures in the group of @gesture

val get_device : t -> Ocgtk_gdk.Gdk.Wrappers.Device.t option

Returns the logical `GdkDevice` that is currently operating on @gesture.

This returns %NULL if the gesture is not being interacted.

val get_bounding_box_center : t -> bool * float * float

If there are touch sequences being currently handled by @gesture, returns %TRUE and fills in @x and @y with the center of the bounding box containing all active touches.

Otherwise, %FALSE will be returned.

val get_bounding_box : t -> bool * Ocgtk_gdk.Gdk.Wrappers.Rectangle.t

If there are touch sequences being currently handled by @gesture, returns %TRUE and fills in @rect with the bounding box containing all active touches.

Otherwise, %FALSE will be returned.

Note: This function will yield unexpected results on touchpad gestures. Since there is no correlation between physical and pixel distances, these will look as if constrained in an infinitely small area, @rect width and height will thus be 0 regardless of the number of touchpoints.

val get_n_points : t -> int

Get property: n-points