summaryrefslogtreecommitdiff
path: root/src/lib/evas/gesture/efl_gesture_recognizer_tap.c
blob: 7f8c2a893b8e4dd1dad8d43a580a9393f907859f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "efl_gesture_private.h"

#define MY_CLASS EFL_GESTURE_RECOGNIZER_TAP_CLASS

EOLIAN static Efl_Gesture *
_efl_gesture_recognizer_tap_efl_gesture_recognizer_create(Eo *obj, void *pd EINA_UNUSED,
                                                          Efl_Object *target EINA_UNUSED)
{
   return efl_add(EFL_GESTURE_TAP_CLASS, obj);
}

EOLIAN static Efl_Gesture_Recognizer_Result
_efl_gesture_recognizer_tap_efl_gesture_recognizer_recognize(Eo *obj EINA_UNUSED,
                                                             void *pd EINA_UNUSED,
                                                             Efl_Gesture *gesture, Efl_Object *watched EINA_UNUSED,
                                                             Efl_Gesture_Touch *event EINA_UNUSED)
{
   double length;
   Eina_Vector2 pos, dist;
   Efl_Gesture_Recognizer_Result result = EFL_GESTURE_CANCEL;

   switch (efl_gesture_touch_state_get(event))
     {
      case EFL_GESTURE_TOUCH_BEGIN:
        {
           pos = efl_gesture_touch_start_point_get(event);
           efl_gesture_hotspot_set(gesture, pos);
           result = EFL_GESTURE_TRIGGER;
           break;
        }
      case EFL_GESTURE_TOUCH_UPDATE:
      case EFL_GESTURE_TOUCH_END:
        {
           if (efl_gesture_state_get(gesture) != EFL_GESTURE_NONE &&
               !efl_gesture_touch_multi_touch_get(event))
             {
                dist = efl_gesture_touch_distance(event, 0);
                length = fabs(dist.x) + fabs(dist.y);
                if (length <= 50) // FIXME config!
                  {
                     if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_END)
                       result = EFL_GESTURE_FINISH;
                     else
                       result = EFL_GESTURE_TRIGGER;
                  }
             }
           break;
        }
      default:
        break;
     }
   return result;
}

#include "efl_gesture_recognizer_tap.eo.c"