forked from enlightenment/efl
efl/gesture: move finger_size into private structs of recognizers
we must write these recognizers using publicly available apis to ensure that we don't accidentally start using private struct data this requires a lot of changes to properly manage the config value for finger size and update the recognizer data when changed (which external recognizers will need to monitor an event to achieve) and then also to change some recognizers so they don't use memset and unset the finger_size value ref TT8503 Reviewed-by: woochan lee <wc0917.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D11173
This commit is contained in:
parent
f2347354f3
commit
89e8cb912c
|
@ -2,6 +2,7 @@
|
||||||
#include "efl_canvas_gesture_private.h"
|
#include "efl_canvas_gesture_private.h"
|
||||||
|
|
||||||
#define MY_CLASS EFL_CANVAS_GESTURE_MANAGER_CLASS
|
#define MY_CLASS EFL_CANVAS_GESTURE_MANAGER_CLASS
|
||||||
|
#define EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE 10
|
||||||
|
|
||||||
typedef struct _Object_Gesture
|
typedef struct _Object_Gesture
|
||||||
{
|
{
|
||||||
|
@ -53,8 +54,52 @@ _hash_unref_cb(Eo *obj)
|
||||||
efl_unref(obj);
|
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 *
|
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));
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
||||||
|
|
||||||
|
@ -65,6 +110,8 @@ _efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_M
|
||||||
pd->m_gestures_to_delete = NULL;
|
pd->m_gestures_to_delete = NULL;
|
||||||
|
|
||||||
pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free));
|
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.
|
//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_TAP_CLASS, obj));
|
||||||
|
@ -74,6 +121,7 @@ _efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_M
|
||||||
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_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_FLICK_CLASS, obj));
|
||||||
efl_gesture_manager_recognizer_register(obj, efl_add(EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_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;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -85,27 +133,18 @@ _efl_canvas_gesture_manager_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Ges
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
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_value_copy(value, v);
|
||||||
eina_hash_add(pd->m_config, name, v);
|
eina_hash_add(pd->m_config, name, v);
|
||||||
|
if (!eina_streq(name, "glayer_tap_finger_size")) return;
|
||||||
//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);
|
eina_value_get(value, &finger_size);
|
||||||
|
_update_finger_sizes(pd, 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
|
|
|
@ -44,7 +44,6 @@ struct _Efl_Canvas_Gesture_Recognizer_Data
|
||||||
{
|
{
|
||||||
Eo *manager; // keeps a reference of the manager
|
Eo *manager; // keeps a reference of the manager
|
||||||
Eo *gesture;
|
Eo *gesture;
|
||||||
int finger_size;
|
|
||||||
Eina_Bool continues;
|
Eina_Bool continues;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,6 +52,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Tap_Data
|
||||||
Eo *target;
|
Eo *target;
|
||||||
Eo *gesture;
|
Eo *gesture;
|
||||||
Ecore_Timer *timeout;
|
Ecore_Timer *timeout;
|
||||||
|
int finger_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data
|
struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data
|
||||||
|
@ -63,6 +63,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Long_Tap_Data
|
||||||
Ecore_Timer *timeout;
|
Ecore_Timer *timeout;
|
||||||
double start_timeout;
|
double start_timeout;
|
||||||
Eina_Bool is_timeout;
|
Eina_Bool is_timeout;
|
||||||
|
int finger_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data
|
struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data
|
||||||
|
@ -74,6 +75,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Double_Tap_Data
|
||||||
double start_timeout;
|
double start_timeout;
|
||||||
Eina_Bool is_timeout;
|
Eina_Bool is_timeout;
|
||||||
int tap_count;
|
int tap_count;
|
||||||
|
int finger_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data
|
struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data
|
||||||
|
@ -85,6 +87,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Triple_Tap_Data
|
||||||
double start_timeout;
|
double start_timeout;
|
||||||
Eina_Bool is_timeout;
|
Eina_Bool is_timeout;
|
||||||
int tap_count;
|
int tap_count;
|
||||||
|
int finger_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data
|
struct _Efl_Canvas_Gesture_Recognizer_Momentum_Data
|
||||||
|
@ -105,6 +108,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Flick_Data
|
||||||
unsigned int t_end;
|
unsigned int t_end;
|
||||||
int line_length;
|
int line_length;
|
||||||
double line_angle;
|
double line_angle;
|
||||||
|
int finger_size;
|
||||||
Eina_Bool touched;
|
Eina_Bool touched;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,6 +127,7 @@ struct _Efl_Canvas_Gesture_Recognizer_Zoom_Data
|
||||||
double zoom_step;
|
double zoom_step;
|
||||||
double next_step;
|
double next_step;
|
||||||
Eina_Bool calc_temp;
|
Eina_Bool calc_temp;
|
||||||
|
int finger_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Canvas_Gesture_Data
|
struct _Efl_Canvas_Gesture_Data
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
|
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_CLASS
|
||||||
|
|
||||||
#define EFL_GESTURE_RECOGNIZER_TYPE_TAP_FINGER_SIZE 10
|
|
||||||
EOLIAN static Eina_Value *
|
EOLIAN static Eina_Value *
|
||||||
_efl_canvas_gesture_recognizer_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd, const char *name)
|
_efl_canvas_gesture_recognizer_config_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Recognizer_Data *pd, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -15,16 +14,6 @@ _efl_canvas_gesture_recognizer_reset(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Rec
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
int
|
||||||
_direction_get(Evas_Coord xx1, Evas_Coord xx2)
|
_direction_get(Evas_Coord xx1, Evas_Coord xx2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,4 @@ abstract @beta Efl.Canvas.Gesture_Recognizer extends Efl.Object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
implements {
|
|
||||||
Efl.Object.constructor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
Eina_Position2D pos;
|
Eina_Position2D pos;
|
||||||
Eina_Vector2 dist;
|
Eina_Vector2 dist;
|
||||||
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
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->target = watched;
|
||||||
pd->gesture = gesture;
|
pd->gesture = gesture;
|
||||||
|
@ -107,7 +106,7 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
length = fabs(dist.x) + fabs(dist.y);
|
||||||
|
|
||||||
if (length > rd->finger_size)
|
if (length > pd->finger_size)
|
||||||
{
|
{
|
||||||
if (pd->timeout)
|
if (pd->timeout)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +145,7 @@ _efl_canvas_gesture_recognizer_double_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
length = fabs(dist.x) + fabs(dist.y);
|
||||||
|
|
||||||
if (length <= rd->finger_size)
|
if (length <= pd->finger_size)
|
||||||
{
|
{
|
||||||
pd->tap_count++;
|
pd->tap_count++;
|
||||||
if (pd->tap_count == 1)
|
if (pd->tap_count == 1)
|
||||||
|
|
|
@ -10,6 +10,18 @@
|
||||||
#define RAD2DEG(x) ((x) * 57.295779513)
|
#define RAD2DEG(x) ((x) * 57.295779513)
|
||||||
#define DEG2RAD(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 *
|
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)
|
_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)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +248,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
if ((xdir[0] != xdir[1]) || (ydir[0] != ydir[1]))
|
if ((xdir[0] != xdir[1]) || (ydir[0] != ydir[1]))
|
||||||
{
|
{
|
||||||
rd->continues = EINA_FALSE;
|
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_CANCEL;
|
||||||
}
|
}
|
||||||
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
||||||
|
@ -258,7 +270,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
if (val) eina_value_get(val, &line_distance_tolerance);
|
if (val) eina_value_get(val, &line_distance_tolerance);
|
||||||
else line_distance_tolerance = 3.0;
|
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");
|
val = efl_gesture_recognizer_config_get(obj, "glayer_line_angular_tolerance");
|
||||||
if (val) eina_value_get(val, &line_angular_tolerance);
|
if (val) eina_value_get(val, &line_angular_tolerance);
|
||||||
|
@ -267,7 +279,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
if ((d > line_distance_tolerance) ||
|
if ((d > line_distance_tolerance) ||
|
||||||
(a > line_angular_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 (touch_up) rd->continues = EINA_FALSE;
|
||||||
|
|
||||||
|
@ -291,7 +303,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
if (val) eina_value_get(val, &line_min_length);
|
if (val) eina_value_get(val, &line_min_length);
|
||||||
else line_min_length = 1.0;
|
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)
|
if (pd->line_length >= line_min_length)
|
||||||
fd->angle = pd->line_angle = angle;
|
fd->angle = pd->line_angle = angle;
|
||||||
|
@ -301,7 +313,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
{
|
{
|
||||||
if (pd->line_angle < 0.0)
|
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 (touch_up) rd->continues = EINA_FALSE;
|
||||||
|
|
||||||
|
@ -324,7 +336,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
|
|
||||||
if ((tm_end - pd->t_st) > time_limit_ms)
|
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;
|
if (touch_up) rd->continues = EINA_FALSE;
|
||||||
|
|
||||||
|
@ -371,7 +383,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
|
|
||||||
efl_gesture_hotspot_set(gesture, efl_gesture_touch_cur_point_get(event));
|
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;
|
rd->continues = EINA_FALSE;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
|
||||||
Eina_Position2D pos;
|
Eina_Position2D pos;
|
||||||
Eina_Vector2 dist;
|
Eina_Vector2 dist;
|
||||||
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
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->target = watched;
|
||||||
pd->gesture = gesture;
|
pd->gesture = gesture;
|
||||||
|
@ -92,7 +91,7 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
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)
|
if (pd->timeout)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +122,7 @@ _efl_canvas_gesture_recognizer_long_tap_efl_canvas_gesture_recognizer_recognize(
|
||||||
{
|
{
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
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;
|
result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ _tap_timeout_cb(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Efl_Canvas_Gesture_Recognizer_Result
|
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_Recognizer_Tap_Data *pd,
|
||||||
Efl_Canvas_Gesture *gesture,
|
Efl_Canvas_Gesture *gesture,
|
||||||
Efl_Object *watched,
|
Efl_Object *watched,
|
||||||
|
@ -37,7 +37,6 @@ _efl_canvas_gesture_recognizer_tap_efl_canvas_gesture_recognizer_recognize(Eo *o
|
||||||
Eina_Position2D pos;
|
Eina_Position2D pos;
|
||||||
Eina_Vector2 dist;
|
Eina_Vector2 dist;
|
||||||
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
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->target = watched;
|
||||||
pd->gesture = gesture;
|
pd->gesture = gesture;
|
||||||
|
@ -86,7 +85,7 @@ new_tap:
|
||||||
{
|
{
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
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)
|
if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END)
|
||||||
result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
|
result = EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
|
||||||
|
|
|
@ -51,7 +51,6 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
Eina_Position2D pos;
|
Eina_Position2D pos;
|
||||||
Eina_Vector2 dist;
|
Eina_Vector2 dist;
|
||||||
Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
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->target = watched;
|
||||||
pd->gesture = gesture;
|
pd->gesture = gesture;
|
||||||
|
@ -107,7 +106,7 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
length = fabs(dist.x) + fabs(dist.y);
|
||||||
|
|
||||||
if (length > rd->finger_size)
|
if (length > pd->finger_size)
|
||||||
{
|
{
|
||||||
if (pd->timeout)
|
if (pd->timeout)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +145,7 @@ _efl_canvas_gesture_recognizer_triple_tap_efl_canvas_gesture_recognizer_recogniz
|
||||||
dist = efl_gesture_touch_distance(event, 0);
|
dist = efl_gesture_touch_distance(event, 0);
|
||||||
length = fabs(dist.x) + fabs(dist.y);
|
length = fabs(dist.x) + fabs(dist.y);
|
||||||
|
|
||||||
if (length <= rd->finger_size)
|
if (length <= pd->finger_size)
|
||||||
{
|
{
|
||||||
pd->tap_count++;
|
pd->tap_count++;
|
||||||
if (pd->tap_count < 3)
|
if (pd->tap_count < 3)
|
||||||
|
|
|
@ -2,6 +2,20 @@
|
||||||
|
|
||||||
#define MY_CLASS EFL_CANVAS_GESTURE_RECOGNIZER_ZOOM_CLASS
|
#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
|
static Evas_Coord
|
||||||
_finger_gap_length_get(Evas_Coord xx1,
|
_finger_gap_length_get(Evas_Coord xx1,
|
||||||
Evas_Coord yy1,
|
Evas_Coord yy1,
|
||||||
|
@ -157,7 +171,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
|
||||||
if (val) eina_value_get(val, &pd->zoom_distance_tolerance);
|
if (val) eina_value_get(val, &pd->zoom_distance_tolerance);
|
||||||
else pd->zoom_distance_tolerance = 1.0;
|
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))
|
switch (efl_gesture_touch_state_get(event))
|
||||||
|
@ -175,7 +189,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
|
||||||
{
|
{
|
||||||
if (td->touch_down > 2)
|
if (td->touch_down > 2)
|
||||||
{
|
{
|
||||||
memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Zoom_Data));
|
_reset_recognizer(pd);
|
||||||
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
||||||
}
|
}
|
||||||
if (td->touch_down == 1)
|
if (td->touch_down == 1)
|
||||||
|
@ -248,21 +262,21 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
|
||||||
{
|
{
|
||||||
rd->continues = EINA_FALSE;
|
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);
|
efl_gesture_manager_gesture_clean_up(rd->manager, watched, EFL_EVENT_GESTURE_ZOOM);
|
||||||
|
|
||||||
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
||||||
}
|
}
|
||||||
if ((pd->zoom_base) && (pd->zoom_distance_tolerance == 0))
|
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;
|
return EFL_GESTURE_RECOGNIZER_RESULT_FINISH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
|
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;
|
return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue