hermet pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=2ca3a0824756f5fff03b98f5100acc5b503698e6

commit 2ca3a0824756f5fff03b98f5100acc5b503698e6
Author: woochan lee <wc0917....@samsung.com>
Date:   Sat Mar 28 15:05:44 2015 +0900

    multibuttonentry: Add item long pressed callback.
    
    Summary: Add long pressed callback for application. test code changed to 
following this change as well.
    
    @feature
    
    Reviewers: seoz, woohyun, Jaehyun, Hermet
    
    Differential Revision: https://phab.enlightenment.org/D2103
    
    Conflicts:
    
        src/lib/elc_multibuttonentry.c
---
 src/bin/test_multibuttonentry.c       | 11 +++++++
 src/lib/elc_multibuttonentry.c        | 55 +++++++++++++++++++++++++++++++++++
 src/lib/elc_multibuttonentry.h        |  1 +
 src/lib/elm_multibuttonentry.eo       |  1 +
 src/lib/elm_widget_multibuttonentry.h |  7 ++++-
 5 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/src/bin/test_multibuttonentry.c b/src/bin/test_multibuttonentry.c
index 83da32e..04c6499 100644
--- a/src/bin/test_multibuttonentry.c
+++ b/src/bin/test_multibuttonentry.c
@@ -120,6 +120,16 @@ _shrink_state_changed_cb(void *data EINA_UNUSED,
    printf("contracted state changed! \n");
 }
 
+// "longpressed" smart callback
+static void
+_longpressed_cb(void *data EINA_UNUSED,
+                         Evas_Object *obj EINA_UNUSED,
+                         void *event_info EINA_UNUSED)
+{
+   printf("longpressed! \n");
+}
+
+
 // "item verified" confirm callback
 static Eina_Bool
 _item_filter_cb(Evas_Object *obj EINA_UNUSED,
@@ -198,6 +208,7 @@ _add_multibuttonentry(Evas_Object *parent)
    evas_object_smart_callback_add(mbe, "expanded", _expanded_cb, NULL);
    evas_object_smart_callback_add(mbe, "contracted", _contracted_cb, NULL);
    evas_object_smart_callback_add(mbe, "shrink,state,changed", 
_shrink_state_changed_cb, NULL);
+   evas_object_smart_callback_add(mbe, "longpressed", _longpressed_cb, NULL);
 
    btn = _format_change_btn_add(mbe);
    elm_object_part_content_set(parent, "box", btn);
diff --git a/src/lib/elc_multibuttonentry.c b/src/lib/elc_multibuttonentry.c
index f1e5e63..9e1a755 100644
--- a/src/lib/elc_multibuttonentry.c
+++ b/src/lib/elc_multibuttonentry.c
@@ -28,6 +28,7 @@ static const char SIG_UNFOCUSED[] = "unfocused";
 static const char SIG_EXPANDED[] = "expanded";
 static const char SIG_CONTRACTED[] = "contracted";
 static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
+static const char SIG_LONGPRESSED[] = "longpressed";
 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_ITEM_SELECTED, ""},
    {SIG_ITEM_ADDED, ""},
@@ -39,6 +40,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_EXPANDED, ""},
    {SIG_CONTRACTED, ""},
    {SIG_EXPAND_STATE_CHANGED, ""},
+   {SIG_LONGPRESSED, ""},
    {NULL, NULL}
 };
 
@@ -513,6 +515,51 @@ _on_item_deleted(void *data,
      }
 }
 
