davemds pushed a commit to branch master.

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

commit dcb4f133ca7fa71d83f8c5eb40626279646cf733
Author: Dave Andreoli <[email protected]>
Date:   Mon Dec 29 12:17:41 2014 +0100

    List: new signal: clicked,right with simple test
    
    @feature
---
 src/bin/test_list.c       |  9 +++++++++
 src/lib/elm_list.c        | 24 ++++++++++++++++++++++++
 src/lib/elm_list.h        |  2 ++
 src/lib/elm_widget_list.h |  2 +-
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/bin/test_list.c b/src/bin/test_list.c
index e6a2967..12cea7c 100644
--- a/src/bin/test_list.c
+++ b/src/bin/test_list.c
@@ -262,6 +262,14 @@ scroll_bottom(void        *data EINA_UNUSED,
 }
 
 static void
+clicked_right(void        *data EINA_UNUSED,
+              Evas_Object *obj EINA_UNUSED,
+              void        *event_info EINA_UNUSED)
+{
+   printf("Clicked right!\n");
+}
+
+static void
 scroll_left(void        *data EINA_UNUSED,
             Evas_Object *obj EINA_UNUSED,
             void        *event_info EINA_UNUSED)
@@ -437,6 +445,7 @@ test_list(void        *data EINA_UNUSED,
 
    evas_object_smart_callback_add(li, "edge,top", scroll_top, NULL);
    evas_object_smart_callback_add(li, "edge,bottom", scroll_bottom, NULL);
+   evas_object_smart_callback_add(li, "clicked,right", clicked_right, NULL);
 }
 
 void
diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c
index c3db8e7..f9b405e 100644
--- a/src/lib/elm_list.c
+++ b/src/lib/elm_list.c
@@ -21,6 +21,7 @@
 
 static const char SIG_ACTIVATED[] = "activated";
 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
+static const char SIG_CLICKED_RIGHT[] = "clicked,right";
 static const char SIG_SELECTED[] = "selected";
 static const char SIG_UNSELECTED[] = "unselected";
 static const char SIG_LONGPRESSED[] = "longpressed";
@@ -36,6 +37,7 @@ static const char SIG_ITEM_UNFOCUSED[] = "item,unfocused";
 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {SIG_ACTIVATED, ""},
    {SIG_CLICKED_DOUBLE, ""},
+   {SIG_CLICKED_RIGHT, ""},
    {SIG_SELECTED, ""},
    {SIG_UNSELECTED, ""},
    {SIG_LONGPRESSED, ""},
@@ -1630,11 +1632,20 @@ _mouse_down_cb(void *data,
    Evas_Event_Mouse_Down *ev = event_info;
    Elm_List_Item_Data *it = data;
    Evas_Object *obj;
+   Evas_Coord x, y;
 
    ELM_LIST_ITEM_CHECK_OR_RETURN(it);
    obj = WIDGET(it);
    ELM_LIST_DATA_GET(obj, sd);
 
+   if (ev->button == 3)
+     {
+        evas_object_geometry_get(obj, &x, &y, NULL, NULL);
+        sd->dx = ev->canvas.x - x;
+        sd->dy = ev->canvas.y - y;
+        return;
+     }
+
    if (ev->button != 1) return;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
    else sd->on_hold = EINA_FALSE;
@@ -1676,11 +1687,24 @@ _mouse_up_cb(void *data,
    Evas_Object *obj;
    Elm_List_Item_Data *it = data;
    Evas_Event_Mouse_Up *ev = event_info;
+   Evas_Coord x, y, dx, dy;
 
    ELM_LIST_ITEM_CHECK_OR_RETURN(it);
    obj = WIDGET(it);
    ELM_LIST_DATA_GET(obj, sd);
 
+   if (ev->button == 3)
+     {
+        evas_object_geometry_get(obj, &x, &y, NULL, NULL);
+        dx = sd->dx - (ev->canvas.x - x);
+        dy = sd->dy - (ev->canvas.y - y);
+        if (dx < 0) dx = -dx;
+        if (dy < 0) dy = -dy;
+        if ((dx < 5) && (dy < 5))
+          evas_object_smart_callback_call(obj, SIG_CLICKED_RIGHT, EO_OBJ(it));
+        return;
+     }
+
    if (ev->button != 1) return;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
    else sd->on_hold = EINA_FALSE;
diff --git a/src/lib/elm_list.h b/src/lib/elm_list.h
index 141d3df..d961b45 100644
--- a/src/lib/elm_list.h
+++ b/src/lib/elm_list.h
@@ -29,6 +29,8 @@
  *   is the item that was activated.
  * - @c "clicked,double" - The user has double-clicked an item.
  *   The @p event_info parameter is the item that was double-clicked.
+ * - @c "clicked,right" - The user has right-clicked an item. The @p
+ *   event_info parameter is the item that was right-clicked. (since 1.13)
  * - @c "selected" - when the user selected an item
  * - @c "unselected" - when the user unselected an item
  * - @c "longpressed" - an item in the list is long-pressed
diff --git a/src/lib/elm_widget_list.h b/src/lib/elm_widget_list.h
index cfbdaeb..5feaa4e 100644
--- a/src/lib/elm_widget_list.h
+++ b/src/lib/elm_widget_list.h
@@ -36,7 +36,7 @@ struct _Elm_List_Data
    Elm_Object_Item                      *last_selected_item;
    Elm_Object_Item                      *focused_item; /**< a focused item by 
keypad arrow or mouse. This is set to NULL if widget looses focus. */
    Elm_Object_Item                      *last_focused_item; /**< This records 
the last focused item when widget looses focus. This is required to set the 
focus on last focused item when widgets gets focus. */
-   Evas_Coord                            minw[2], minh[2];
+   Evas_Coord                            minw[2], minh[2], dx, dy;
    Elm_Object_Select_Mode                select_mode;
    Elm_Object_Multi_Select_Mode          multi_select_mode; /**< select mode 
for multiple selection */
    int                                   movements;

-- 


Reply via email to