List: new signal: clicked,right with simple test

@feature
This commit is contained in:
Davide Andreoli 2014-12-29 12:17:41 +01:00
parent b4fe364f1b
commit 62fe9c4964
4 changed files with 36 additions and 1 deletions

View File

@ -261,6 +261,14 @@ scroll_bottom(void *data EINA_UNUSED,
printf("Bottom edge!\n");
}
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,
@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;