/* ELM_GESTURE_NEGATIVE_ANGLE - magic number says we didn't compute this yet */
#define ELM_GESTURE_NEGATIVE_ANGLE (-1.0) /* Magic number */
#define ELM_GESTURE_MOMENTUM_TIMEOUT 50
-#define DBL_CLICK_TIME 400
+#define ELM_GESTURE_MULTI_TIMEOUT 50
+#define ELM_GESTURE_MINIMUM_MOMENTUM 0.001
/* Some Trigo values */
#define RAD_90DEG M_PI_2
#define RAD_180DEG M_PI
#define RAD_270DEG (M_PI_2 * 3)
#define RAD_360DEG (M_PI * 2)
+/* #define DEBUG_GESTURE_LAYER 1 */
static void *
_glayer_bufdup(void *buf, size_t size)
struct _Taps_Type
{
Elm_Gesture_Taps_Info info;
- unsigned int count_ups;
unsigned int sum_x;
unsigned int sum_y;
+ unsigned int n_taps_needed;
unsigned int n_taps;
Eina_List *l;
};
typedef struct _Taps_Type Taps_Type;
+struct _Long_Tap_Type
+{
+ Elm_Gesture_Taps_Info info;
+ Evas_Coord center_x;
+ Evas_Coord center_y;
+ unsigned int max_touched;
+ Ecore_Timer *timeout; /* When this expires, long tap STARTed */
+ Eina_List *touched;
+};
+typedef struct _Long_Tap_Type Long_Tap_Type;
+
struct _Momentum_Type
{ /* Fields used by _line_test() */
Elm_Gesture_Momentum_Info info;
Evas_Coord_Point line_end;
unsigned int t_st_x; /* Time start on X */
unsigned int t_st_y; /* Time start on Y */
- unsigned int t_end; /* Time end */
+ unsigned int t_end; /* Time end */
+ unsigned int t_up; /* Recent up event time */
int xdir, ydir;
};
typedef struct _Momentum_Type Momentum_Type;
Evas_Event_Mouse_Wheel *zoom_wheel;
Evas_Coord zoom_base; /* Holds gap between fingers on zoom-start */
Evas_Coord zoom_distance_tolerance;
+ Elm_Gesture_Momentum_Info momentum1; /* For continues gesture */
+ Elm_Gesture_Momentum_Info momentum2; /* For continues gesture */
double next_step;
};
typedef struct _Zoom_Type Zoom_Type;
Pointer_Event rotate_mv1;
double rotate_angular_tolerance;
double next_step;
+ Elm_Gesture_Momentum_Info momentum1; /* For continues gesture */
+ Elm_Gesture_Momentum_Info momentum2; /* For continues gesture */
};
typedef struct _Rotate_Type Rotate_Type;
double zoom_finger_factor; /* used for zoom factor */
double rotate_angular_tolerance;
unsigned int flick_time_limit_ms;
+ double long_tap_start_timeout;
+ Eina_Bool glayer_continues_enable;
double zoom_step;
double rotate_step;
static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
-static void _event_history_clear(Evas_Object *obj);
+static Eina_Bool _event_history_clear(Evas_Object *obj);
static void _reset_states(Widget_Data *wd);
static void _key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
static void _key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
* @ingroup Elm_Gesture_Layer
*/
static int
-device_is_touched(const void *data1, const void *data2)
+compare_device(const void *data1, const void *data2)
{ /* Compare the two device numbers */
return (((Pointer_Event *) data1)->device -((Pointer_Event *) data2)->device);
}
/**
* @internal
*
- * Recoed Pointer Event in touched device list
- * Note: This fuction allocates memory for PE event
- * This memory is released in _remove_touched_device()
+ * Remove Pointer Event from touched device list
* @param list Pointer to touched device list.
* @param Pointer_Event Pointer to PE.
*
* @ingroup Elm_Gesture_Layer
*/
static Eina_List *
-_add_touched_device(Eina_List *list, Pointer_Event *pe)
+_remove_touched_device(Eina_List *list, Pointer_Event *pe)
{
- if (eina_list_search_unsorted_list(list, device_is_touched, pe))
- return list;
+ Pointer_Event *p = eina_list_search_unsorted(list, compare_device, pe);
+ if (p)
+ {
+ free(p);
+ return eina_list_remove(list, p);
+ }
- Pointer_Event *p = malloc(sizeof(Pointer_Event ));
- memcpy(p, pe, sizeof(Pointer_Event)); /* Freed in _remove_touched_device() */
- return eina_list_append(list, p);
+ return list;
}
/**
* @internal
*
- * Remove Pointer Event from touched device list
+ * Recoed Pointer Event in touched device list
+ * Note: This fuction allocates memory for PE event
+ * This memory is released in _remove_touched_device()
* @param list Pointer to touched device list.
* @param Pointer_Event Pointer to PE.
*
* @ingroup Elm_Gesture_Layer
*/
static Eina_List *
-_remove_touched_device(Eina_List *list, Pointer_Event *pe)
+_add_touched_device(Eina_List *list, Pointer_Event *pe)
{
- Pointer_Event *p = eina_list_search_unsorted(list, device_is_touched, pe);
+ Pointer_Event *p = eina_list_search_unsorted(list, compare_device, pe);
if (p)
- {
- free(p);
- return eina_list_remove(list, p);
+ { /* We like to track device touch-position, overwrite info */
+ memcpy(p, pe, sizeof(Pointer_Event));
+ return list;
+ }
+
+ if ((pe->event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+ (pe->event_type == EVAS_CALLBACK_MULTI_DOWN))
+ { /* Add touched device on DOWN event only */
+ p = malloc(sizeof(Pointer_Event));
+ /* Freed in _remove_touched_device() */
+ memcpy(p, pe, sizeof(Pointer_Event));
+ return eina_list_append(list, p);
}
return list;
{ /* Mark EVAS_EVENT_FLAG_ON_HOLD on events that are used by gesture layer */
/* ev_flags != EVAS_EVENT_FLAG_NONE means target used event and g-layer */
/* should not refeed this event. */
+ if(!event_info)
+ return; /* This happens when restarting gestures */
+
if ((ev_flags) || (!wd->repeat_events))
{
switch(event_type)
_report_state(Gesture_Info *gesture, void *info)
{ /* We report current state (START, MOVE, END, ABORT), once */
#if defined(DEBUG_GESTURE_LAYER)
- printf("%s reporting gesture=<%d> state=<%d>\n" , __func__, g_type,
+ printf("%s reporting gesture=<%d> state=<%d>\n" , __func__, gesture->g_type,
gesture->state);
#endif
if ((gesture->state != ELM_GESTURE_STATE_UNDEFINED) &&
* we clear history immediately to be ready for input.
*
* @param obj The gesture-layer object.
+ * @return TRUE on event history_clear
*
* @ingroup Elm_Gesture_Layer
*/
-static void
+static Eina_Bool
_clear_if_finished(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ if (!wd) return EINA_FALSE;
int i;
/* Clear history if all we have aborted gestures */
Eina_Bool reset_s = EINA_TRUE, all_undefined = EINA_TRUE;
- for (i = ELM_GESTURE_FIRST ; i < ELM_GESTURE_LAST; i++)
+ for (i = ELM_GESTURE_FIRST; i < ELM_GESTURE_LAST; i++)
{ /* If no gesture started and all we have aborted gestures, reset all */
Gesture_Info *p = wd->gesture[i];
if ((p) && (p->state != ELM_GESTURE_STATE_UNDEFINED))
}
}
-// if ((!wd->touched) || (reset_s && !all_undefined))
- /* (!wd->touched && reset_s) - don't stop zoom with mouse-wheel */
- if (reset_s && (!eina_list_count(wd->touched) || !all_undefined))
- _event_history_clear(obj);
+ if (reset_s && (!all_undefined))
+ return _event_history_clear(obj);
+
+ return EINA_FALSE;
}
static Eina_Bool
* This happens when we need to reset our tests.
* for example when gesture is detected or all ABORTed. */
static void
-_dbl_click_test_reset(Gesture_Info *gesture)
+_tap_gestures_test_reset(Gesture_Info *gesture)
{
if (!gesture)
return;
Widget_Data *wd = elm_widget_data_get(gesture->obj);
- if (wd->dbl_timeout) ecore_timer_del(wd->dbl_timeout);
wd->dbl_timeout = NULL;
Eina_List *data;
Pointer_Event *pe;
memset(gesture->data, 0, sizeof(Taps_Type));
}
+/* All *test_reset() funcs are called to clear
+ * gesture intermediate data.
+ * This happens when we need to reset our tests.
+ * for example when gesture is detected or all ABORTed. */
+static void
+_n_long_tap_test_reset(Gesture_Info *gesture)
+{
+ if (!gesture)
+ return;
+
+ if (!gesture->data)
+ return;
+
+ Long_Tap_Type *st = gesture->data;
+ Eina_List *l;
+ Pointer_Event *p;
+ EINA_LIST_FOREACH(st->touched, l, p)
+ free(p);
+
+ eina_list_free(st->touched);
+ if (st->timeout) ecore_timer_del(st->timeout);
+ memset(gesture->data, 0, sizeof(Long_Tap_Type));
+}
+
static void
_momentum_test_reset(Gesture_Info *gesture)
{
Widget_Data *wd = elm_widget_data_get(gesture->obj);
Zoom_Type *st = gesture->data;
- Pointer_Event pe, pe1;
Evas_Modifier_Mask mask = evas_key_modifier_mask_get(
evas_object_evas_get(wd->target), "Control");
evas_object_key_ungrab(wd->target, "Control_L", mask, 0);
evas_object_key_ungrab(wd->target, "Control_R", mask, 0);
- pe.timestamp = pe1.timestamp = 0;
-
- if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
- &st->zoom_st))
- memcpy(&pe, &st->zoom_st, sizeof(Pointer_Event));
-
- if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
- &st->zoom_st1))
- memcpy(&pe1, &st->zoom_st1, sizeof(Pointer_Event));
-
memset(st, 0, sizeof(Zoom_Type));
-
- /* If user released one finger only, restore down-info */
- if (pe.timestamp && (!pe1.timestamp))
- memcpy(&st->zoom_st, &pe, sizeof(Pointer_Event));
-
- if (pe1.timestamp && (!pe.timestamp))
- memcpy(&st->zoom_st1, &pe1, sizeof(Pointer_Event));
-
st->zoom_distance_tolerance = wd->zoom_distance_tolerance;
st->info.zoom = 1.0;
}
Widget_Data *wd = elm_widget_data_get(gesture->obj);
Rotate_Type *st = gesture->data;
- Pointer_Event pe, pe1;
-
- pe.timestamp = pe1.timestamp = 0;
-
- if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
- &st->rotate_st))
- memcpy(&pe, &st->rotate_st, sizeof(Pointer_Event));
-
- if (eina_list_search_unsorted_list(wd->touched, device_is_touched,
- &st->rotate_st1))
- memcpy(&pe1, &st->rotate_st1, sizeof(Pointer_Event));
memset(st, 0, sizeof(Rotate_Type));
-
- /* If user released one finger only, restore down-info */
- if (pe.timestamp && (!pe1.timestamp))
- memcpy(&st->rotate_st, &pe, sizeof(Pointer_Event));
-
- if (pe1.timestamp && (!pe.timestamp))
- memcpy(&st->rotate_st1, &pe1, sizeof(Pointer_Event));
-
-
st->info.base_angle = ELM_GESTURE_NEGATIVE_ANGLE;
st->rotate_angular_tolerance = wd->rotate_angular_tolerance;
}
static int
device_in_pending_list(const void *data1, const void *data2)
{ /* Compare the two device numbers */
- return (((int) data1) - ((int) data2));
+ return (((intptr_t) data1) - ((intptr_t) data2));
}
/**
}
if (!eina_list_search_unsorted_list(list, device_in_pending_list,
- (void *) device))
+ (intptr_t*) device))
{
- return eina_list_append(list, (void *) device);
+ return eina_list_append(list, (intptr_t*) device);
}
return list;
}
return eina_list_search_unsorted_list(list, device_in_pending_list,
- (void *) device);
+ (intptr_t *) device);
}
/**
*
* @ingroup Elm_Gesture_Layer
*/
-static void
+static Eina_Bool
_event_history_clear(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ if (!wd) return EINA_FALSE;
int i;
Gesture_Info *p;
_reset_states(wd); /* we are ready to start testing for gestures again */
- /* Clear all gestures intermediate date */
- _dbl_click_test_reset(wd->gesture[ELM_GESTURE_N_TAPS]);
- _dbl_click_test_reset(wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS]);
- _dbl_click_test_reset(wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS]);
+ /* Clear all gestures intermediate data */
+ if (IS_TESTED(ELM_GESTURE_N_LONG_TAPS))
+ { /* We do not clear a long-tap gesture if fingers still on surface */
+ /* and gesture timer still pending to test gesture state */
+ Long_Tap_Type *st = wd->gesture[ELM_GESTURE_N_LONG_TAPS]->data;
+ if ((st) && /* st not allocated if clear occurs before 1st input */
+ ((!eina_list_count(st->touched)) || (!st->timeout)))
+ _n_long_tap_test_reset(wd->gesture[ELM_GESTURE_N_LONG_TAPS]);
+ }
+
+ if (wd->dbl_timeout)
+ {
+ ecore_timer_del(wd->dbl_timeout);
+ wd->dbl_timeout = NULL;
+ }
+
+ _tap_gestures_test_reset(wd->gesture[ELM_GESTURE_N_TAPS]);
+ _tap_gestures_test_reset(wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS]);
+ _tap_gestures_test_reset(wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS]);
_momentum_test_reset(wd->gesture[ELM_GESTURE_MOMENTUM]);
_line_test_reset(wd->gesture[ELM_GESTURE_N_LINES]);
_line_test_reset(wd->gesture[ELM_GESTURE_N_FLICKS]);
if (pending)
{
- wd->pending = eina_list_remove_list(wd->pending, pending);
- int device = ELM_MOUSE_DEVICE;
- if (wd->event_history_list->event_type == EVAS_CALLBACK_MULTI_UP)
- device = ((Evas_Event_Multi_Up *)
- (wd->event_history_list->event))->device;
+ wd->pending = eina_list_remove_list(wd->pending, pending);
}
else
- wd->pending = _add_device_pending(wd->pending,
- wd->event_history_list->event,
- wd->event_history_list->event_type);
+ {
+ wd->pending = _add_device_pending(wd->pending,
+ wd->event_history_list->event,
+ wd->event_history_list->event_type);
+ }
}
free(wd->event_history_list->event);
free(t);
}
_register_callbacks(obj);
+ return EINA_TRUE;
}
/**
static int
compare_pe_device(const void *data1, const void *data2)
-{ /* Compare coords of first item in list to cur coords */
- const Pointer_Event *pe1 = eina_list_data_get(eina_list_last(data1));
+{ /* Compare device of first item in list to our pe device */
+ const Pointer_Event *pe1 = eina_list_data_get(data1);
const Pointer_Event *pe2 = data2;
/* Only match if last was a down event */
/**
* @internal
*
- * when this timer expires we ABORT double click gesture.
+ * This function sets state a tap-gesture to END or ABORT
+ *
+ * @param data gesture info pointer
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static void
+_tap_gesture_finish(void *data)
+{ /* This function will test each tap gesture when timer expires */
+ Gesture_Info *gesture = data;
+ Elm_Gesture_State s = ELM_GESTURE_STATE_END;
+ /* Here we check if taps-gesture was completed successfuly */
+ /* Count how many taps were recieved on each device then */
+ /* determine if it matches n_taps_needed defined on START */
+ Taps_Type *st = gesture->data;
+ Eina_List *l;
+ Eina_List *pe_list;
+ EINA_LIST_FOREACH(st->l, l, pe_list)
+ {
+ if (eina_list_count(pe_list) != st->n_taps_needed)
+ { /* No match taps number on device, ABORT */
+ s = ELM_GESTURE_STATE_ABORT;
+ break;
+ }
+ }
+
+ st->info.n = eina_list_count(st->l);
+ _set_state(gesture, s, gesture->info, EINA_FALSE);
+ _tap_gestures_test_reset(gesture);
+}
+
+/**
+ * @internal
+ *
+ * when this timer expires we finish tap gestures.
*
* @param data The gesture-layer object.
* @return cancles callback for this timer.
* @ingroup Elm_Gesture_Layer
*/
static Eina_Bool
-_dbl_click_timeout(void *data)
+_multi_tap_timeout(void *data)
{
- Gesture_Info *gesture = data;
- Widget_Data *wd = elm_widget_data_get(gesture->obj);
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return EINA_FALSE;
+
+ if (IS_TESTED(ELM_GESTURE_N_TAPS))
+ _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TAPS]);
+
+ if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
+ _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_DOUBLE_TAPS]);
+ if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
+ _tap_gesture_finish(wd->gesture[ELM_GESTURE_N_TRIPLE_TAPS]);
+
+ _clear_if_finished(data);
wd->dbl_timeout = NULL;
- _set_state(gesture, ELM_GESTURE_STATE_ABORT,
- gesture->info, EINA_FALSE);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/**
+ * @internal
+ *
+ * when this timer expires we START long tap gesture
+ *
+ * @param data The gesture-layer object.
+ * @return cancles callback for this timer.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static Eina_Bool
+_long_tap_timeout(void *data)
+{
+ Gesture_Info *gesture = data;
+ Long_Tap_Type *st = gesture->data;
+ st->timeout = NULL;
+
+ _set_state(gesture, ELM_GESTURE_STATE_START,
+ gesture->data, EINA_FALSE);
- _dbl_click_test_reset(gesture);
- _clear_if_finished(gesture->obj);
return ECORE_CALLBACK_CANCEL;
}
+
/**
* @internal
*
- * This function checks all click/tap and double/triple taps
+ * This function checks if a tap gesture should start
*
- * @param obj The gesture-layer object.
+ * @param wd Gesture Layer Widget Data.
* @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.
- * @param g_type what Gesture we are testing.
- * @param taps How many click/taps we test for.
+ * @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 void
-_dbl_click_test(Evas_Object *obj, Pointer_Event *pe,
+static Eina_Bool
+_tap_gesture_start(Widget_Data *wd, Pointer_Event *pe,
void *event_info, Evas_Callback_Type event_type,
- Elm_Gesture_Types g_type, int taps)
-{ /* Here we fill Recent_Taps struct and fire-up click/tap timers */
- 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 */
-
- Gesture_Info *gesture = wd->gesture[g_type];
- if (!gesture ) return;
-
- if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- eina_list_count(wd->touched))
- return; /* user left a finger on device, do NOT start */
-
+ Gesture_Info *gesture, int taps)
+{ /* Here we fill Tap struct */
Taps_Type *st = gesture->data;
if (!st)
{ /* Allocated once on first time */
st = calloc(1, sizeof(Taps_Type));
gesture->data = st;
- _dbl_click_test_reset(gesture);
+ _tap_gestures_test_reset(gesture);
}
Eina_List *pe_list = NULL;
{
case EVAS_CALLBACK_MULTI_DOWN:
case EVAS_CALLBACK_MOUSE_DOWN:
+ /* Check if got tap on same cord was tapped before */
pe_list = eina_list_search_unsorted(st->l, compare_match_fingers, pe);
+
+ if ((!pe_list) &&
+ eina_list_search_unsorted(st->l, compare_pe_device, pe))
+ { /* This device was touched in other cord before completion */
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+
+ return EINA_FALSE;
+ }
+
pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
if ((pe->device == 0) && (eina_list_count(pe_list) == 1))
{ /* This is the first mouse down we got */
&st->info, EINA_FALSE);
consume_event(wd, event_info, event_type, ev_flag);
- /* To test dbl_click/dbl_tap */
- /* When this timer expires, gesture ABORTed if not completed */
- if (!wd->dbl_timeout && (taps > 1))
- wd->dbl_timeout = ecore_timer_add(0.4, _dbl_click_timeout,
- gesture);
+ st->n_taps_needed = taps * 2; /* count DOWN and UP */
- return;
+ return EINA_TRUE;
}
break;
+
case EVAS_CALLBACK_MULTI_UP:
case EVAS_CALLBACK_MOUSE_UP:
pe_list = eina_list_search_unsorted(st->l, compare_pe_device, pe);
if (!pe_list)
- return; /* Got only first mouse_down and mouse_up */
+ return EINA_FALSE;
pe_list = _record_pointer_event(st, pe_list, pe, wd, event_info, event_type);
-
- if (eina_list_count(pe_list) <= (unsigned int) ((taps - 1) * 2))
- return; /* Got only first mouse_down and mouse_up */
-
- /* Get first event in first list, this has to be Mouse Down event */
- pe_down = eina_list_data_get(pe_list);
-
- if (_inside(pe_down->x, pe_down->y, pe->x, pe->y))
- {
- st->count_ups++;
- }
- else
- {
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- break;
- }
-
- if (st->count_ups == eina_list_count(st->l))
- {
- /* Abort if we found a single click */
- if ((taps == 1) && (st->count_ups == 1))
- {
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- break;
- }
- st->info.n = st->count_ups;
- ev_flag =_set_state(gesture, ELM_GESTURE_STATE_END,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
-
- return;
- }
-
break;
case EVAS_CALLBACK_MULTI_MOVE:
pe_down = eina_list_data_get(pe_list);
if (!_inside(pe_down->x, pe_down->y, pe->x, pe->y))
{
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
}
}
break;
default:
- return;
+ 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);
+ }
+}
+
+/**
+ * @internal
+ *
+ * This function computes center-point for long-tap gesture
+ *
+ * @param st Long Tap gesture info pointer
+ * @param pe The recent input event as stored in pe struct.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static void
+_compute_taps_center(Long_Tap_Type *st,
+ Evas_Coord *x_out, Evas_Coord *y_out, Pointer_Event *pe)
+{
+ if(!eina_list_count(st->touched))
+ return;
+
+ Eina_List *l;
+ Pointer_Event *p;
+ Evas_Coord x = 0, y = 0;
+ EINA_LIST_FOREACH(st->touched, l, p)
+ { /* Accumulate all then take avarage */
+ if (p->device == pe->device)
+ { /* This will take care of values coming from MOVE event */
+ x += pe->x;
+ y += pe->y;
+ }
+ else
+ {
+ x += p->x;
+ y += p->y;
+ }
+ }
+
+ *x_out = x / eina_list_count(st->touched);
+ *y_out = y / eina_list_count(st->touched);
+}
+
+/**
+ * @internal
+ *
+ * This function checks N long-tap gesture.
+ *
+ * @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.
+ * @param g_type what Gesture we are testing.
+ * @param taps How many click/taps we test for.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+static void
+_n_long_tap_test(Evas_Object *obj, Pointer_Event *pe,
+ void *event_info, Evas_Callback_Type event_type,
+ Elm_Gesture_Types g_type)
+{ /* Here we fill Recent_Taps struct and fire-up click/tap timers */
+ 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 */
+ Gesture_Info *gesture = wd->gesture[g_type];
+ if (!gesture) return;
+
+ Long_Tap_Type *st = gesture->data;
+ if (!st)
+ { /* Allocated once on first time */
+ st = calloc(1, sizeof(Long_Tap_Type));
+ gesture->data = st;
+ _n_long_tap_test_reset(gesture);
+ }
+
+ Evas_Event_Flags ev_flag = EVAS_EVENT_FLAG_NONE;
+ switch (pe->event_type)
+ {
+ case EVAS_CALLBACK_MULTI_DOWN:
+ case EVAS_CALLBACK_MOUSE_DOWN:
+ st->touched = _add_touched_device(st->touched, pe);
+ st->info.n = eina_list_count(st->touched);
+ if (st->info.n > st->max_touched)
+ st->max_touched = st->info.n;
+ else
+ { /* User removed finger from touch, then put back - ABORT */
+ if ((gesture->state == ELM_GESTURE_STATE_START) ||
+ (gesture->state == ELM_GESTURE_STATE_MOVE))
+ {
+ ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ }
+
+ if ((pe->device == 0) && (eina_list_count(st->touched) == 1))
+ { /* This is the first mouse down we got */
+ st->info.timestamp = pe->timestamp;
+
+ /* To test long tap */
+ /* When this timer expires, gesture STARTED */
+ if (!st->timeout)
+ st->timeout = ecore_timer_add(wd->long_tap_start_timeout,
+ _long_tap_timeout, gesture);
+ }
+
+ consume_event(wd, event_info, event_type, ev_flag);
+ _compute_taps_center(st, &st->info.x, &st->info.y, pe);
+ st->center_x = st->info.x;
+ st->center_y = st->info.y;
+ break;
+
+ case EVAS_CALLBACK_MULTI_UP:
+ case EVAS_CALLBACK_MOUSE_UP:
+ st->touched = _remove_touched_device(st->touched, pe);
+ _compute_taps_center(st, &st->center_x, &st->center_y, pe);
+ if (st->info.n &&
+ ((gesture->state == ELM_GESTURE_STATE_START) ||
+ (gesture->state == ELM_GESTURE_STATE_MOVE)))
+ { /* Report END only for gesture that STARTed */
+ if (eina_list_count(st->touched) == 0)
+ { /* Report END only at last release event */
+ ev_flag =_set_state(gesture, ELM_GESTURE_STATE_END,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ }
+ else
+ { /* Stop test, user lifts finger before long-start */
+ if (st->timeout) ecore_timer_del(st->timeout);
+ st->timeout = NULL;
+ ev_flag =_set_state(gesture, ELM_GESTURE_STATE_ABORT,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+
+ break;
+
+ case EVAS_CALLBACK_MULTI_MOVE:
+ case EVAS_CALLBACK_MOUSE_MOVE:
+ if(st->info.n &&
+ ((gesture->state == ELM_GESTURE_STATE_START) ||
+ (gesture->state == ELM_GESTURE_STATE_MOVE)))
+ { /* Report MOVE only if STARTED */
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Elm_Gesture_State state_to_report = ELM_GESTURE_STATE_MOVE;
+
+ _compute_taps_center(st, &x, &y, pe);
+ /* ABORT if user moved fingers out of tap area */
+#if defined(DEBUG_GESTURE_LAYER)
+ printf("%s x,y=(%d,%d) st->info.x,st->info.y=(%d,%d)\n",__func__,x,y,st->info.x,st->info.y);
+#endif
+ if (!_inside(x, y, st->center_x, st->center_y))
+ state_to_report = ELM_GESTURE_STATE_ABORT;
+
+ /* Report MOVE if gesture started */
+ ev_flag = _set_state(gesture, state_to_report,
+ &st->info, EINA_TRUE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ break;
+
+ default:
+ return;
}
}
else
return 1;
}
-
/**
* @internal
*
Gesture_Info *gesture = wd->gesture[g_type];
if (!gesture ) return;
- if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- eina_list_count(wd->touched))
- return; /* user left a finger on device, do NOT start */
+ /* When continues enable = TRUE a gesture may START on MOVE event */
+ /* We don't allow this to happen with the if-statement below. */
+ /* When continues enable = FALSE a gesture may START on DOWN only */
+ /* Therefor it would NOT start on MOVE event. */
+ /* NOTE that touched list is updated AFTER this function returns */
+ /* so (count == 0) when we get here on first touch on surface. */
+ if ((wd->glayer_continues_enable) && (!eina_list_count(wd->touched)))
+ return; /* Got move on mouse-over move */
Momentum_Type *st = gesture->data;
+ Elm_Gesture_State state_to_report = ELM_GESTURE_STATE_MOVE;
if (!st)
{ /* Allocated once on first time */
st = calloc(1, sizeof(Momentum_Type));
if (!pe)
return;
+ /* First make avarage of all touched devices to determine center point */
+ Eina_List *l;
+ Pointer_Event *p;
+ Pointer_Event pe_local = *pe; /* Copy pe event info to local */
+ unsigned int cnt = 1; /* We start counter counting current pe event */
+ EINA_LIST_FOREACH(wd->touched, l, p)
+ if (p->device != pe_local.device)
+ {
+ pe_local.x += p->x;
+ pe_local.y += p->y;
+ cnt++;
+ }
+
+
+ /* Compute avarage to get center point */
+ pe_local.x /= cnt;
+ pe_local.y /= cnt;
+
+ /* If user added finger - reset gesture */
+ if ((st->info.n) && (st->info.n < cnt))
+ state_to_report = ELM_GESTURE_STATE_ABORT;
+
+ if (st->info.n < cnt)
+ st->info.n = cnt;
+
Evas_Event_Flags ev_flag = EVAS_EVENT_FLAG_NONE;
- switch (pe->event_type)
+ switch (event_type)
{
case EVAS_CALLBACK_MOUSE_DOWN:
- st->line_st.x = st->line_end.x = pe->x;
- st->line_st.y = st->line_end.y = pe->y;
- st->t_st_x = st->t_st_y = st->t_end = pe->timestamp;
- st->xdir = st->ydir = 0;
- st->info.x2 = st->info.x1 = pe->x;
- st->info.y2 = st->info.y1 = pe->y;
- st->info.tx = st->info.ty = pe->timestamp;
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- break;
-
- case EVAS_CALLBACK_MOUSE_UP:
- /* IGNORE if line info was cleared, like long press, move */
+ case EVAS_CALLBACK_MULTI_DOWN:
+ case EVAS_CALLBACK_MOUSE_MOVE:
+ case EVAS_CALLBACK_MULTI_MOVE:
if (!st->t_st_x)
- return;
-
- if ((pe->timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
{
- /* Too long of a wait, reset all values */
- st->line_st.x = pe->x;
- st->line_st.y = pe->y;
- st->t_st_y = st->t_st_x = pe->timestamp;
- st->xdir = st->ydir = 0;
- }
-
- st->info.x2 = pe->x;
- st->info.y2 = pe->y;
- st->line_end.x = pe->x;
- st->line_end.y = pe->y;
- st->t_end = pe->timestamp;
-
- _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe->x, pe->y,
- st->t_st_x, st->t_st_y, pe->timestamp);
+ if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
+ (event_type == EVAS_CALLBACK_MULTI_DOWN) ||
+ (wd->glayer_continues_enable)) /* start also on MOVE */
+ { /* We start on MOVE when cont-enabled only */
+ st->line_st.x = st->line_end.x = pe_local.x;
+ st->line_st.y = st->line_end.y = pe_local.y;
+ st->t_st_x = st->t_st_y = st->t_end = pe_local.timestamp;
+ st->xdir = st->ydir = 0;
+ st->info.x2 = st->info.x1 = pe_local.x;
+ st->info.y2 = st->info.y1 = pe_local.y;
+ st->info.tx = st->info.ty = pe_local.timestamp;
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_END, &st->info,
- EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
+ return;
+ }
- return;
- case EVAS_CALLBACK_MOUSE_MOVE:
- /* IGNORE if line info was cleared, like long press, move */
- if (!st->t_st_x)
- return;
+ /* ABORT gesture if got DOWN or MOVE event after UP+timeout */
+ if ((st->t_up) &&
+ ((st->t_up + ELM_GESTURE_MULTI_TIMEOUT) < pe_local.timestamp))
+ state_to_report = ELM_GESTURE_STATE_ABORT;
- if ((pe->timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
- {
- /* Too long of a wait, reset all values */
- st->line_st.x = pe->x;
- st->line_st.y = pe->y;
- st->t_st_y = st->t_st_x = pe->timestamp;
+ if ((pe_local.timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
+ { /* Too long of a wait, reset all values */
+ st->line_st.x = pe_local.x;
+ st->line_st.y = pe_local.y;
+ st->t_st_y = st->t_st_x = pe_local.timestamp;
st->info.tx = st->t_st_x;
st->info.ty = st->t_st_y;
st->xdir = st->ydir = 0;
else
{
int xdir, ydir;
- xdir = _get_direction(st->line_end.x, pe->x);
- ydir = _get_direction(st->line_end.y, pe->y);
+ xdir = _get_direction(st->line_st.x, pe_local.x);
+ ydir = _get_direction(st->line_st.y, pe_local.y);
if (!xdir || (xdir == (-st->xdir)))
{
st->line_st.x = st->line_end.x;
}
}
- st->info.x2 = st->line_end.x = pe->x;
- st->info.y2 = st->line_end.y = pe->y;
- st->t_end = pe->timestamp;
- _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe->x, pe->y,
- st->t_st_x, st->t_st_y, pe->timestamp);
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_MOVE, &st->info,
+ st->info.x2 = st->line_end.x = pe_local.x;
+ st->info.y2 = st->line_end.y = pe_local.y;
+ st->t_end = pe_local.timestamp;
+ _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe_local.x, pe_local.y,
+ st->t_st_x, st->t_st_y, pe_local.timestamp);
+ ev_flag = _set_state(gesture, state_to_report, &st->info,
EINA_TRUE);
consume_event(wd, event_info, event_type, ev_flag);
break;
+
+ case EVAS_CALLBACK_MOUSE_UP:
case EVAS_CALLBACK_MULTI_UP:
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT, &st->info,
+ st->t_up = pe_local.timestamp; /* Record recent up event time */
+ if ((cnt > 1) || /* Ignore if more fingers touch surface */
+ (!st->t_st_x)) /* IGNORE if info was cleared, long press,move */
+ return;
+
+ if ((pe_local.timestamp - ELM_GESTURE_MOMENTUM_TIMEOUT) > st->t_end)
+ { /* Too long of a wait, reset all values */
+ st->line_st.x = pe_local.x;
+ st->line_st.y = pe_local.y;
+ st->t_st_y = st->t_st_x = pe_local.timestamp;
+ st->xdir = st->ydir = 0;
+ }
+
+ st->info.x2 = pe_local.x;
+ st->info.y2 = pe_local.y;
+ st->line_end.x = pe_local.x;
+ st->line_end.y = pe_local.y;
+ st->t_end = pe_local.timestamp;
+
+ _set_momentum(&st->info, st->line_st.x, st->line_st.y, pe_local.x, pe_local.y,
+ st->t_st_x, st->t_st_y, pe_local.timestamp);
+
+ if ((fabs(st->info.mx) > ELM_GESTURE_MINIMUM_MOMENTUM) ||
+ (fabs(st->info.my) > ELM_GESTURE_MINIMUM_MOMENTUM))
+ state_to_report = ELM_GESTURE_STATE_END;
+ else
+ state_to_report = ELM_GESTURE_STATE_ABORT;
+
+ ev_flag = _set_state(gesture, state_to_report, &st->info,
EINA_FALSE);
consume_event(wd, event_info, event_type, ev_flag);
return;
*/
static Eina_Bool
_single_line_process(Elm_Gesture_Line_Info *info, Line_Data *st,
- Pointer_Event *pe)
+ Pointer_Event *pe, Evas_Callback_Type event_type)
{ /* Record events and set momentum for line pointed by st */
if (!pe)
return EINA_FALSE;
- switch (pe->event_type)
+ switch (event_type)
{
case EVAS_CALLBACK_MOUSE_DOWN:
+ case EVAS_CALLBACK_MOUSE_MOVE:
case EVAS_CALLBACK_MULTI_DOWN:
- st->line_st.x = pe->x;
- st->line_st.y = pe->y;
- st->t_st = pe->timestamp;
- st->device = pe->device;
- info->momentum.x1 = pe->x;
- info->momentum.y1 = pe->y;
- info->momentum.tx = pe->timestamp;
- info->momentum.ty = pe->timestamp;
-
- return EINA_TRUE;
+ case EVAS_CALLBACK_MULTI_MOVE:
+ if (!st->t_st)
+ { /* This happens only when line starts */
+ st->line_st.x = pe->x;
+ st->line_st.y = pe->y;
+ st->t_st = pe->timestamp;
+ st->device = pe->device;
+ info->momentum.x1 = pe->x;
+ info->momentum.y1 = pe->y;
+ info->momentum.tx = pe->timestamp;
+ info->momentum.ty = pe->timestamp;
+
+ return EINA_TRUE;
+ }
+
break;
case EVAS_CALLBACK_MOUSE_UP:
st->t_end = pe->timestamp;
break;
- case EVAS_CALLBACK_MOUSE_MOVE:
- case EVAS_CALLBACK_MULTI_MOVE:
- /* IGNORE if line info was cleared, like long press, move */
- if (!st->t_st)
- return EINA_FALSE;
-
- break;
default:
return EINA_FALSE;
}
Gesture_Info *gesture = wd->gesture[g_type];
if (!gesture ) return;
- if ((gesture->state == ELM_GESTURE_STATE_UNDEFINED) &&
- eina_list_count(wd->touched))
- return; /* user left a finger on device, do NOT start */
+ /* When continues enable = TRUE a gesture may START on MOVE event */
+ /* We don't allow this to happen with the if-statement below. */
+ /* When continues enable = FALSE a gesture may START on DOWN only */
+ /* Therefor it would NOT start on MOVE event. */
+ /* NOTE that touched list is updated AFTER this function returns */
+ /* so (count == 0) when we get here on first touch on surface. */
+ if ((wd->glayer_continues_enable) && (!eina_list_count(wd->touched)))
+ return; /* Got move on mouse-over move */
Line_Type *st = gesture->data;
if (!st)
Line_Data *line = NULL;
Eina_List *list = st->list;
- unsigned int i, cnt = eina_list_count(list);
+ unsigned cnt = eina_list_count(list);
if (cnt)
{ /* list is not empty, locate this device on list */
line = (Line_Data *) eina_list_search_unsorted(st->list,
compare_line_device, &pe->device);
-
- if (!line)
- { /* Try to locate an empty-node */
- for (i = 0; i < cnt; i++)
- {
- line = eina_list_nth(list, i);
- if (!line->t_st)
- break; /* Found a free node */
-
- line = NULL;
- }
- }
}
if (!line)
{ /* List is empty or device not found, new line-struct on START only */
if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
- (event_type == EVAS_CALLBACK_MULTI_DOWN))
- { /* Allocate new item on START */
+ (event_type == EVAS_CALLBACK_MULTI_DOWN) ||
+ ((wd->glayer_continues_enable) && /* START on MOVE also */
+ ((event_type == EVAS_CALLBACK_MOUSE_MOVE) ||
+ (event_type == EVAS_CALLBACK_MULTI_MOVE))))
+ { /* Allocate new item on START only */
line = calloc(1, sizeof(Line_Data));
_line_data_reset(line);
list = eina_list_append(list, line);
if (!line) /* This may happen on MOVE that comes before DOWN */
return; /* No line-struct to work with, can't continue testing */
-
- if (_single_line_process(&st->info, line, pe)) /* update st with input */
+ if (_single_line_process(&st->info, line, pe, event_type)) /* update st with input */
consume_event(wd, event_info, event_type, EVAS_EVENT_FLAG_NONE);
/* Get direction and magnitude of the line */
consume_event(wd, event_info, event_type, ev_flag);
return;
}
+
+ if (wd->glayer_continues_enable)
+ { /* We may finish line if momentum is zero */
+ /* This is for continues-gesture */
+ if ((!st->info.momentum.mx) && (!st->info.momentum.my))
+ { /* Finish line on zero momentum for continues gesture */
+ line->line_end.x = pe->x;
+ line->line_end.y = pe->y;
+ line->t_end = pe->timestamp;
+ }
+ }
}
else
{ /* Record the line angle as it broke minimum length for line */
st->info.angle = line->line_angle = angle;
}
+
if (line->t_end)
{
if (line->line_angle < 0.0)
}
}
- st->info.n = started;
+ st->info.momentum.n = started;
if (ended &&
case EVAS_CALLBACK_MOUSE_DOWN:
case EVAS_CALLBACK_MULTI_DOWN:
- if (started)
- {
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
- &st->info, EINA_TRUE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
-
- break;
-
case EVAS_CALLBACK_MOUSE_MOVE:
case EVAS_CALLBACK_MULTI_MOVE:
if (started)
{
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_MOVE,
- &st->info, EINA_TRUE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
+ if (wd->glayer_continues_enable && (started == ended))
+ { /* For continues gesture */
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_END,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ else
+ { /* When continues, may START on MOVE event too */
+ Elm_Gesture_State s = ELM_GESTURE_STATE_MOVE;
+ /* This happens when: on n > 1 lines then one finger up */
+ /* caused abort, then put finger down. */
+ /* This will stop line from starting again. */
+ /* Number of lines, MUST match touched-device in list */
+ if ((!wd->glayer_continues_enable) &&
+ (eina_list_count(st->list) < eina_list_count(wd->touched)))
+ s = ELM_GESTURE_STATE_ABORT;
+
+ if (gesture->state == ELM_GESTURE_STATE_UNDEFINED)
+ s = ELM_GESTURE_STATE_START;
+
+ ev_flag = _set_state(gesture, s, &st->info, EINA_TRUE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ }
break;
default:
}
#if defined(DEBUG_GESTURE_LAYER)
- printf("%s angle=<%d> low=<%d> high=<%d>\n", __func__, t, low, high);
+ printf("%s angle=<%f> low=<%f> high=<%f>\n", __func__, t, low, high);
#endif
if ((t < low) || (t > high))
{ /* This marks that roation action has started */
*
* @ingroup Elm_Gesture_Layer
*/
-/* FIXME change float to double */
static double
compute_zoom(Zoom_Type *st, Evas_Coord x1, Evas_Coord y1, unsigned int tm1,
Evas_Coord x2, Evas_Coord y2, unsigned int tm2, double zoom_finger_factor)
st->info.x = st->zoom_wheel->canvas.x;
st->info.y = st->zoom_wheel->canvas.y;
- if (st->zoom_wheel->z > 0) /* zoom in */
+ if (st->zoom_wheel->z < 0) /* zoom in */
st->info.zoom += (wd->zoom_finger_factor * wd->zoom_wheel_factor);
- if (st->zoom_wheel->z < 0) /* zoom out */
+ if (st->zoom_wheel->z > 0) /* zoom out */
st->info.zoom -= (wd->zoom_finger_factor * wd->zoom_wheel_factor);
if (st->info.zoom < 0.0)
_zoom_test_reset(gesture_zoom);
}
+
+ /* Start - new zoom testing, letting all fingers start */
Evas_Event_Flags ev_flag = EVAS_EVENT_FLAG_NONE;
switch (event_type)
{
- case EVAS_CALLBACK_MOUSE_DOWN:
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->zoom_st, pe, sizeof(Pointer_Event));
-
- break;
-
case EVAS_CALLBACK_MOUSE_MOVE:
- consume_event(wd, event_info, event_type, ev_flag);
- if (!st->zoom_st.timestamp)
- return; /* we got move event before down event.Ignore it */
+ case EVAS_CALLBACK_MULTI_MOVE:
+ /* if non-continues mode and gesture NOT started, ignore MOVE */
+ if ((!wd->glayer_continues_enable) &&
+ (!st->zoom_st.timestamp))
+ return;
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->zoom_mv, pe, sizeof(Pointer_Event));
+ case EVAS_CALLBACK_MOUSE_DOWN:
+ case EVAS_CALLBACK_MULTI_DOWN:
+ { /* Here we take care of zoom-start and zoom move */
+ Eina_List *l;
+ Pointer_Event *p;
+
+ if(eina_list_count(wd->touched) > 2)
+ { /* Process zoom only when 2 fingers on surface */
+ ev_flag = _set_state(gesture_zoom,
+ ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
- /* We match this point to previous multi-move or multi-down event */
- if (st->zoom_mv1.timestamp)
- {
- st->info.zoom = compute_zoom(st,
- st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
- st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
- wd->zoom_finger_factor);
- break;
- }
+ return;
+ }
- if (st->zoom_st1.timestamp)
- {
- st->info.zoom = compute_zoom(st,
- st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
- st->zoom_st1.x, st->zoom_st1.y, st->zoom_st1.timestamp,
- wd->zoom_finger_factor);
- break;
- }
+ if (!st->zoom_st.timestamp)
+ { /* Now scan touched-devices list and find other finger */
+ EINA_LIST_FOREACH(wd->touched, l, p)
+ { /* Device of other finger <> pe device */
+ if (p->device != pe->device)
+ break;
+ }
- break;
+ if (!p) /* Single finger on touch */
+ return;
- case EVAS_CALLBACK_MULTI_MOVE:
- if (!st->zoom_st1.timestamp)
- return; /* We get move event before down event.Ignore it */
+ /* Record down fingers */
+ consume_event(wd, event_info, event_type, ev_flag);
+ memcpy(&st->zoom_st, pe, sizeof(Pointer_Event));
+ memcpy(&st->zoom_st1, p, sizeof(Pointer_Event));
+
+ /* Set mv field as well to be ready for MOVE events */
+ memcpy(&st->zoom_mv, pe, sizeof(Pointer_Event));
+ memcpy(&st->zoom_mv1, p, sizeof(Pointer_Event));
+
+ /* Here we have zoom_st, zoom_st1 set, report START */
+ /* Set zoom-base after BOTH down events recorded */
+ /* Compute length of line between fingers zoom start */
+ st->info.zoom = 1.0;
+ st->zoom_base = get_finger_gap_length(st->zoom_st1.x,
+ st->zoom_st1.y, st->zoom_st.x, st->zoom_st.y,
+ &st->info.x, &st->info.y);
+
+ st->info.radius = st->zoom_base / 2;
+
+ if ((gesture_zoom->state != ELM_GESTURE_STATE_START) &&
+ (gesture_zoom->state != ELM_GESTURE_STATE_MOVE))
+ { /* zoom started with mouse-wheel, don't report twice */
+ ev_flag = _set_state(gesture_zoom,
+ ELM_GESTURE_STATE_START, &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
- consume_event(wd, event_info, event_type, ev_flag);
- if (st->zoom_mv1.timestamp)
- {
- if (st->zoom_mv1.device !=
- ((Evas_Event_Multi_Move *) event_info)->device)
- { /* A third finger on screen, abort zoom */
- ev_flag = _set_state(gesture_zoom,
- ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
+ return; /* Zoom started */
+ } /* End of ZOOM_START handling */
- return;
- }
- }
- memcpy(&st->zoom_mv1, pe, sizeof(Pointer_Event));
+ /* if we got here, we have (exacally) two fingers on surfce */
+ /* we also after START, report MOVE */
+ /* First detect which finger moved */
+ if (pe->device == st->zoom_mv.device)
+ memcpy(&st->zoom_mv, pe, sizeof(Pointer_Event));
+ else if (pe->device == st->zoom_mv1.device)
+ memcpy(&st->zoom_mv1, pe, sizeof(Pointer_Event));
- /* Match this point to previous mouse-move or mouse-down event */
- if (st->zoom_mv.timestamp)
- {
+ /* Compute change in zoom as fingers move */
st->info.zoom = compute_zoom(st,
- st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
st->zoom_mv.x, st->zoom_mv.y, st->zoom_mv.timestamp,
- wd->zoom_finger_factor);
- break;
- }
-
- if (st->zoom_st.timestamp)
- {
- st->info.zoom = compute_zoom(st,
st->zoom_mv1.x, st->zoom_mv1.y, st->zoom_mv1.timestamp,
- st->zoom_st.x, st->zoom_st.y, st->zoom_st.timestamp,
wd->zoom_finger_factor);
- break;
- }
- break;
+ if (!st->zoom_distance_tolerance)
+ { /* Zoom broke tolerance, report move */
+ double d = st->info.zoom - st->next_step;
+ if (d < 0.0)
+ d = (-d);
- case EVAS_CALLBACK_MULTI_DOWN:
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->zoom_st1, pe, sizeof(Pointer_Event));
- break;
+ if (d >= wd->zoom_step)
+ { /* Report move in steps */
+ st->next_step = st->info.zoom;
+
+ ev_flag = _set_state(gesture_zoom,
+ ELM_GESTURE_STATE_MOVE,
+ &st->info, EINA_TRUE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ } /* End of ZOOM_MOVE handling */
+
+ return;
+ }
case EVAS_CALLBACK_MOUSE_UP:
case EVAS_CALLBACK_MULTI_UP:
- /* Reset timestamp of finger-up.This is used later
- by _zoom_test_reset() to retain finger-down data */
- consume_event(wd, event_info, event_type, ev_flag);
- if (((st->zoom_wheel) || (st->zoom_base)) &&
- (st->zoom_distance_tolerance == 0))
- {
- ev_flag = _set_state(gesture_zoom, ELM_GESTURE_STATE_END,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
+ /* Reset timestamp of finger-up.This is used later
+ by _zoom_test_reset() to retain finger-down data */
+ consume_event(wd, event_info, event_type, ev_flag);
+ if (((st->zoom_wheel) || (st->zoom_base)) &&
+ (st->zoom_distance_tolerance == 0))
+ {
+ ev_flag = _set_state(gesture_zoom, ELM_GESTURE_STATE_END,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
- return;
- }
+ return;
+ }
- /* if we got here not a ZOOM */
- if (gesture_zoom->state != ELM_GESTURE_STATE_UNDEFINED)
- { /* Must be != undefined, if gesture started */
- ev_flag = _set_state(gesture_zoom,
- ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
+ /* if we got here not a ZOOM */
+ if (gesture_zoom->state != ELM_GESTURE_STATE_UNDEFINED)
+ { /* Must be != undefined, if gesture started */
+ ev_flag = _set_state(gesture_zoom,
+ ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
- _zoom_test_reset(gesture_zoom);
+ _zoom_test_reset(gesture_zoom);
- return;
+ return;
default:
- return;
- }
-
-
- if (!st->zoom_distance_tolerance)
- if ((event_type == EVAS_CALLBACK_MOUSE_MOVE) ||
- (event_type == EVAS_CALLBACK_MULTI_MOVE))
- {
- { /* Zoom broke tolerance, report move */
- double d = st->info.zoom - st->next_step;
- if (d < 0.0)
- d = (-d);
-
- if (d >= wd->zoom_step)
- { /* Report move in steps */
- st->next_step = st->info.zoom;
-
- ev_flag = _set_state(gesture_zoom, ELM_GESTURE_STATE_MOVE,
- &st->info, EINA_TRUE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
- }
-
- return;
+ return;
}
-
- if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
- (event_type == EVAS_CALLBACK_MULTI_DOWN))
- { /* report zoom start finger location is zoom-center temporarly */
- /* Zoom may have started with mouse-wheel, don't report START */
- if ((st->zoom_st.timestamp) && (st->zoom_st1.timestamp))
- { /* Set zoom-base after BOTH down events were recorded */
- /* Compute length of line between fingers on zoom start */
- st->info.zoom = 1.0;
- st->zoom_base = get_finger_gap_length(st->zoom_st1.x,
- st->zoom_st1.y, st->zoom_st.x, st->zoom_st.y,
- &st->info.x, &st->info.y);
-
- st->info.radius = st->zoom_base / 2;
-
- if ((gesture_zoom->state != ELM_GESTURE_STATE_START) &&
- (gesture_zoom->state != ELM_GESTURE_STATE_MOVE))
- { /* Report START only when two fingers touching */
- ev_flag = _set_state(gesture_zoom,
- ELM_GESTURE_STATE_START, &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
- }
- }
-
- return;
}
static void
}
Evas_Event_Flags ev_flag = EVAS_EVENT_FLAG_NONE;
-
switch (event_type)
{
- case EVAS_CALLBACK_MOUSE_DOWN:
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->rotate_st, pe, sizeof(Pointer_Event));
-
- break;
-
case EVAS_CALLBACK_MOUSE_MOVE:
- if (!st->rotate_st.timestamp)
- break; /* We got move event before down event.Ignore it */
-
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->rotate_mv, pe, sizeof(Pointer_Event));
-
- /* Match this point to previous multi-move or multi-down event */
- if (st->rotate_mv1.timestamp)
- { /* Compute rotation angle and report to user */
- _get_rotate_properties(st,
- st->rotate_mv.x, st->rotate_mv.y, st->rotate_mv.timestamp,
- st->rotate_mv1.x, st->rotate_mv1.y, st->rotate_mv1.timestamp,
- &st->info.angle);
- break;
- }
-
- if (st->rotate_st1.timestamp)
- { /* Compute rotation angle and report to user */
- _get_rotate_properties(st,
- st->rotate_mv.x, st->rotate_mv.y, st->rotate_mv.timestamp,
- st->rotate_st1.x, st->rotate_st1.y, st->rotate_st1.timestamp,
- &st->info.angle);
- break;
- }
-
- return;
-
case EVAS_CALLBACK_MULTI_MOVE:
- if (!st->rotate_st1.timestamp)
- break; /* We got move event before down event.Ignore it */
+ /* if non-continues mode and gesture NOT started, ignore MOVE */
+ if ((!wd->glayer_continues_enable) &&
+ (!st->rotate_st.timestamp))
+ return;
- consume_event(wd, event_info, event_type, ev_flag);
- if (st->rotate_mv1.timestamp)
- {
- if (st->rotate_mv1.device !=
- ((Evas_Event_Multi_Move *) event_info)->device)
- { /* A third finger on screen, abort rotate */
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_ABORT,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
+ case EVAS_CALLBACK_MOUSE_DOWN:
+ case EVAS_CALLBACK_MULTI_DOWN:
+ { /* Here we take care of rotate-start and rotate move */
+ Eina_List *l;
+ Pointer_Event *p;
+
+ if(eina_list_count(wd->touched) > 2)
+ { /* Process rotate only when 2 fingers on surface */
+ ev_flag = _set_state(gesture,
+ ELM_GESTURE_STATE_ABORT, &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
- return;
- }
- }
+ return;
+ }
- memcpy(&st->rotate_mv1, pe, sizeof(Pointer_Event));
+ if (!st->rotate_st.timestamp)
+ { /* Now scan touched-devices list and find other finger */
+ EINA_LIST_FOREACH(wd->touched, l, p)
+ { /* Device of other finger <> pe device */
+ if (p->device != pe->device)
+ break;
+ }
- /* Match this point to previous mouse-move or mouse-down event */
- if (st->rotate_mv.timestamp)
- { /* Compute rotation angle and report to user */
- _get_rotate_properties(st,
- st->rotate_mv.x, st->rotate_mv.y, st->rotate_mv.timestamp,
- st->rotate_mv1.x, st->rotate_mv1.y, st->rotate_mv1.timestamp,
- &st->info.angle);
- break;
- }
+ if (!p)
+ return; /* Single finger on touch */
- if (st->rotate_st.timestamp)
- { /* Compute rotation angle and report to user */
- _get_rotate_properties(st,
- st->rotate_st.x, st->rotate_st.y, st->rotate_st.timestamp,
- st->rotate_mv1.x, st->rotate_mv1.y, st->rotate_mv1.timestamp,
- &st->info.angle);
- break;
- }
+ /* Record down fingers */
+ consume_event(wd, event_info, event_type, ev_flag);
+ memcpy(&st->rotate_st, pe, sizeof(Pointer_Event));
+ memcpy(&st->rotate_st1, p, sizeof(Pointer_Event));
+
+ /* Set mv field as well to be ready for MOVE events */
+ memcpy(&st->rotate_mv, pe, sizeof(Pointer_Event));
+ memcpy(&st->rotate_mv1, p, sizeof(Pointer_Event));
+
+ /* Here we have rotate_st, rotate_st1 set, report START */
+ /* Set rotate-base after BOTH down events recorded */
+ /* Compute length of line between fingers rotate start */
+ _get_rotate_properties(st,
+ st->rotate_st.x, st->rotate_st.y,
+ st->rotate_st.timestamp,
+ st->rotate_st1.x, st->rotate_st1.y,
+ st->rotate_st1.timestamp, &st->info.base_angle);
+
+ ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
+ &st->info, EINA_FALSE);
+ consume_event(wd, event_info, event_type, ev_flag);
- return;
+ return; /* Rotate started */
+ } /* End of ROTATE_START handling */
+
+
+ /* if we got here, we have (exacally) two fingers on surfce */
+ /* we also after START, report MOVE */
+ /* First detect which finger moved */
+ if (pe->device == st->rotate_mv.device)
+ memcpy(&st->rotate_mv, pe, sizeof(Pointer_Event));
+ else if (pe->device == st->rotate_mv1.device)
+ memcpy(&st->rotate_mv1, pe, sizeof(Pointer_Event));
+
+ /* Compute change in rotate as fingers move */
+ _get_rotate_properties(st,
+ st->rotate_mv.x, st->rotate_mv.y,
+ st->rotate_mv.timestamp,
+ st->rotate_mv1.x, st->rotate_mv1.y,
+ st->rotate_mv1.timestamp, &st->info.angle);
+
+ if (rotation_broke_tolerance(st))
+ { /* Rotation broke tolerance, report move */
+ double d = st->info.angle - st->next_step;
+ if (d < 0.0)
+ d = (-d);
+
+ if (d >= wd->rotate_step)
+ { /* Report move in steps */
+ st->next_step = st->info.angle;
+
+ ev_flag = _set_state(gesture,
+ ELM_GESTURE_STATE_MOVE, &st->info, EINA_TRUE);
+ consume_event(wd, event_info, event_type, ev_flag);
+ }
+ } /* End of ROTATE_MOVE handling */
- case EVAS_CALLBACK_MULTI_DOWN:
- consume_event(wd, event_info, event_type, ev_flag);
- memcpy(&st->rotate_st1, pe, sizeof(Pointer_Event));
- _get_rotate_properties(st,
- st->rotate_st.x, st->rotate_st.y, st->rotate_st.timestamp,
- st->rotate_st1.x, st->rotate_st1.y, st->rotate_st1.timestamp,
- &st->info.angle);
- break;
+ return;
+ }
case EVAS_CALLBACK_MOUSE_UP:
case EVAS_CALLBACK_MULTI_UP:
return;
default:
- return;
- }
-
- if ((event_type == EVAS_CALLBACK_MOUSE_MOVE) ||
- (event_type == EVAS_CALLBACK_MULTI_MOVE))
- { /* Report MOVE or ABORT for *MOVE event */
- if (rotation_broke_tolerance(st))
- { /* Rotation broke tolerance, report move */
- double d = st->info.angle - st->next_step;
- if (d < 0.0)
- d = (-d);
-
- if (d >= wd->rotate_step)
- { /* Report move in steps */
- st->next_step = st->info.angle;
-
- ev_flag = _set_state(gesture,
- ELM_GESTURE_STATE_MOVE, &st->info, EINA_TRUE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
- }
-
- return;
- }
-
- if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
- (event_type == EVAS_CALLBACK_MULTI_DOWN))
- {
- if ((st->rotate_st.timestamp) && (st->rotate_st1.timestamp))
- { /* two-fingers on touch screen - report rotate start */
- /* Set base angle, then report start. */
- _get_rotate_properties(st,
- st->rotate_st.x, st->rotate_st.y, st->rotate_st.timestamp,
- st->rotate_st1.x, st->rotate_st1.y, st->rotate_st1.timestamp,
- &st->info.base_angle);
-
- ev_flag = _set_state(gesture, ELM_GESTURE_STATE_START,
- &st->info, EINA_FALSE);
- consume_event(wd, event_info, event_type, ev_flag);
- }
- }
-
- return;
+ return;
+ }
}
/**
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return EINA_FALSE;
+ memset(pe, '\0', sizeof(*pe));
switch (event_type)
{
case EVAS_CALLBACK_MOUSE_DOWN:
/**
* @internal
*
+ * This function restartes line, flick, zoom and rotate gestures
+ * when gesture-layer continues-gestures enabled.
+ * Example of continues-gesture:
+ * When doing a line, user stops moving finger but keeps fingers on touch.
+ * This will cause line-end, then as user continues moving his finger
+ * it re-starts line gesture.
+ * When continue mode is disabled, user has to lift finger from touch
+ * to end a gesture. Them touch-again to start a new one.
+ *
+ * @param data The gesture-layer object.
+ * @param wd gesture layer widget data.
+ * @param states_reset flag that marks gestures were reset in history clear.
+ *
+ * @ingroup Elm_Gesture_Layer
+ */
+void continues_gestures_restart(void *data, Eina_Bool states_reset)
+{
+ Widget_Data *wd = elm_widget_data_get(data);
+ if (!wd) return;
+
+ /* Run through events to restart gestures */
+ Gesture_Info *g;
+ Eina_Bool n_momentum, n_lines, n_flicks, zoom, rotate;
+ /* We turn-on flag for finished, aborted, not-started gestures */
+ g = wd->gesture[ELM_GESTURE_MOMENTUM];
+ n_momentum = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+ && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+ if (n_momentum)
+ {
+ _momentum_test_reset(wd->gesture[ELM_GESTURE_MOMENTUM]);
+ _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+ SET_TEST_BIT(g);
+ }
+
+ g = wd->gesture[ELM_GESTURE_N_LINES];
+ n_lines = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+ && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+ if (n_lines)
+ {
+ _line_test_reset(wd->gesture[ELM_GESTURE_N_LINES]);
+ _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+ SET_TEST_BIT(g);
+ }
+
+ g = wd->gesture[ELM_GESTURE_N_FLICKS];
+ n_flicks = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+ && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+ if (n_flicks)
+ {
+ _line_test_reset(wd->gesture[ELM_GESTURE_N_FLICKS]);
+ _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+ SET_TEST_BIT(g);
+ }
+
+ g = wd->gesture[ELM_GESTURE_ZOOM];
+ zoom = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+ && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+ if (zoom)
+ {
+ _zoom_test_reset(wd->gesture[ELM_GESTURE_ZOOM]);
+ _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+ SET_TEST_BIT(g);
+ }
+
+ g = wd->gesture[ELM_GESTURE_ROTATE];
+ rotate = (g) ? ((states_reset) | ((g->state != ELM_GESTURE_STATE_START)
+ && (g->state != ELM_GESTURE_STATE_MOVE))) : EINA_FALSE;
+ if (rotate)
+ {
+ _rotate_test_reset(wd->gesture[ELM_GESTURE_ROTATE]);
+ _set_state(g, ELM_GESTURE_STATE_UNDEFINED, NULL, EINA_FALSE);
+ SET_TEST_BIT(g);
+ }
+}
+
+/**
+ * @internal
+ *
* This function the core-function where input handling is done.
* Here we get user input and stream it to gesture testing.
* We notify user about any gestures with new state:
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
+#if defined(DEBUG_GESTURE_LAYER)
+ int i;
+ Gesture_Info *g;
+ printf("Gesture | State | is tested\n");
+ for(i = ELM_GESTURE_N_TAPS; i < ELM_GESTURE_LAST; i++)
+ {
+ g = wd->gesture[i];
+ if(g)
+ printf(" %d %d %d\n", i, g->state, g->test);
+ }
+#endif
+
/* Start testing candidate gesture from here */
if (_make_pointer_event(data, event_info, event_type, &_pe))
pe = &_pe;
- if (IS_TESTED(ELM_GESTURE_N_TAPS))
- _dbl_click_test(data, pe, event_info, event_type,
- ELM_GESTURE_N_TAPS, 1);
-
- if (IS_TESTED(ELM_GESTURE_N_DOUBLE_TAPS))
- _dbl_click_test(data, pe, event_info, event_type,
- ELM_GESTURE_N_DOUBLE_TAPS, 2);
+ if (IS_TESTED(ELM_GESTURE_N_LONG_TAPS))
+ _n_long_tap_test(data, pe, event_info, event_type,
+ ELM_GESTURE_N_LONG_TAPS);
- if (IS_TESTED(ELM_GESTURE_N_TRIPLE_TAPS))
- _dbl_click_test(data, pe, event_info, event_type,
- ELM_GESTURE_N_TRIPLE_TAPS, 3);
+ /* This takes care of single, double and tripple tap */
+ _tap_gestures_test(data, pe, event_info, event_type);
if (IS_TESTED(ELM_GESTURE_MOMENTUM))
_momentum_test(data, pe, event_info, event_type,
}
}
- /* we maintain list of touched devices*/
+ /* we maintain list of touched devices */
+ /* We also use move to track current device x.y pos */
if ((event_type == EVAS_CALLBACK_MOUSE_DOWN) ||
- (event_type == EVAS_CALLBACK_MULTI_DOWN))
+ (event_type == EVAS_CALLBACK_MULTI_DOWN) ||
+ (event_type == EVAS_CALLBACK_MOUSE_MOVE) ||
+ (event_type == EVAS_CALLBACK_MULTI_MOVE))
{
wd->touched = _add_touched_device(wd->touched, pe);
}
}
/* Report current states and clear history if needed */
- _clear_if_finished(data);
+ Eina_Bool states_reset = _clear_if_finished(data);
+ if (wd->glayer_continues_enable)
+ continues_gestures_restart(data, states_reset);
}
Elm_Gesture_State cb_type, Elm_Gesture_Event_Cb cb, void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Gesture_Info *p;
if (!wd) return;
if (!wd->gesture[idx])
wd->gesture[idx] = calloc(1, sizeof(Gesture_Info));
+ if (!wd->gesture[idx]) return;
- Gesture_Info *p = wd->gesture[idx];
+ p = wd->gesture[idx];
p->obj = obj;
p->g_type = idx;
p->fn[cb_type].cb = cb;
wd->rotate_angular_tolerance = _elm_config->glayer_rotate_angular_tolerance;
wd->line_angular_tolerance = _elm_config->glayer_line_angular_tolerance;
wd->flick_time_limit_ms = _elm_config->glayer_flick_time_limit_ms;
+ wd->long_tap_start_timeout = _elm_config->glayer_long_tap_start_timeout;
wd->repeat_events = EINA_TRUE;
+ wd->glayer_continues_enable = _elm_config->glayer_continues_enable;
#if defined(DEBUG_GESTURE_LAYER)
printf("size of Gestures = <%d>\n", sizeof(wd->gesture));
- printf("initial values:\n\tzoom_finger_factor=<%f>\n\tzoom_distance_tolerance=<%d>\n\tline_min_length=<%d>\n\tline_distance_tolerance=<%d>\n\tzoom_wheel_factor=<%f>\n\trotate_angular_tolerance=<%f>\n\twd->line_angular_tolerance=<%f>\n\twd->flick_time_limit_ms=<%d>\n", wd->zoom_finger_factor, wd->zoom_distance_tolerance, wd->line_min_length, wd->line_distance_tolerance, wd->zoom_wheel_factor, wd->rotate_angular_tolerance, wd->line_angular_tolerance, wd->flick_time_limit_ms);
+ printf("initial values:\n\tzoom_finger_factor=<%f>\n\tzoom_distance_tolerance=<%d>\n\tline_min_length=<%d>\n\tline_distance_tolerance=<%d>\n\tzoom_wheel_factor=<%f>\n\trotate_angular_tolerance=<%f>\n\twd->line_angular_tolerance=<%f>\n\twd->flick_time_limit_ms=<%d>\n\twd->long_tap_start_timeout=<%f>\n\twd->zoom_step=<%f>\n\twd->rotate_step=<%f>\n\twd->glayer_continues_enable=<%d>\n ", wd->zoom_finger_factor, wd->zoom_distance_tolerance, wd->line_min_length, wd->line_distance_tolerance, wd->zoom_wheel_factor, wd->rotate_angular_tolerance, wd->line_angular_tolerance, wd->flick_time_limit_ms, wd->long_tap_start_timeout, wd->zoom_step, wd->rotate_step, wd->glayer_continues_enable);
#endif
memset(wd->gesture, 0, sizeof(wd->gesture));