+static Eina_Bool
+_long_press_cb(void *data)
+{
+   Elm_Multibuttonentry_Item_Data *it = data;
+
+   ELM_MULTIBUTTONENTRY_DATA_GET(WIDGET(it), sd);
+
+   sd->longpress_timer = NULL;
+
+   evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, EO_OBJ(it));
+
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_mouse_down_cb(void  *data,
+               Evas *evas EINA_UNUSED,
+               Evas_Object *obj EINA_UNUSED,
+               void *event_info)
+{
+   Elm_Multibuttonentry_Item_Data *it = data;
+   Evas_Event_Mouse_Down *ev = event_info;
+
+   ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
+
+   if (ev->button != 1) return;
+
+   ecore_timer_del(sd->longpress_timer);
+   sd->longpress_timer = ecore_timer_add
+      (_elm_config->longpress_timeout, _long_press_cb, it);
+}
+
+static void
+_mouse_up_cb(void *data,
+             Evas *evas EINA_UNUSED,
+             Evas_Object *obj EINA_UNUSED,
+             void *event_info EINA_UNUSED)
+{
+   Elm_Multibuttonentry_Item_Data *it = data;
+
+   ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
+
+   ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
+}
+
 EOLIAN static void
 _elm_multibuttonentry_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
                                                        
Elm_Multibuttonentry_Item_Data *item,
@@ -664,6 +711,13 @@ _item_new(Elm_Multibuttonentry_Data *sd,
      (VIEW(item), "mouse,clicked,1", "*", _on_item_clicked, EO_OBJ(item));
    elm_layout_signal_callback_add
      (VIEW(item), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item));
+   evas_object_event_callback_add
+      (VIEW(item),
+       EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, item);
+   evas_object_event_callback_add
+      (VIEW(item),
+       EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, item);
+
    evas_object_show(VIEW(item));
 
    evas_object_smart_calculate(VIEW(item));
@@ -1466,6 +1520,7 @@ _elm_multibuttonentry_evas_object_smart_del(Eo *obj, 
Elm_Multibuttonentry_Data *
    evas_object_del(sd->label);
    evas_object_del(sd->guide_text);
    evas_object_del(sd->end);
+   ecore_timer_del(sd->longpress_timer);
 
    eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
 }
diff --git a/src/lib/elc_multibuttonentry.h b/src/lib/elc_multibuttonentry.h
index 32b590d..d0862fc 100644
--- a/src/lib/elc_multibuttonentry.h
+++ b/src/lib/elc_multibuttonentry.h
@@ -37,6 +37,7 @@
  * - @c "contracted" - when multi-button entry is contracted.
  * - @c "expand,state,changed" - when shrink mode state of
  *       multi-button entry is changed.
+ * - @c "longpressed" - when multi-button entry is pressed for a long time.
  *
  * Default text parts of the multi-button entry widget that you can use are:
  * @li "default" - A label of the multi-button entry
diff --git a/src/lib/elm_multibuttonentry.eo b/src/lib/elm_multibuttonentry.eo
index 43e13a9..6149ab6 100644
--- a/src/lib/elm_multibuttonentry.eo
+++ b/src/lib/elm_multibuttonentry.eo
@@ -280,6 +280,7 @@ class Elm_Multibuttonentry (Elm_Layout)
       expanded;
       contracted;
       expand,state,changed;
+      longpressed;
    }
 
 }
diff --git a/src/lib/elm_widget_multibuttonentry.h 
b/src/lib/elm_widget_multibuttonentry.h
index 41d1926..607e05c 100644
--- a/src/lib/elm_widget_multibuttonentry.h
+++ b/src/lib/elm_widget_multibuttonentry.h
@@ -105,14 +105,19 @@ struct _Elm_Multibuttonentry_Data
    Eina_Bool                           last_it_select : 1;
    Eina_Bool                           editable : 1;
    Eina_Bool                           focused : 1;
+
+   Ecore_Timer                         *longpress_timer;
 };
 
 /**
  * @}
  */
 
+#define ELM_MULTIBUTTONENTRY_DATA_GET(o, sd) \
+  Elm_Multibuttonentry_Data *sd = eo_data_scope_get(o, 
ELM_MULTIBUTTONENTRY_CLASS);
+
 #define ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(o, ptr) \
-  Elm_Multibuttonentry_Data *ptr = eo_data_scope_get(o, 
ELM_MULTIBUTTONENTRY_CLASS); \
+  ELM_MULTIBUTTONENTRY_DATA_GET(o, ptr);                \
   if (EINA_UNLIKELY(!ptr))                              \
     {                                                   \
        CRI("No widget data for object %p (%s)",         \

-- 


Reply via email to