2 * @defgroup Elm_Gesture_Layer Gesture Layer
5 * Use Gesture Layer to detect gestures.
6 * The advantage is that you don't have to implement
7 * gesture detection, just set callbacks of gesture state.
8 * By using gesture layer we make standard interface.
10 * In order to use Gesture Layer you start with @ref elm_gesture_layer_add
11 * with a parent object parameter.
12 * Next 'activate' gesture layer with a @ref elm_gesture_layer_attach
13 * call. Usually with same object as target (2nd parameter).
15 * Now you need to tell gesture layer what gestures you follow.
16 * This is done with @ref elm_gesture_layer_cb_set call.
17 * By setting the callback you actually saying to gesture layer:
18 * I would like to know when the gesture @ref Elm_Gesture_Types
19 * switches to state @ref Elm_Gesture_State.
21 * Next, you need to implement the actual action that follows the input
24 * Note that if you like to stop being reported about a gesture, just set
25 * all callbacks referring this gesture to NULL.
26 * (again with @ref elm_gesture_layer_cb_set)
28 * The information reported by gesture layer to your callback is depending
29 * on @ref Elm_Gesture_Types:
30 * @ref Elm_Gesture_Taps_Info is the info reported for tap gestures:
31 * @ref ELM_GESTURE_N_TAPS, @ref ELM_GESTURE_N_LONG_TAPS,
32 * @ref ELM_GESTURE_N_DOUBLE_TAPS, @ref ELM_GESTURE_N_TRIPLE_TAPS.
34 * @ref Elm_Gesture_Momentum_Info is info reported for momentum gestures:
35 * @ref ELM_GESTURE_MOMENTUM.
37 * @ref Elm_Gesture_Line_Info is the info reported for line gestures:
38 * (this also contains @ref Elm_Gesture_Momentum_Info internal structure)
39 * @ref ELM_GESTURE_N_LINES, @ref ELM_GESTURE_N_FLICKS.
40 * Note that we consider a flick as a line-gesture that should be completed
41 * in flick-time-limit as defined in @ref Config.
43 * @ref Elm_Gesture_Zoom_Info is the info reported for @ref ELM_GESTURE_ZOOM gesture.
45 * @ref Elm_Gesture_Rotate_Info is the info reported for @ref ELM_GESTURE_ROTATE gesture.
48 * Gesture Layer Tweaks:
50 * Note that line, flick, gestures can start without the need to remove fingers from surface.
51 * When user fingers rests on same-spot gesture is ended and starts again when fingers moved.
53 * Setting glayer_continues_enable to false in @ref Config will change this behavior
54 * so gesture starts when user touches (a *DOWN event) touch-surface
55 * and ends when no fingers touches surface (a *UP event).
57 * Supported elm_object common APIs.
58 * @li elm_object_disabled_set
59 * @li elm_object_disabled_get
64 * Enum of supported gesture types.
65 * @ingroup Elm_Gesture_Layer
69 ELM_GESTURE_FIRST = 0,
71 ELM_GESTURE_N_TAPS, /**< N fingers single taps */
72 ELM_GESTURE_N_LONG_TAPS, /**< N fingers single long-taps */
73 ELM_GESTURE_N_DOUBLE_TAPS, /**< N fingers double-single taps */
74 ELM_GESTURE_N_TRIPLE_TAPS, /**< N fingers triple-single taps */
76 ELM_GESTURE_MOMENTUM, /**< Reports momentum in the dircetion of move */
78 ELM_GESTURE_N_LINES, /**< N fingers line gesture */
79 ELM_GESTURE_N_FLICKS, /**< N fingers flick gesture */
81 ELM_GESTURE_ZOOM, /**< Zoom */
82 ELM_GESTURE_ROTATE, /**< Rotate */
88 * @enum _Elm_Gesture_State
89 * Enum of gesture states.
90 * @ingroup Elm_Gesture_Layer
94 ELM_GESTURE_STATE_UNDEFINED = -1, /**< Gesture not STARTed */
95 ELM_GESTURE_STATE_START, /**< Gesture STARTed */
96 ELM_GESTURE_STATE_MOVE, /**< Gesture is ongoing */
97 ELM_GESTURE_STATE_END, /**< Gesture completed */
98 ELM_GESTURE_STATE_ABORT /**< Onging gesture was ABORTed */
102 * @struct _Elm_Gesture_Taps_Info
103 * Struct holds taps info for user
104 * @ingroup Elm_Gesture_Layer
106 struct _Elm_Gesture_Taps_Info
108 Evas_Coord x, y; /**< Holds center point between fingers */
109 unsigned int n; /**< Number of fingers tapped */
110 unsigned int timestamp; /**< event timestamp */
114 * @typedef Elm_Gesture_Taps_Info
115 * holds taps info for user
116 * @ingroup Elm_Gesture_Layer
118 typedef struct _Elm_Gesture_Taps_Info Elm_Gesture_Taps_Info;
121 * @struct _Elm_Gesture_Momentum_Info
122 * Struct holds momentum info for user
123 * x1 and y1 are not necessarily in sync
124 * x1 holds x value of x direction starting point
125 * and same holds for y1.
126 * This is noticeable when doing V-shape movement
127 * @ingroup Elm_Gesture_Layer
129 struct _Elm_Gesture_Momentum_Info /* Report line ends, timestamps, and momentum computed */
130 {Evas_Coord x1; /**< Final-swipe direction starting point on X */
131 Evas_Coord y1; /**< Final-swipe direction starting point on Y */
132 Evas_Coord x2; /**< Final-swipe direction ending point on X */
133 Evas_Coord y2; /**< Final-swipe direction ending point on Y */
135 unsigned int tx; /**< Timestamp of start of final x-swipe */
136 unsigned int ty; /**< Timestamp of start of final y-swipe */
138 Evas_Coord mx; /**< Momentum on X */
139 Evas_Coord my; /**< Momentum on Y */
141 unsigned int n; /**< Number of fingers */
145 * @typedef Elm_Gesture_Momentum_Info
146 * holds momentum info for user
147 * @ingroup Elm_Gesture_Layer
149 typedef struct _Elm_Gesture_Momentum_Info Elm_Gesture_Momentum_Info;
152 * @struct _Elm_Gesture_Line_Info
153 * Struct holds line info for user
154 * @ingroup Elm_Gesture_Layer
156 struct _Elm_Gesture_Line_Info /* Report line ends, timestamps, and momentum computed */
157 {Elm_Gesture_Momentum_Info momentum; /**< Line momentum info */
158 double angle; /**< Angle (direction) of lines */
162 * @typedef Elm_Gesture_Line_Info
163 * Holds line info for user
164 * @ingroup Elm_Gesture_Layer
166 typedef struct _Elm_Gesture_Line_Info Elm_Gesture_Line_Info;
169 * @struct _Elm_Gesture_Zoom_Info
170 * Struct holds zoom info for user
171 * @ingroup Elm_Gesture_Layer
173 struct _Elm_Gesture_Zoom_Info
175 Evas_Coord x, y; /**< Holds zoom center point reported to user */
176 Evas_Coord radius; /**< Holds radius between fingers reported to user */
177 double zoom; /**< Zoom value: 1.0 means no zoom */
178 double momentum; /**< Zoom momentum: zoom growth per second (NOT YET SUPPORTED) */
182 * @typedef Elm_Gesture_Zoom_Info
183 * Holds zoom info for user
184 * @ingroup Elm_Gesture_Layer
186 typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;
189 * @struct _Elm_Gesture_Rotate_Info
190 * Struct holds rotation info for user
191 * @ingroup Elm_Gesture_Layer
193 struct _Elm_Gesture_Rotate_Info
195 Evas_Coord x, y; /**< Holds zoom center point reported to user */
196 Evas_Coord radius; /**< Holds radius between fingers reported to user */
197 double base_angle; /**< Holds start-angle */
198 double angle; /**< Rotation value: 0.0 means no rotation */
199 double momentum; /**< Rotation momentum: rotation done per second (NOT YET SUPPORTED) */
203 * @typedef Elm_Gesture_Rotate_Info
204 * Holds rotation info for user
205 * @ingroup Elm_Gesture_Layer
207 typedef struct _Elm_Gesture_Rotate_Info Elm_Gesture_Rotate_Info;
210 * @typedef Elm_Gesture_Event_Cb
211 * User callback used to stream gesture info from gesture layer
212 * @param data user data
213 * @param event_info gesture report info
214 * Returns a flag field to be applied on the causing event.
215 * You should probably return EVAS_EVENT_FLAG_ON_HOLD if your widget acted
216 * upon the event, in an irreversible way.
218 * @ingroup Elm_Gesture_Layer
220 typedef Evas_Event_Flags (*Elm_Gesture_Event_Cb)(void *data, void *event_info);
223 * Use function to set callbacks to be notified about
224 * change of state of gesture.
225 * When a user registers a callback with this function
226 * this means this gesture has to be tested.
228 * When ALL callbacks for a gesture are set to NULL
229 * it means user isn't interested in gesture-state
230 * and it will not be tested.
232 * @param obj Pointer to gesture-layer.
233 * @param idx The gesture you would like to track its state.
234 * @param cb callback function pointer.
235 * @param cb_type what event this callback tracks: START, MOVE, END, ABORT.
236 * @param data user info to be sent to callback (usually, Smart Data)
238 * @ingroup Elm_Gesture_Layer
240 EAPI void elm_gesture_layer_cb_set(Evas_Object *obj, Elm_Gesture_Types idx, Elm_Gesture_State cb_type, Elm_Gesture_Event_Cb cb, void *data);
243 * Call this function to get repeat-events settings.
245 * @param obj Pointer to gesture-layer.
247 * @return repeat events settings.
248 * @see elm_gesture_layer_hold_events_set()
249 * @ingroup Elm_Gesture_Layer
251 EAPI Eina_Bool elm_gesture_layer_hold_events_get(Evas_Object *obj);
254 * This function called in order to make gesture-layer repeat events.
255 * Set this of you like to get the raw events only if gestures were not detected.
256 * Clear this if you like gesture layer to fwd events as testing gestures.
258 * @param obj Pointer to gesture-layer.
259 * @param r Repeat: TRUE/FALSE
261 * @ingroup Elm_Gesture_Layer
263 EAPI void elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool r);
266 * This function sets step-value for zoom action.
267 * Set step to any positive value.
268 * Cancel step setting by setting to 0.0
270 * @param obj Pointer to gesture-layer.
271 * @param s new zoom step value.
273 * @ingroup Elm_Gesture_Layer
275 EAPI void elm_gesture_layer_zoom_step_set(Evas_Object *obj, double s);
278 * This function sets step-value for rotate action.
279 * Set step to any positive value.
280 * Cancel step setting by setting to 0.0
282 * @param obj Pointer to gesture-layer.
283 * @param s new roatate step value.
285 * @ingroup Elm_Gesture_Layer
287 EAPI void elm_gesture_layer_rotate_step_set(Evas_Object *obj, double s);
290 * This function called to attach gesture-layer to an Evas_Object.
291 * @param obj Pointer to gesture-layer.
292 * @param t Pointer to underlying object (AKA Target)
294 * @return TRUE, FALSE on success, failure.
296 * @ingroup Elm_Gesture_Layer
298 EAPI Eina_Bool elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *t);
301 * Call this function to construct a new gesture-layer object.
302 * This does not activate the gesture layer. You have to
303 * call elm_gesture_layer_attach in order to 'activate' gesture-layer.
305 * @param parent the parent object.
307 * @return Pointer to new gesture-layer object.
309 * @ingroup Elm_Gesture_Layer
311 EAPI Evas_Object *elm_gesture_layer_add(Evas_Object *parent);