2 * @defgroup Elm_Gesture_Layer Gesture Layer
3 * @ingroup elm_infra_group
5 * @brief This provides basic gesture detection.
7 * @image html gesture_layer_inheritance_tree.png
8 * @image latex gesture_layer_inheritance_tree.eps
10 * Gesture Layer Usage:
12 * Use Gesture Layer to detect gestures.
13 * The advantage is that you don't have to implement
14 * gesture detection, just set callbacks of the gesture state.
15 * By using the gesture layer we make a standard interface.
17 * In order to use Gesture Layer you start with @ref elm_gesture_layer_add
18 * and a parent object parameter.
19 * Next 'activate' the gesture layer with a call to @ref elm_gesture_layer_attach
20 * Usually with the same object as target (2nd parameter).
22 * Now you need to tell the gesture layer what gestures you follow.
23 * This is done with @ref elm_gesture_layer_cb_set call.
24 * By setting the callback you are actually telling the gesture layer:
25 * I would like to know when the gesture @ref Elm_Gesture_Type
26 * switches to the state @ref Elm_Gesture_State.
28 * Next, you need to implement the actual action that follows the input
31 * Note that if you like to stop being reported about a gesture, just set
32 * all callbacks referring to this gesture to @c NULL.
33 * (again with @ref elm_gesture_layer_cb_set)
35 * The information reported by the gesture layer to your callback is depending
36 * on @ref Elm_Gesture_Type :
37 * @ref Elm_Gesture_Taps_Info is the info reported for tap gestures:
38 * @ref ELM_GESTURE_N_TAPS, @ref ELM_GESTURE_N_LONG_TAPS,
39 * @ref ELM_GESTURE_N_DOUBLE_TAPS, @ref ELM_GESTURE_N_TRIPLE_TAPS.
41 * @ref Elm_Gesture_Momentum_Info is the info reported for momentum gestures:
42 * @ref ELM_GESTURE_MOMENTUM.
44 * @ref Elm_Gesture_Line_Info is the info reported for line gestures:
45 * (this also contains the @ref Elm_Gesture_Momentum_Info internal structure)
46 * @ref ELM_GESTURE_N_LINES, @ref ELM_GESTURE_N_FLICKS.
47 * Note that we consider a flick as a line-gesture that should be completed
48 * in a flick-time-limit as defined in @ref Config.
50 * @ref Elm_Gesture_Zoom_Info is the info reported for the @ref ELM_GESTURE_ZOOM gesture.
52 * @ref Elm_Gesture_Rotate_Info is the info reported for the @ref ELM_GESTURE_ROTATE gesture.
55 * Gesture Layer Tweaks:
57 * Note that line, flick, gestures can start without the need to remove fingers from the surface.
58 * When the user's fingers rest on the same-spot, the gesture ends and starts again when the fingers are moved.
60 * Setting glayer_continues_enable to @c false in @ref Config changes this behavior,
61 * so the gesture starts when the user touches (a *DOWN event) touch-surface
62 * and ends when no fingers touch the surface (a *UP event).
64 * Supported common elm_object APIs.
65 * @li @ref elm_object_disabled_set
66 * @li @ref elm_object_disabled_get
73 * @enum _Elm_Gesture_Type
74 * @brief Enumeration of supported gesture types.
76 enum _Elm_Gesture_Type
78 ELM_GESTURE_FIRST = 0,
80 ELM_GESTURE_N_TAPS, /**< N fingers single taps */
81 ELM_GESTURE_N_LONG_TAPS, /**< N fingers single long-taps */
82 ELM_GESTURE_N_DOUBLE_TAPS, /**< N fingers double-single taps */
83 ELM_GESTURE_N_TRIPLE_TAPS, /**< N fingers triple-single taps */
85 ELM_GESTURE_MOMENTUM, /**< Reports momentum in the direction of movement */
87 ELM_GESTURE_N_LINES, /**< N fingers line gesture */
88 ELM_GESTURE_N_FLICKS, /**< N fingers flick gesture */
90 ELM_GESTURE_ZOOM, /**< Zoom */
91 ELM_GESTURE_ROTATE, /**< Rotate */
97 * @typedef Elm_Gesture_Type
98 * @brief This is a convenient macro around #_Elm_Gesture_Type.
100 typedef enum _Elm_Gesture_Type Elm_Gesture_Type;
103 * @enum _Elm_Gesture_State
104 * @brief Enumeration of gesture states.
106 enum _Elm_Gesture_State
108 ELM_GESTURE_STATE_UNDEFINED = -1, /**< Gesture not STARTed */
109 ELM_GESTURE_STATE_START, /**< Gesture STARTed */
110 ELM_GESTURE_STATE_MOVE, /**< Gesture is ongoing */
111 ELM_GESTURE_STATE_END, /**< Gesture has completed */
112 ELM_GESTURE_STATE_ABORT /**< Ongoing gesture has been ABORTed */
116 * @typedef Elm_Gesture_State
117 * @brief This is a convenient macro around #_Elm_Gesture_State
119 typedef enum _Elm_Gesture_State Elm_Gesture_State;
122 * @struct _Elm_Gesture_Taps_Info
123 * @brief The structure type that holds taps info for the user.
125 struct _Elm_Gesture_Taps_Info
127 Evas_Coord x, y; /**< Holds center point between fingers */
128 unsigned int n; /**< Number of fingers tapped */
129 unsigned int timestamp; /**< Event timestamp */
133 * @typedef Elm_Gesture_Taps_Info
134 * @brief The structure type that holds taps info for the user.
136 typedef struct _Elm_Gesture_Taps_Info Elm_Gesture_Taps_Info;
139 * @struct _Elm_Gesture_Momentum_Info
140 * @brief The structure type that holds momentum info for the user.
141 * x1 and y1 are not necessarily in sync
142 * x1 holds the x value of the x direction starting point
143 * and same holds for y1.
144 * This is noticeable when doing V-shape movement.
146 struct _Elm_Gesture_Momentum_Info /* Report line ends, timestamps, and momentum computed */
147 {Evas_Coord x1; /**< Final-swipe direction with starting point on X */
148 Evas_Coord y1; /**< Final-swipe direction with starting point on Y */
149 Evas_Coord x2; /**< Final-swipe direction with ending point on X */
150 Evas_Coord y2; /**< Final-swipe direction with ending point on Y */
152 unsigned int tx; /**< Timestamp of the start of the final x-swipe */
153 unsigned int ty; /**< Timestamp of the start of the final y-swipe */
155 Evas_Coord mx; /**< Momentum on X */
156 Evas_Coord my; /**< Momentum on Y */
158 unsigned int n; /**< Number of fingers */
162 * @typedef Elm_Gesture_Momentum_Info
163 * @brief The structure type that holds momentum info for the user.
165 typedef struct _Elm_Gesture_Momentum_Info Elm_Gesture_Momentum_Info;
168 * @struct _Elm_Gesture_Line_Info
169 * @brief The structure type that holds line info for the user.
171 struct _Elm_Gesture_Line_Info /* Report line ends, timestamps, and momentum computed */
172 {Elm_Gesture_Momentum_Info momentum; /**< Line momentum info */
173 double angle; /**< Angle (direction) of the lines */
177 * @typedef Elm_Gesture_Line_Info
178 * @brief The structure type that holds line info for the user.
180 typedef struct _Elm_Gesture_Line_Info Elm_Gesture_Line_Info;
183 * @struct _Elm_Gesture_Zoom_Info
184 * @brief The structure type that holds zoom info for the user.
186 struct _Elm_Gesture_Zoom_Info
188 Evas_Coord x, y; /**< Holds zoom center point reported to the user */
189 Evas_Coord radius; /**< Holds radius between fingers reported to the user */
190 double zoom; /**< Zoom value: @c 1.0 means no zoom */
191 double momentum; /**< Zoom momentum: zoom growth per second (NOT YET SUPPORTED) */
195 * @typedef Elm_Gesture_Zoom_Info
196 * @brief The structure type that holds zoom info for the user.
198 typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;
201 * @struct _Elm_Gesture_Rotate_Info
202 * @brief The structure type that holds rotation info for the user.
204 struct _Elm_Gesture_Rotate_Info
206 Evas_Coord x, y; /**< Holds zoom center point reported to the user */
207 Evas_Coord radius; /**< Holds radius between fingers reported to the user */
208 double base_angle; /**< Holds start-angle */
209 double angle; /**< Rotation value: @c 0.0 means no rotation */
210 double momentum; /**< Rotation momentum: rotation done per second (NOT YET SUPPORTED) */
214 * @typedef Elm_Gesture_Rotate_Info
215 * @brief The structure type that holds rotation info for the user.
217 typedef struct _Elm_Gesture_Rotate_Info Elm_Gesture_Rotate_Info;
220 * @typedef Elm_Gesture_Event_Cb
221 * @brief User callback used to stream gesture info from the gesture layer.
223 * @remarks You should probably return EVAS_EVENT_FLAG_ON_HOLD if your widget acted
224 * upon the event, in an irreversible way.
226 * @param data The user data
227 * @param event_info The gesture report info
228 * @return The flag field to be applied on the causing event
231 typedef Evas_Event_Flags (*Elm_Gesture_Event_Cb)(void *data, void *event_info);
234 * @brief Sets callbacks to be notified about the
235 * change of state of a gesture.
237 * @if MOBILE @since_tizen 2.3
238 * @elseif WEARABLE @since_tizen 2.3.1
241 * @remarks When a user registers a callback with this function
242 * it means this gesture has to be tested.
244 * @remarks When ALL callbacks for a gesture are set to @c NULL
245 * it means the user isn't interested in gesture-state
246 * and it is not tested.
248 * @param[in] obj The gesture-layer
249 * @param[in] idx The gesture whose state is tracked
250 * @param[in] cb The callback function pointer
251 * @param[in] cb_type The event type this callback tracks: START, MOVE, END, ABORT
252 * @param[in] data The user info to be sent to the callback (usually, Smart Data)
255 EAPI void elm_gesture_layer_cb_set(Evas_Object *obj, Elm_Gesture_Type idx, Elm_Gesture_State cb_type, Elm_Gesture_Event_Cb cb, void *data);
258 * @brief Called to get repeat-events settings.
260 * @if MOBILE @since_tizen 2.3
261 * @elseif WEARABLE @since_tizen 2.3.1
264 * @param[in] obj The gesture-layer
266 * @return The repeat events settings
267 * @see elm_gesture_layer_hold_events_set()
269 EAPI Eina_Bool elm_gesture_layer_hold_events_get(const Evas_Object *obj);
272 * @brief Makes gesture-layer repeat events.
274 * @if MOBILE @since_tizen 2.3
275 * @elseif WEARABLE @since_tizen 2.3.1
278 * @remarks Set this if you like to get the raw events only if gestures were not
280 * @remarks Clear this if you like the gesture layer to forward events as testing gestures.
282 * @param[in] obj The gesture layer
283 * @param[in] hold_events The boolean value that indicates whether events are held
286 EAPI void elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool hold_events);
289 * @brief Sets the step-value for zoom action.
291 * @if MOBILE @since_tizen 2.3
292 * @elseif WEARABLE @since_tizen 2.3.1
295 * @remarks Set the step to any positive value.
296 * @remarks Cancel step setting by setting it to @c 0.
298 * @param[in] obj The gesture-layer
299 * @param[in] step The new zoom step value
301 * @see elm_gesture_layer_zoom_step_get()
303 EAPI void elm_gesture_layer_zoom_step_set(Evas_Object *obj, double step);
306 * @brief Gets the step-value for zoom action.
308 * @if MOBILE @since_tizen 2.3
309 * @elseif WEARABLE @since_tizen 2.3.1
312 * @param[in] obj The gesture-layer
313 * @return The zoom step value
315 * @see elm_gesture_layer_zoom_step_set()
317 EAPI double elm_gesture_layer_zoom_step_get(const Evas_Object *obj);
320 * @brief Sets the step-value for rotate action.
322 * @if MOBILE @since_tizen 2.3
323 * @elseif WEARABLE @since_tizen 2.3.1
326 * @remarks Set the step to any positive value.
327 * @remarks Cancel the step setting by setting to @c 0.
329 * @param[in] obj The gesture-layer
330 * @param[in] step The new rotate step value
333 EAPI void elm_gesture_layer_rotate_step_set(Evas_Object *obj, double step);
336 * @brief Gets the step-value for rotate action.
338 * @if MOBILE @since_tizen 2.3
339 * @elseif WEARABLE @since_tizen 2.3.1
342 * @param[in] obj The gesture-layer
343 * @return The rotate step value
346 EAPI double elm_gesture_layer_rotate_step_get(const Evas_Object *obj);
349 * @brief Attaches a given gesture layer widget to an Evas object, thus setting
350 * the widget's @b target.
352 * @if MOBILE @since_tizen 2.3
353 * @elseif WEARABLE @since_tizen 2.3.1
356 * @remarks A gesture layer target may be whichever Evas object one
357 * chooses. This is the object @a obj that listens to all mouse and key
358 * events and reports the gestures made upon it.
361 * @param[in] obj The gesture layer to attach an object to
362 * @param[in] target The object to attach to @a obj (target)
364 * @return @c EINA_TRUE on success, otherwise @c EINA_FALSE on failure
367 EAPI Eina_Bool elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *target);
370 * @brief Called to construct a new gesture-layer object.
372 * @if MOBILE @since_tizen 2.3
373 * @elseif WEARABLE @since_tizen 2.3.1
376 * @remarks This does not activate the gesture layer. You have to
377 * call elm_gesture_layer_attach() in order to 'activate' gesture-layer.
379 * @param[in] parent The gesture layer's parent widget
381 * @return A new gesture layer object
384 EAPI Evas_Object *elm_gesture_layer_add(Evas_Object *parent);
387 * @brief Sets the gesture layer line min length of an object.
391 * @if MOBILE @since_tizen 2.3
392 * @elseif WEARABLE @since_tizen 2.3.1
395 * @param[in] obj The gesture-layer
396 * @param[in] line_min_length The length
399 EAPI void elm_gesture_layer_line_min_length_set(Evas_Object *obj, int line_min_length);
402 * @brief Gets the gesture layer line min length of an object.
406 * @if MOBILE @since_tizen 2.3
407 * @elseif WEARABLE @since_tizen 2.3.1
410 * @param[in] obj The gesture-layer
414 EAPI int elm_gesture_layer_line_min_length_get(const Evas_Object *obj);
417 * @brief Sets the gesture layer zoom distance tolerance of an object.
421 * @if MOBILE @since_tizen 2.3
422 * @elseif WEARABLE @since_tizen 2.3.1
425 * @param[in] obj The gesture-layer
426 * @param[in] zoom_distance_tolerance The zoom distance tolerance
429 EAPI void elm_gesture_layer_zoom_distance_tolerance_set(Evas_Object *obj, Evas_Coord zoom_distance_tolerance);
432 * @brief Gets the gesture layer zoom distance tolerance of an object.
436 * @if MOBILE @since_tizen 2.3
437 * @elseif WEARABLE @since_tizen 2.3.1
440 * @param[in] obj The gesture-layer
441 * @return The zoom distance tolerance
444 EAPI Evas_Coord elm_gesture_layer_zoom_distance_tolerance_get(const Evas_Object *obj);
447 * @brief Sets the gesture layer line distance tolerance of an object.
451 * @if MOBILE @since_tizen 2.3
452 * @elseif WEARABLE @since_tizen 2.3.1
455 * @param[in] obj The gesture-layer
456 * @param[in] line_distance_tolerance The line distance tolerance
459 EAPI void elm_gesture_layer_line_distance_tolerance_set(Evas_Object *obj, Evas_Coord line_distance_tolerance);
462 * @brief Gets the gesture layer line distance tolerance of an object.
466 * @if MOBILE @since_tizen 2.3
467 * @elseif WEARABLE @since_tizen 2.3.1
470 * @param[in] obj The gesture-layer
471 * @return The line distance tolerance
474 EAPI Evas_Coord elm_gesture_layer_line_distance_tolerance_get(const Evas_Object *obj);
477 * @brief Sets the gesture layer line angular tolerance of an object.
481 * @if MOBILE @since_tizen 2.3
482 * @elseif WEARABLE @since_tizen 2.3.1
485 * @param[in] obj The gesture-layer
486 * @param[in] line_angular_tolerance The line angular tolerance
489 EAPI void elm_gesture_layer_line_angular_tolerance_set(Evas_Object *obj, double line_angular_tolerance);
492 * @brief Gets the gesture layer line angular tolerance of an object.
496 * @if MOBILE @since_tizen 2.3
497 * @elseif WEARABLE @since_tizen 2.3.1
500 * @param[in] obj The gesture-layer
501 * @return The line angular tolerance
504 EAPI double elm_gesture_layer_line_angular_tolerance_get(const Evas_Object *obj);
507 * @brief Sets the gesture layer zoom wheel factor of an object.
511 * @if MOBILE @since_tizen 2.3
512 * @elseif WEARABLE @since_tizen 2.3.1
515 * @param[in] obj The gesture-layer
516 * @param[in] zoom_wheel_factor The zoom wheel factor
519 EAPI void elm_gesture_layer_zoom_wheel_factor_set(Evas_Object *obj, double zoom_wheel_factor);
522 * @brief Gets the gesture layer zoom wheel factor of an object.
526 * @if MOBILE @since_tizen 2.3
527 * @elseif WEARABLE @since_tizen 2.3.1
530 * @param[in] obj The gesture-layer
531 * @return The zoom wheel factor
534 EAPI double elm_gesture_layer_zoom_wheel_factor_get(const Evas_Object *obj);
537 * @brief Sets the gesture layer zoom finger factor of an object
541 * @if MOBILE @since_tizen 2.3
542 * @elseif WEARABLE @since_tizen 2.3.1
545 * @param[in] obj The gesture-layer
546 * @param[in] zoom_finger_factor The zoom finger factor
549 EAPI void elm_gesture_layer_zoom_finger_factor_set(Evas_Object *obj, double zoom_finger_factor);
552 * @brief Gets the gesture layer zoom finger factor of an object.
556 * @if MOBILE @since_tizen 2.3
557 * @elseif WEARABLE @since_tizen 2.3.1
560 * @param[in] obj The gesture-layer
561 * @return The zoom finger factor
564 EAPI double elm_gesture_layer_zoom_finger_factor_get(const Evas_Object *obj);
567 * @brief Sets the gesture layer rotate angular tolerance of an object.
571 * @if MOBILE @since_tizen 2.3
572 * @elseif WEARABLE @since_tizen 2.3.1
575 * @param[in] obj The gesture-layer
576 * @param[in] rotate_angular_tolerance The rotate angular tolerance
579 EAPI void elm_gesture_layer_rotate_angular_tolerance_set(Evas_Object *obj, double rotate_angular_tolerance);
582 * @brief Gets the gesture layer rotate angular tolerance of an object.
586 * @if MOBILE @since_tizen 2.3
587 * @elseif WEARABLE @since_tizen 2.3.1
590 * @param[in] obj The gesture-layer
591 * @return The rotate angular tolerance
594 EAPI double elm_gesture_layer_rotate_angular_tolerance_get(const Evas_Object *obj);
597 * @brief Sets the gesture layer flick time limit (in ms) of an object.
601 * @if MOBILE @since_tizen 2.3
602 * @elseif WEARABLE @since_tizen 2.3.1
605 * @param[in] obj The gesture-layer
606 * @param[in] flick_time_limit_ms The flick time limit (in ms)
609 EAPI void elm_gesture_layer_flick_time_limit_ms_set(Evas_Object *obj, unsigned int flick_time_limit_ms);
612 * @brief Gets the gesture layer flick time limit (in ms) of an object.
616 * @if MOBILE @since_tizen 2.3
617 * @elseif WEARABLE @since_tizen 2.3.1
620 * @param[in] obj The gesture-layer
621 * @return The flick time limit (in ms)
624 EAPI unsigned int elm_gesture_layer_flick_time_limit_ms_get(const Evas_Object *obj);
627 * @brief Sets the gesture layer long tap start timeout of an object.
631 * @if MOBILE @since_tizen 2.3
632 * @elseif WEARABLE @since_tizen 2.3.1
635 * @param[in] obj The gesture-layer
636 * @param[in] long_tap_start_timeout The long tap start timeout
639 EAPI void elm_gesture_layer_long_tap_start_timeout_set(Evas_Object *obj, double long_tap_start_timeout);
642 * @brief Gets the gesture layer long tap start timeout of an object.
646 * @if MOBILE @since_tizen 2.3
647 * @elseif WEARABLE @since_tizen 2.3.1
650 * @param[in] obj The gesture-layer
651 * @return The long tap start timeout
654 EAPI double elm_gesture_layer_long_tap_start_timeout_get(const Evas_Object *obj);
657 * @brief Sets the gesture layer continues enable of an object.
661 * @if MOBILE @since_tizen 2.3
662 * @elseif WEARABLE @since_tizen 2.3.1
665 * @param[in] obj The gesture-layer
666 * @param[in] continues_enable The continues enable
669 EAPI void elm_gesture_layer_continues_enable_set(Evas_Object *obj, Eina_Bool continues_enable);
672 * @brief Gets the gesture layer continues enable of an object.
676 * @if MOBILE @since_tizen 2.3
677 * @elseif WEARABLE @since_tizen 2.3.1
680 * @param[in] obj The gesture-layer
681 * @return The continues enable
684 EAPI Eina_Bool elm_gesture_layer_continues_enable_get(const Evas_Object *obj);
687 * @brief Sets the gesture layer double tap timeout of an object.
691 * @if MOBILE @since_tizen 2.3
692 * @elseif WEARABLE @since_tizen 2.3.1
695 * @param[in] obj The gesture-layer
696 * @param[in] double_tap_timeout The double tap timeout
699 EAPI void elm_gesture_layer_double_tap_timeout_set(Evas_Object *obj, double double_tap_timeout);
702 * @brief Gets the gesture layer double tap timeout of an object.
706 * @if MOBILE @since_tizen 2.3
707 * @elseif WEARABLE @since_tizen 2.3.1
710 * @param[in] obj The gesture-layer
711 * @return The double tap timeout
714 EAPI double elm_gesture_layer_double_tap_timeout_get(const Evas_Object *obj);
717 * @brief Sets the gesture layer finger-size for taps.
719 * @if MOBILE @since_tizen 2.3
720 * @elseif WEARABLE @since_tizen 2.3.1
723 * @remarks If not set, this size is taken from elm_config.
724 * Set to ZERO if you want GLayer to use system finger size value (default)
725 * It is recommended to not set a very big or small value to avoid weird
728 * @param[in] obj The gesture-layer
729 * @param[in] sz The finger size
732 EAPI void elm_gesture_layer_tap_finger_size_set(Evas_Object *obj, Evas_Coord sz);
735 * @brief Gets the gesture layer finger-size for taps.
739 * @if MOBILE @since_tizen 2.3
740 * @elseif WEARABLE @since_tizen 2.3.1
743 * @param[in] obj The gesture-layer
744 * @return The finger size that is currently used by the Gesture Layer for taps
747 EAPI Evas_Coord elm_gesture_layer_tap_finger_size_get(const Evas_Object *obj);