Evas events: Add helper functions to read event info
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 31 May 2016 04:40:14 +0000 (13:40 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 31 May 2016 10:03:04 +0000 (19:03 +0900)
This adds simple helpers for double/triple click
and on_hold/on_scroll flags.

src/lib/evas/canvas/efl_pointer_event.c
src/lib/evas/canvas/efl_pointer_event.eo

index 5b11ce6..456ab6b 100644 (file)
@@ -338,4 +338,64 @@ _efl_pointer_event_efl_input_state_lock_enabled_get(Eo *obj EINA_UNUSED, Efl_Poi
    return evas_key_lock_is_set(pd->locks, name);
 }
 
+EOLIAN static Eina_Bool
+_efl_pointer_event_double_click_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Eina_Bool val)
+{
+   if (val)
+     pd->button_flags |= EFL_POINTER_BUTTON_FLAGS_DOUBLE_CLICK;
+   else
+     pd->button_flags &= ~EFL_POINTER_BUTTON_FLAGS_DOUBLE_CLICK;
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_double_click_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return !!(pd->button_flags & EFL_POINTER_BUTTON_FLAGS_DOUBLE_CLICK);
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_triple_click_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Eina_Bool val)
+{
+   if (val)
+     pd->button_flags |= EFL_POINTER_BUTTON_FLAGS_TRIPLE_CLICK;
+   else
+     pd->button_flags &= ~EFL_POINTER_BUTTON_FLAGS_TRIPLE_CLICK;
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_triple_click_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return !!(pd->button_flags & EFL_POINTER_BUTTON_FLAGS_TRIPLE_CLICK);
+}
+
+EOLIAN static void
+_efl_pointer_event_on_hold_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Eina_Bool val)
+{
+   if (val)
+     pd->event_flags |= EFL_POINTER_EVENT_FLAGS_ON_HOLD;
+   else
+     pd->event_flags &= ~EFL_POINTER_EVENT_FLAGS_ON_HOLD;
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_on_hold_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return !!(pd->event_flags & EFL_POINTER_EVENT_FLAGS_ON_HOLD);
+}
+
+EOLIAN static void
+_efl_pointer_event_on_scroll_set(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd, Eina_Bool val)
+{
+   if (val)
+     pd->event_flags |= EFL_POINTER_EVENT_FLAGS_ON_SCROLL;
+   else
+     pd->event_flags &= ~EFL_POINTER_EVENT_FLAGS_ON_SCROLL;
+}
+
+EOLIAN static Eina_Bool
+_efl_pointer_event_on_scroll_get(Eo *obj EINA_UNUSED, Efl_Pointer_Event_Data *pd)
+{
+   return !!(pd->event_flags & EFL_POINTER_EVENT_FLAGS_ON_SCROLL);
+}
+
 #include "efl_pointer_event.eo.c"
index 04531db..c7291a7 100644 (file)
@@ -97,19 +97,48 @@ class Efl.Pointer.Event (Eo.Base, Efl.Event, Efl.Input.State)
             src: Eo.Base; [[Source object: $Efl.Gfx]]
          }
       }
-      /* FIXME: why not double_click() and triple_click() */
       @property button_flags {
          [[Double or triple click information.]]
          values {
             flags: Efl.Pointer.Button_Flags;
          }
       }
+      @property double_click {
+         [[$true if @.button_flags indicates a double click (2nd press).
+
+           This is just a helper function around @.button_flags.
+         ]]
+         values {
+            val: bool;
+         }
+      }
+      @property triple_click {
+         [[$true if @.button_flags indicates a triple click (3rd press).
+
+           This is just a helper function around @.button_flags.
+         ]]
+         values {
+            val: bool;
+         }
+      }
       @property event_flags {
          [[Extra flags for this event, may be changed by the user.]]
          values {
             flags: Efl.Pointer.Event_Flags;
          }
       }
+      @property on_hold {
+         [[$true if @.event_flags indicates the event is on hold.]]
+         values {
+            val: bool;
+         }
+      }
+      @property on_scroll {
+         [[$true if @.event_flags indicates the event happened while scrolling.]]
+         values {
+            val: bool;
+         }
+      }
       @property wheel_direction {
          values {
             dir: Efl.Orient; [[Horizontal or Vertical only.]]