2 * @defgroup Elm_Gesture_Layer Gesture Layer
7 * Use Gesture Layer to detect gestures.
8 * The advantage is that you don't have to implement
9 * gesture detection, just set callbacks of gesture state.
10 * By using gesture layer we make standard interface.
12 * In order to use Gesture Layer you start with @ref elm_gesture_layer_add
13 * with a parent object parameter.
14 * Next 'activate' gesture layer with a @ref elm_gesture_layer_attach
15 * call. Usually with same object as target (2nd parameter).
17 * Now you need to tell gesture layer what gestures you follow.
18 * This is done with @ref elm_gesture_layer_cb_set call.
19 * By setting the callback you actually saying to gesture layer:
20 * I would like to know when the gesture @ref Elm_Gesture_Type
21 * switches to state @ref Elm_Gesture_State.
23 * Next, you need to implement the actual action that follows the input
26 * Note that if you like to stop being reported about a gesture, just set
27 * all callbacks referring this gesture to NULL.
28 * (again with @ref elm_gesture_layer_cb_set)
30 * The information reported by gesture layer to your callback is depending
31 * on @ref Elm_Gesture_Type:
32 * @ref Elm_Gesture_Taps_Info is the info reported for tap gestures:
33 * @ref ELM_GESTURE_N_TAPS, @ref ELM_GESTURE_N_LONG_TAPS,
34 * @ref ELM_GESTURE_N_DOUBLE_TAPS, @ref ELM_GESTURE_N_TRIPLE_TAPS.
36 * @ref Elm_Gesture_Momentum_Info is info reported for momentum gestures:
37 * @ref ELM_GESTURE_MOMENTUM.
39 * @ref Elm_Gesture_Line_Info is the info reported for line gestures:
40 * (this also contains @ref Elm_Gesture_Momentum_Info internal structure)
41 * @ref ELM_GESTURE_N_LINES, @ref ELM_GESTURE_N_FLICKS.
42 * Note that we consider a flick as a line-gesture that should be completed
43 * in flick-time-limit as defined in @ref Config.
45 * @ref Elm_Gesture_Zoom_Info is the info reported for @ref ELM_GESTURE_ZOOM gesture.
47 * @ref Elm_Gesture_Rotate_Info is the info reported for @ref ELM_GESTURE_ROTATE gesture.
50 * Gesture Layer Tweaks:
52 * Note that line, flick, gestures can start without the need to remove fingers from surface.
53 * When user fingers rests on same-spot gesture is ended and starts again when fingers moved.
55 * Setting glayer_continues_enable to false in @ref Config will change this behavior
56 * so gesture starts when user touches (a *DOWN event) touch-surface
57 * and ends when no fingers touches surface (a *UP event).
59 * Supported elm_object common APIs.
60 * @li @ref elm_object_disabled_set
61 * @li @ref elm_object_disabled_get
66 * Enum of supported gesture types.
67 * @ingroup Elm_Gesture_Layer
71 ELM_GESTURE_FIRST = 0,
73 ELM_GESTURE_N_TAPS, /**< N fingers single taps */
74 ELM_GESTURE_N_LONG_TAPS, /**< N fingers single long-taps */
75 ELM_GESTURE_N_DOUBLE_TAPS, /**< N fingers double-single taps */
76 ELM_GESTURE_N_TRIPLE_TAPS, /**< N fingers triple-single taps */
78 ELM_GESTURE_MOMENTUM, /**< Reports momentum in the direction of move */
80 ELM_GESTURE_N_LINES, /**< N fingers line gesture */
81 ELM_GESTURE_N_FLICKS, /**< N fingers flick gesture */
83 ELM_GESTURE_ZOOM, /**< Zoom */
84 ELM_GESTURE_ROTATE, /**< Rotate */
90 * @enum _Elm_Gesture_State
91 * Enum of gesture states.
92 * @ingroup Elm_Gesture_Layer
96 ELM_GESTURE_STATE_UNDEFINED = -1, /**< Gesture not STARTed */
97 ELM_GESTURE_STATE_START, /**< Gesture STARTed */
98 ELM_GESTURE_STATE_MOVE, /**< Gesture is ongoing */
99 ELM_GESTURE_STATE_END, /**< Gesture completed */
100 ELM_GESTURE_STATE_ABORT /**< Ongoing gesture was ABORTed */
104 * @struct _Elm_Gesture_Taps_Info
105 * Struct holds taps info for user
106 * @ingroup Elm_Gesture_Layer
108 struct _Elm_Gesture_Taps_Info
110 Evas_Coord x, y; /**< Holds center point between fingers */
111 unsigned int n; /**< Number of fingers tapped */
112 unsigned int timestamp; /**< event timestamp */
116 * @typedef Elm_Gesture_Taps_Info
117 * holds taps info for user
118 * @ingroup Elm_Gesture_Layer
120 typedef struct _Elm_Gesture_Taps_Info Elm_Gesture_Taps_Info;
123 * @struct _Elm_Gesture_Momentum_Info
124 * Struct holds momentum info for user
125 * x1 and y1 are not necessarily in sync
126 * x1 holds x value of x direction starting point
127 * and same holds for y1.
128 * This is noticeable when doing V-shape movement
129 * @ingroup Elm_Gesture_Layer
131 struct _Elm_Gesture_Momentum_Info /* Report line ends, timestamps, and momentum computed */
132 {Evas_Coord x1; /**< Final-swipe direction starting point on X */
133 Evas_Coord y1; /**< Final-swipe direction starting point on Y */
134 Evas_Coord x2; /**< Final-swipe direction ending point on X */
135 Evas_Coord y2; /**< Final-swipe direction ending point on Y */
137 unsigned int tx; /**< Timestamp of start of final x-swipe */
138 unsigned int ty; /**< Timestamp of start of final y-swipe */
140 Evas_Coord mx; /**< Momentum on X */
141 Evas_Coord my; /**< Momentum on Y */
143 unsigned int n; /**< Number of fingers */
147 * @typedef Elm_Gesture_Momentum_Info
148 * holds momentum info for user
149 * @ingroup Elm_Gesture_Layer
151 typedef struct _Elm_Gesture_Momentum_Info Elm_Gesture_Momentum_Info;
154 * @struct _Elm_Gesture_Line_Info
155 * Struct holds line info for user
156 * @ingroup Elm_Gesture_Layer
158 struct _Elm_Gesture_Line_Info /* Report line ends, timestamps, and momentum computed */
159 {Elm_Gesture_Momentum_Info momentum; /**< Line momentum info */
160 double angle; /**< Angle (direction) of lines */
164 * @typedef Elm_Gesture_Line_Info
165 * Holds line info for user
166 * @ingroup Elm_Gesture_Layer
168 typedef struct _Elm_Gesture_Line_Info Elm_Gesture_Line_Info;
171 * @struct _Elm_Gesture_Zoom_Info
172 * Struct holds zoom info for user
173 * @ingroup Elm_Gesture_Layer
175 struct _Elm_Gesture_Zoom_Info
177 Evas_Coord x, y; /**< Holds zoom center point reported to user */
178 Evas_Coord radius; /**< Holds radius between fingers reported to user */
179 double zoom; /**< Zoom value: 1.0 means no zoom */
180 double momentum; /**< Zoom momentum: zoom growth per second (NOT YET SUPPORTED) */
184 * @typedef Elm_Gesture_Zoom_Info
185 * Holds zoom info for user
186 * @ingroup Elm_Gesture_Layer
188 typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;
191 * @struct _Elm_Gesture_Rotate_Info
192 * Struct holds rotation info for user
193 * @ingroup Elm_Gesture_Layer
195 struct _Elm_Gesture_Rotate_Info
197 Evas_Coord x, y; /**< Holds zoom center point reported to user */
198 Evas_Coord radius; /**< Holds radius between fingers reported to user */
199 double base_angle; /**< Holds start-angle */
200 double angle; /**< Rotation value: 0.0 means no rotation */
201 double momentum; /**< Rotation momentum: rotation done per second (NOT YET SUPPORTED) */
205 * @typedef Elm_Gesture_Rotate_Info
206 * Holds rotation info for user
207 * @ingroup Elm_Gesture_Layer
209 typedef struct _Elm_Gesture_Rotate_Info Elm_Gesture_Rotate_Info;
212 * @typedef Elm_Gesture_Event_Cb
213 * User callback used to stream gesture info from gesture layer
214 * @param data user data
215 * @param event_info gesture report info
216 * Returns a flag field to be applied on the causing event.
217 * You should probably return EVAS_EVENT_FLAG_ON_HOLD if your widget acted
218 * upon the event, in an irreversible way.
220 * @ingroup Elm_Gesture_Layer
222 typedef Evas_Event_Flags (*Elm_Gesture_Event_Cb)(void *data, void *event_info);
225 * Use function to set callbacks to be notified about
226 * change of state of gesture.
227 * When a user registers a callback with this function
228 * this means this gesture has to be tested.
230 * When ALL callbacks for a gesture are set to NULL
231 * it means user isn't interested in gesture-state
232 * and it will not be tested.
234 * @param obj gesture-layer.
235 * @param idx The gesture you would like to track its state.
236 * @param cb callback function pointer.
237 * @param cb_type what event this callback tracks: START, MOVE, END, ABORT.
238 * @param data user info to be sent to callback (usually, Smart Data)
240 * @ingroup Elm_Gesture_Layer
242 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);
245 * Call this function to get repeat-events settings.
247 * @param obj gesture-layer.
249 * @return repeat events settings.
250 * @see elm_gesture_layer_hold_events_set()
251 * @ingroup Elm_Gesture_Layer
253 EAPI Eina_Bool elm_gesture_layer_hold_events_get(const Evas_Object *obj);
256 * This function is to make gesture-layer repeat events.
257 * Set this if you like to get the raw events only if gestures were not
259 * Clear this if you like gesture layer to forward events as testing gestures.
261 * @param obj gesture layer.
262 * @param hold_events hold events or not.
264 * @ingroup Elm_Gesture_Layer
266 EAPI void elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool hold_events);
269 * This function sets step-value for zoom action.
270 * Set step to any positive value.
271 * Cancel step setting by setting to 0
273 * @param obj gesture-layer.
274 * @param step new zoom step value.
276 * @see elm_gesture_layer_zoom_step_get()
277 * @ingroup Elm_Gesture_Layer
279 EAPI void elm_gesture_layer_zoom_step_set(Evas_Object *obj, double step);
282 * This function returns step-value for zoom action.
284 * @param obj gesture-layer.
285 * @return zoom step value.
287 * @see elm_gesture_layer_zoom_step_set()
288 * @ingroup Elm_Gesture_Layer
290 EAPI double elm_gesture_layer_zoom_step_get(const Evas_Object *obj);
293 * This function sets step-value for rotate action.
294 * Set step to any positive value.
295 * Cancel step setting by setting to 0
297 * @param obj gesture-layer.
298 * @param step new rotate step value.
300 * @ingroup Elm_Gesture_Layer
302 EAPI void elm_gesture_layer_rotate_step_set(Evas_Object *obj, double step);
305 * This function returns step-value for rotate action.
307 * @param obj gesture-layer.
308 * @return rotate step value.
310 * @ingroup Elm_Gesture_Layer
312 EAPI double elm_gesture_layer_rotate_step_get(const Evas_Object *obj);
315 * This function called to attach gesture-layer to an Evas_Object.
316 * @param obj gesture-layer.
317 * @param target Pointer to underlying object (AKA Target)
319 * @return TRUE, FALSE on success, failure.
321 * @ingroup Elm_Gesture_Layer
323 EAPI Eina_Bool elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *target);
326 * Call this function to construct a new gesture-layer object.
327 * This does not activate the gesture layer. You have to
328 * call elm_gesture_layer_attach in order to 'activate' gesture-layer.
330 * @param parent the parent object.
332 * @return new gesture-layer object.
334 * @ingroup Elm_Gesture_Layer
336 EAPI Evas_Object *elm_gesture_layer_add(Evas_Object *parent);