#define ELM_GESTURE_MULTI_TIMEOUT 50
#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001
+#define ELM_GESTURE_TAP_TIMEOUT 0.2
+
/* Some Trigo values */
#define RAD_90DEG M_PI_2
#define RAD_180DEG M_PI
if (!event_info)
return; /* This happens when restarting gestures */
- if ((ev_flags) || (!wd->repeat_events))
+ if (!wd->repeat_events) ev_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+
+ if (ev_flags)
{
switch(event_type)
{
Taps_Type *st = gesture->data;
Eina_List *l;
Eina_List *pe_list;
+ if (!st || !st->l) return EINA_FALSE;
EINA_LIST_FOREACH(st->l, l, pe_list)
{
if (eina_list_count(pe_list) != st->n_taps_needed)
static void
_tap_gesture_finish(void *data)
{ /* This function will test each tap gesture when timer expires */
- Elm_Gesture_State s = ELM_GESTURE_STATE_END;
+ Elm_Gesture_State s = ELM_GESTURE_STATE_ABORT;
Gesture_Info *gesture = data;
Taps_Type *st = gesture->data;
- if (!_tap_gesture_check_finish(data))
- s = ELM_GESTURE_STATE_ABORT;
+ if (_tap_gesture_check_finish(gesture))
+ {
+ s = ELM_GESTURE_STATE_END;
+ }
st->info.n = eina_list_count(st->l);
_set_state(gesture, s, gesture->info, EINA_FALSE);
/**
* @internal
*
- * This function checks if a tap gesture should start
+ * This function checks the state of a tap gesture.
*
* @param wd Gesture Layer Widget Data.
* @param pe The recent input event as stored in pe struct.
* @param gesture what gesture is tested
* @param how many taps for this gesture (1, 2 or 3)
*
- * @return Flag to determine if we need to set a timer for finish
- *
* @ingroup Elm_Gesture_Layer
*/
-static Eina_Bool
-_tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
+static void
+_tap_gesture_test(Widget_Data *wd, Pointer_Event *pe,
void *event_info, Evas_Callback_Type event_type,
Gesture_Info *gesture, int taps)
{ /* Here we fill Tap struct */
+ if (!pe)
+ return;
+
Taps_Type *st = gesture->data;
if (!st)
{ /* Allocated once on first time */
&st->info, EINA_FALSE);
consume_event(wd, event_info, event_type, ev_flag);
- return EINA_FALSE;
+ return;
}
pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
+ if (!wd->dbl_timeout)
+ {
+ wd->dbl_timeout = ecore_timer_add(ELM_GESTURE_TAP_TIMEOUT,
+ _multi_tap_timeout, gesture->obj);
+ }
+ else
+ {
+ ecore_timer_reset(wd->dbl_timeout);
+ }
+
if ((pe->device == 0) && (eina_list_count(pe_list) == 1))
{ /* This is the first mouse down we got */
ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
st->n_taps_needed = taps * 2; /* count DOWN and UP */
- return EINA_TRUE;
+ return;
+ }
+ else if (eina_list_count(pe_list) > st->n_taps_needed)
+ {
+ /* If we arleady got too many touches for this gesture. */
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
+ &st->info, EINA_FALSE);
}
break;
case EVAS_CALLBACK_MOUSE_UP:
pe_list = eina_list_search_unsorted(st->l, compare_pe_device, pe);
if (!pe_list)
- return EINA_FALSE;
+ return;
pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
if (_tap_gesture_check_finish(gesture))
{
_tap_gesture_finish(gesture);
- return EINA_FALSE;
+ return;
}
}
break;
default:
- return EINA_FALSE;
- }
-
- return EINA_FALSE;
-}
-
-
-/**
- * @internal
- *
- * This function checks all click/tap and double/triple taps
- *
- * @param obj The gesture-layer object.
- * @param pe The recent input event as stored in pe struct.
- * @param event_info Original input event pointer.
- * @param event_type Type of original input event.
- *
- * @ingroup Elm_Gesture_Layer
- */
-static void
-_tap_gestures_test(Evas_Object *obj, Pointer_Event *pe,
- void *event_info, Evas_Callback_Type event_type)
-{ /* Here we fill Recent_Taps struct and fire-up click/tap timers */
- Eina_Bool need_timer = EINA_FALSE;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- if (!pe) /* this happens when unhandled event arrived */
- return; /* see _make_pointer_event function */
-
- if (IS_TESTED(ELM_GESTURE_N_TAPS))
- need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
- wd->gesture[ELM_GESTURE_N_TAPS], 1);
-
- if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
- need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
- wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS], 2);
-
- if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
- need_timer |= _tap_gesture_start(wd, pe, event_info, event_type,
- wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS], 3);
-
- if ((need_timer) && (!wd->dbl_timeout))
- { /* Set a timer to finish these gestures */
- wd->dbl_timeout = ecore_timer_add(0.4, _multi_tap_timeout,
- obj);
+ return ;
}
}
_n_long_tap_test(data, pe, event_info, event_type,
ELM_GESTURE_N_LONG_TAPS);
- /* This takes care of single, double and tripple tap */
- _tap_gestures_test(data, pe, event_info, event_type);
+ if (IS_TESTED(ELM_GESTURE_N_TAPS))
+ _tap_gesture_test(wd, pe, event_info, event_type,
+ wd->gesture[ELM_GESTURE_N_TAPS], 1);
+
+ if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
+ _tap_gesture_test(wd, pe, event_info, event_type,
+ wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS], 2);
+
+ if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
+ _tap_gesture_test(wd, pe, event_info, event_type,
+ wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS], 3);
if (IS_TESTED(ELM_GESTURE_MOMENTUM))
_momentum_test(data, pe, event_info, event_type,
if (_get_event_flag(event_info, event_type) & EVAS_EVENT_FLAG_ON_HOLD)
_event_history_add(data, event_info, event_type);
- else if ((event_type == EVAS_CALLBACK_MOUSE_UP) ||
- (event_type == EVAS_CALLBACK_MULTI_UP))
- {
- Eina_List *pending = _device_is_pending(wd->pending, event_info, event_type);
- if (pending)
- {
- consume_event(wd, event_info, event_type, EVAS_EVENT_FLAG_ON_HOLD);
- _event_history_add(data, event_info, event_type);
- }
- }
/* we maintain list of touched devices */
/* We also use move to track current device x.y pos */
* (again with @ref elm_gesture_layer_cb_set)
*
* The information reported by gesture layer to your callback is depending
- * on @ref Elm_Gesture_Type:
+ * on @ref Elm_Gesture_Type :
* @ref Elm_Gesture_Taps_Info is the info reported for tap gestures:
* @ref ELM_GESTURE_N_TAPS, @ref ELM_GESTURE_N_LONG_TAPS,
* @ref ELM_GESTURE_N_DOUBLE_TAPS, @ref ELM_GESTURE_N_TRIPLE_TAPS.
* @li @ref elm_object_disabled_set
* @li @ref elm_object_disabled_get
*
+ * @{
+ *
*/
/**
+ * @enum _Elm_Gesture_Type
* Enum of supported gesture types.
- * @ingroup Elm_Gesture_Layer
*/
-typedef enum
+enum _Elm_Gesture_Type
{
ELM_GESTURE_FIRST = 0,
ELM_GESTURE_ROTATE, /**< Rotate */
ELM_GESTURE_LAST
-} Elm_Gesture_Type;
+};
+
+/**
+ * @typedef Elm_Gesture_Type
+ * Convenient macro around #_Elm_Gesture_Type
+ */
+typedef enum _Elm_Gesture_Type Elm_Gesture_Type;
/**
* @enum _Elm_Gesture_State
* Enum of gesture states.
- * @ingroup Elm_Gesture_Layer
*/
-typedef enum
+enum _Elm_Gesture_State
{
ELM_GESTURE_STATE_UNDEFINED = -1, /**< Gesture not STARTed */
ELM_GESTURE_STATE_START, /**< Gesture STARTed */
ELM_GESTURE_STATE_MOVE, /**< Gesture is ongoing */
ELM_GESTURE_STATE_END, /**< Gesture completed */
ELM_GESTURE_STATE_ABORT /**< Ongoing gesture was ABORTed */
-} Elm_Gesture_State;
+};
+
+/**
+ * @typedef Elm_Gesture_State
+ * Convenient macro around #_Elm_Gesture_State
+ */
+typedef enum _Elm_Gesture_State Elm_Gesture_State;
/**
* @struct _Elm_Gesture_Taps_Info
* Struct holds taps info for user
- * @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Taps_Info
{
/**
* @typedef Elm_Gesture_Taps_Info
* holds taps info for user
- * @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Taps_Info Elm_Gesture_Taps_Info;
* x1 holds x value of x direction starting point
* and same holds for y1.
* This is noticeable when doing V-shape movement
- * @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Momentum_Info /* Report line ends, timestamps, and momentum computed */
{Evas_Coord x1; /**< Final-swipe direction starting point on X */
/**
* @typedef Elm_Gesture_Momentum_Info
* holds momentum info for user
- * @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Momentum_Info Elm_Gesture_Momentum_Info;
/**
* @struct _Elm_Gesture_Line_Info
* Struct holds line info for user
- * @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Line_Info /* Report line ends, timestamps, and momentum computed */
{Elm_Gesture_Momentum_Info momentum; /**< Line momentum info */
/**
* @typedef Elm_Gesture_Line_Info
* Holds line info for user
- * @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Line_Info Elm_Gesture_Line_Info;
/**
* @struct _Elm_Gesture_Zoom_Info
* Struct holds zoom info for user
- * @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Zoom_Info
{
/**
* @typedef Elm_Gesture_Zoom_Info
* Holds zoom info for user
- * @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Zoom_Info Elm_Gesture_Zoom_Info;
/**
* @struct _Elm_Gesture_Rotate_Info
* Struct holds rotation info for user
- * @ingroup Elm_Gesture_Layer
*/
struct _Elm_Gesture_Rotate_Info
{
/**
* @typedef Elm_Gesture_Rotate_Info
* Holds rotation info for user
- * @ingroup Elm_Gesture_Layer
*/
typedef struct _Elm_Gesture_Rotate_Info Elm_Gesture_Rotate_Info;
* You should probably return EVAS_EVENT_FLAG_ON_HOLD if your widget acted
* upon the event, in an irreversible way.
*
- * @ingroup Elm_Gesture_Layer
*/
typedef Evas_Event_Flags (*Elm_Gesture_Event_Cb)(void *data, void *event_info);
* @param cb_type what event this callback tracks: START, MOVE, END, ABORT.
* @param data user info to be sent to callback (usually, Smart Data)
*
- * @ingroup Elm_Gesture_Layer
*/
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);
*
* @return repeat events settings.
* @see elm_gesture_layer_hold_events_set()
- * @ingroup Elm_Gesture_Layer
*/
EAPI Eina_Bool elm_gesture_layer_hold_events_get(const Evas_Object *obj);
* @param obj gesture layer.
* @param hold_events hold events or not.
*
- * @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_hold_events_set(Evas_Object *obj, Eina_Bool hold_events);
* @param step new zoom step value.
*
* @see elm_gesture_layer_zoom_step_get()
- * @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_zoom_step_set(Evas_Object *obj, double step);
* @return zoom step value.
*
* @see elm_gesture_layer_zoom_step_set()
- * @ingroup Elm_Gesture_Layer
*/
EAPI double elm_gesture_layer_zoom_step_get(const Evas_Object *obj);
* @param obj gesture-layer.
* @param step new rotate step value.
*
- * @ingroup Elm_Gesture_Layer
*/
EAPI void elm_gesture_layer_rotate_step_set(Evas_Object *obj, double step);
* @param obj gesture-layer.
* @return rotate step value.
*
- * @ingroup Elm_Gesture_Layer
*/
EAPI double elm_gesture_layer_rotate_step_get(const Evas_Object *obj);
*
* @return TRUE, FALSE on success, failure.
*
- * @ingroup Elm_Gesture_Layer
*/
EAPI Eina_Bool elm_gesture_layer_attach(Evas_Object *obj, Evas_Object *target);
*
* @return new gesture-layer object.
*
- * @ingroup Elm_Gesture_Layer
*/
EAPI Evas_Object *elm_gesture_layer_add(Evas_Object *parent);
+
+/**
+ * @}
+ */