#include "efl_canvas_gesture_private.h"
#define MY_CLASS EFL_CANVAS_GESTURE_MANAGER_CLASS
+#define EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE 10
typedef struct _Object_Gesture
{
efl_unref(obj);
}
+/* updates the data for in-tree recognizers without needing to watch events */
+static void
+_update_finger_sizes(Efl_Canvas_Gesture_Manager_Data *pd, int finger_size)
+{
+ Efl_Canvas_Gesture_Recognizer *r;
+ Efl_Canvas_Gesture_Recognizer_Tap_Data *td;
+ Efl_Canvas_Gesture_Recognizer_Double_Tap_Data *dtd;
+ Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data *ttd;
+ Efl_Canvas_Gesture_Recognizer_Long_Tap_Data *ltd;
+ Efl_Canvas_Gesture_Recognizer_Flick_Data *fd;
+ Efl_Canvas_Gesture_Recognizer_Zoom_Data *zd;
+ const Efl_Event_Description *type;
+
+ type = EFL_EVENT_GESTURE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ td = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS);
+ td->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_DOUBLE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ dtd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_DOUBLE_TAP_CLASS);
+ dtd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_TRIPLE_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ ttd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_TRIPLE_TAP_CLASS);
+ ttd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_LONG_TAP;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ ltd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_LONG_TAP_CLASS);
+ ltd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_FLICK;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ fd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS);
+ fd->finger_size = finger_size;
+
+ type = EFL_EVENT_GESTURE_ZOOM;
+ r = eina_hash_find(pd->m_recognizers, &type);
+ zd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS);
+ zd->finger_size = finger_size;
+}
+
EOLIAN static Efl_Object *
-_efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd EINA_UNUSED)
+_efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->m_gestures_to_delete = NULL;
pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free));
+ /* this needs to always be present */
+ eina_hash_add(pd->m_config, "glayer_tap_finger_size", eina_value_int_new(EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE));
//Register all types of recognizers at very first time.
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_TAP_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_MOMENTUM_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_FLICK_CLASS, obj));
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS, obj));
+ _update_finger_sizes(pd, EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE);
return obj;
}
}
EOLIAN static void
-_efl_canvas_gesture_manager_config_set(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd, const char *name, Eina_Value *value)
+_efl_canvas_gesture_manager_config_set(Eo *obj, Efl_Canvas_Gesture_Manager_Data *pd, const char *name, Eina_Value *value)
{
- Eina_Value *v = eina_value_new(eina_value_type_get(value));
+ Eina_Value *v;
+ int finger_size;
+
+ EINA_SAFETY_ON_NULL_RETURN(name);
+ v = eina_value_new(eina_value_type_get(value));
eina_value_copy(value, v);
eina_hash_add(pd->m_config, name, v);
-
- //Sets recognizer class property.
- if (!strcmp(name, "glayer_tap_finger_size"))
- {
- int finger_size;
- Efl_Canvas_Gesture_Recognizer *r;
- Efl_Canvas_Gesture_Recognizer_Data *rd;
-
- eina_value_get(value, &finger_size);
-
- const Efl_Event_Description *type = EFL_EVENT_GESTURE_TAP;
-
- r = eina_hash_find(pd->m_recognizers, &type);
- rd = efl_data_scope_get(r, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
- rd->finger_size = finger_size;
- }
+ if (!eina_streq(name, "glayer_tap_finger_size")) return;
+ eina_value_get(value, &finger_size);
+ _update_finger_sizes(pd, finger_size);
}
EOLIAN static void
{
Eo *manager; // keeps a reference of the manager
Eo *gesture;
- int finger_size;
Eina_Bool continues;
};
Eo *target;
Eo *gesture;
Ecore_Timer *timeout;
+ int finger_size;
};
struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data
Ecore_Timer *timeout;
double start_timeout;
Eina_Bool is_timeout;
+ int finger_size;
};
struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data
double start_timeout;
Eina_Bool is_timeout;
int tap_count;
+ int finger_size;
};
struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data
double start_timeout;
Eina_Bool is_timeout;
int tap_count;
+ int finger_size;
};
struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data
unsigned int t_end;
int line_length;
double line_angle;
+ int finger_size;
Eina_Bool touched;
};
double zoom_step;
double next_step;
Eina_Bool calc_temp;
+ int finger_size;
};
struct _Efl_Canvas_Gesture_Data
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
-#define EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE 10
EOLIAN static Eina_Value *
_efl_canvas_gesture_recognizer_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd, const char *name)
{
{
}
-EOLIAN static Efl_Object *
-_efl_canvas_gesture_recognizer_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_Recognizer_Data *pd)
-{
- obj = efl_constructor(efl_super(obj, MY_CLASS));
-
- pd->finger_size = EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE;
-
- return obj;
-}
-
int
_direction_get(Evas_Coord xx1, Evas_Coord xx2)
{
}
}
}
- implements {
- Efl.Object.constructor;
- }
}
Eina_Position2D pos;
Eina_Vector2 dist;
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd->target = watched;
pd->gesture = gesture;
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length > rd->finger_size)
+ if (length > pd->finger_size)
{
if (pd->timeout)
{
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size)
+ if (length <= pd->finger_size)
{
pd->tap_count++;
if (pd->tap_count == 1)
#define RAD2DEG(x) ((x) * 57.295779513)
#define DEG2RAD(x) ((x) / 57.295779513)
+#define memset do not use memset to reset flick data, use _reset_recognizer
+
+static void
+_reset_recognizer(Efl_Canvas_Gesture_Recognizer_Flick_Data *pd)
+{
+ pd->st_line = EINA_POSITION2D(0, 0);
+ pd->t_st = pd->t_end = 0;
+ pd->line_length = 0;
+ pd->line_angle = -1;
+ pd->touched = EINA_FALSE;
+}
+
EOLIAN static Efl_Canvas_Gesture *
_efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_add(Eo *obj, Efl_Canvas_Gesture_Recognizer_Flick_Data *pd EINA_UNUSED, Efl_Object *target EINA_UNUSED)
{
if ((xdir[0] != xdir[1]) || (ydir[0] != ydir[1]))
{
rd->continues = EINA_FALSE;
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
}
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
if (val) eina_value_get(val, &line_distance_tolerance);
else line_distance_tolerance = 3.0;
- line_distance_tolerance *= rd->finger_size;
+ line_distance_tolerance *= pd->finger_size;
val = efl_gesture_recognizer_config_get(obj, "glayer_line_angular_tolerance");
if (val) eina_value_get(val, &line_angular_tolerance);
if ((d > line_distance_tolerance) ||
(a > line_angular_tolerance))
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
if (touch_up) rd->continues = EINA_FALSE;
if (val) eina_value_get(val, &line_min_length);
else line_min_length = 1.0;
- line_min_length *= rd->finger_size;
+ line_min_length *= pd->finger_size;
if (pd->line_length >= line_min_length)
fd->angle = pd->line_angle = angle;
{
if (pd->line_angle < 0.0)
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
if (touch_up) rd->continues = EINA_FALSE;
if ((tm_end - pd->t_st) > time_limit_ms)
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
if (touch_up) rd->continues = EINA_FALSE;
efl_gesture_hotspot_set(gesture, efl_gesture_touch_cur_point_get(event));
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Flick_Data));
+ _reset_recognizer(pd);
rd->continues = EINA_FALSE;
Eina_Position2D pos;
Eina_Vector2 dist;
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd->target = watched;
pd->gesture = gesture;
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if ((efl_gesture_touch_multi_touch_get(event)) || (length > rd->finger_size))
+ if ((efl_gesture_touch_multi_touch_get(event)) || (length > pd->finger_size))
{
if (pd->timeout)
{
{
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size && pd->is_timeout)
+ if (length <= pd->finger_size && pd->is_timeout)
{
result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
}
}
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
-_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj,
+_efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
Efl_Canvas_Gesture_Recognizer_Tap_Data *pd,
Efl_Canvas_Gesture *gesture,
Efl_Object *watched,
Eina_Position2D pos;
Eina_Vector2 dist;
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd->target = watched;
pd->gesture = gesture;
{
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size)
+ if (length <= pd->finger_size)
{
if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
Eina_Position2D pos;
Eina_Vector2 dist;
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
- Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
pd->target = watched;
pd->gesture = gesture;
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length > rd->finger_size)
+ if (length > pd->finger_size)
{
if (pd->timeout)
{
dist = efl_gesture_touch_distance(event, 0);
length = fabs(dist.x) + fabs(dist.y);
- if (length <= rd->finger_size)
+ if (length <= pd->finger_size)
{
pd->tap_count++;
if (pd->tap_count < 3)
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS
+static void
+_reset_recognizer(Efl_Canvas_Gesture_Recognizer_Zoom_Data *pd)
+{
+ memset(&pd->zoom_st, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_st1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_mv, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ memset(&pd->zoom_mv1, 0, sizeof(Efl_Gesture_Touch_Point_Data));
+ pd->zoom_base = 0;
+ pd->zoom_step = pd->next_step = pd->zoom_finger_factor = pd->zoom_distance_tolerance = 0;
+ pd->calc_temp = EINA_FALSE;
+}
+
+#define memset do not use memset to reset zoom data, use _reset_recognizer
+
static Evas_Coord
_finger_gap_length_get(Evas_Coord xx1,
Evas_Coord yy1,
if (val) eina_value_get(val, &pd->zoom_distance_tolerance);
else pd->zoom_distance_tolerance = 1.0;
- pd->zoom_distance_tolerance *= rd->finger_size;
+ pd->zoom_distance_tolerance *= pd->finger_size;
}
switch (efl_gesture_touch_state_get(event))
{
if (td->touch_down > 2)
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ _reset_recognizer(pd);
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
}
if (td->touch_down == 1)
{
rd->continues = EINA_FALSE;
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ _reset_recognizer(pd);
efl_gesture_manager_gesture_clean_up(rd->manager, watched, EFL_EVENT_GESTURE_ZOOM);
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
}
if ((pd->zoom_base) && (pd->zoom_distance_tolerance == 0))
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ _reset_recognizer(pd);
return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
}
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
{
- memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
+ _reset_recognizer(pd);
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
}