forked from enlightenment/efl
elm_list & elm_genlist & elm_gengrid: fix the behavior of using the mouse.
Summary: Elementary widgets have different behavior of using the mouse, they need to be unified. - swipe : without checking on hold, just checking drag state. - longpress : after longpress, _item_unhighlight(), _item_unselect() are called. - select : when the mouse pointer leaves item area, _item_unhighlight(), _item_unselect() are called. First, apply this commit https://phab.enlightenment.org/D2550 Test Plan: elementary_test -> list Reviewers: seoz, Hermet, CHAN, woohyun, kimcinoo, jaehwan, SanghyeonLee, cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D2622 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
126fb18ca9
commit
da81eff897
|
@ -558,10 +558,11 @@ _item_mouse_move_cb(void *data,
|
||||||
Elm_Gen_Item *it = data;
|
Elm_Gen_Item *it = data;
|
||||||
Evas_Event_Mouse_Move *ev = event_info;
|
Evas_Event_Mouse_Move *ev = event_info;
|
||||||
Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
|
Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
|
||||||
Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
|
Evas_Coord minw = 0, minh = 0, x, y, w, h, dx, dy, adx, ady;
|
||||||
ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
|
ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
|
||||||
Elm_Object_Item *eo_it = EO_OBJ(it);
|
Elm_Object_Item *eo_it = EO_OBJ(it);
|
||||||
|
|
||||||
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
||||||
{
|
{
|
||||||
if (!sd->on_hold)
|
if (!sd->on_hold)
|
||||||
|
@ -574,6 +575,14 @@ _item_mouse_move_cb(void *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y) &&
|
||||||
|
!sd->reorder_it )
|
||||||
|
{
|
||||||
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
|
if (!sd->was_selected)
|
||||||
|
it->unsel_cb(it);
|
||||||
|
it->base->still_in = EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ((it->dragging) && (it->down))
|
if ((it->dragging) && (it->down))
|
||||||
{
|
{
|
||||||
|
@ -612,7 +621,6 @@ _item_mouse_move_cb(void *data,
|
||||||
if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
|
if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
|
||||||
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||||
|
|
||||||
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
|
|
||||||
x = ev->cur.canvas.x - x;
|
x = ev->cur.canvas.x - x;
|
||||||
y = ev->cur.canvas.y - y;
|
y = ev->cur.canvas.y - y;
|
||||||
dx = x - it->dx;
|
dx = x - it->dx;
|
||||||
|
@ -1052,12 +1060,7 @@ _item_mouse_up_cb(void *data,
|
||||||
evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, eo_it);
|
evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, eo_it);
|
||||||
dragged = EINA_TRUE;
|
dragged = EINA_TRUE;
|
||||||
}
|
}
|
||||||
if (sd->on_hold)
|
|
||||||
{
|
|
||||||
sd->longpressed = EINA_FALSE;
|
|
||||||
sd->on_hold = EINA_FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((sd->reorder_mode) &&
|
if ((sd->reorder_mode) &&
|
||||||
(sd->reorder_it))
|
(sd->reorder_it))
|
||||||
{
|
{
|
||||||
|
@ -1092,7 +1095,14 @@ _item_mouse_up_cb(void *data,
|
||||||
_elm_gengrid_item_unrealize(it, EINA_FALSE);
|
_elm_gengrid_item_unrealize(it, EINA_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get()) || (dragged)) return;
|
if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get())) return;
|
||||||
|
|
||||||
|
if (sd->on_hold || it->base->still_in)
|
||||||
|
{
|
||||||
|
sd->longpressed = EINA_FALSE;
|
||||||
|
sd->on_hold = EINA_FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (sd->focused_item != eo_it)
|
if (sd->focused_item != eo_it)
|
||||||
elm_object_item_focus_set(eo_it, EINA_TRUE);
|
elm_object_item_focus_set(eo_it, EINA_TRUE);
|
||||||
|
|
|
@ -3712,6 +3712,7 @@ _item_mouse_move_cb(void *data,
|
||||||
ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
|
ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
|
||||||
Elm_Object_Item *eo_it = EO_OBJ(it);
|
Elm_Object_Item *eo_it = EO_OBJ(it);
|
||||||
|
|
||||||
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
||||||
{
|
{
|
||||||
if (!sd->on_hold)
|
if (!sd->on_hold)
|
||||||
|
@ -3721,6 +3722,15 @@ _item_mouse_move_cb(void *data,
|
||||||
_item_unselect(it);
|
_item_unselect(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y) &&
|
||||||
|
!sd->reorder_it)
|
||||||
|
{
|
||||||
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
|
if ((!sd->wasselected) && (!it->flipped))
|
||||||
|
_item_unselect(it);
|
||||||
|
it->base->still_in = EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sd->multi_touched)
|
if (sd->multi_touched)
|
||||||
{
|
{
|
||||||
sd->cur_x = ev->cur.canvas.x;
|
sd->cur_x = ev->cur.canvas.x;
|
||||||
|
@ -3815,8 +3825,6 @@ _item_mouse_move_cb(void *data,
|
||||||
{
|
{
|
||||||
it->dragging = EINA_TRUE;
|
it->dragging = EINA_TRUE;
|
||||||
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
if (!sd->wasselected)
|
|
||||||
_item_unselect(it);
|
|
||||||
if (dy < 0)
|
if (dy < 0)
|
||||||
{
|
{
|
||||||
if (ady > adx)
|
if (ady > adx)
|
||||||
|
@ -4135,6 +4143,7 @@ _item_mouse_down_cb(void *data,
|
||||||
it->long_timer = NULL;
|
it->long_timer = NULL;
|
||||||
sd->swipe = EINA_FALSE;
|
sd->swipe = EINA_FALSE;
|
||||||
sd->movements = 0;
|
sd->movements = 0;
|
||||||
|
it->base->still_in = EINA_TRUE;
|
||||||
|
|
||||||
if (_is_no_select(it) ||
|
if (_is_no_select(it) ||
|
||||||
eo_do_ret((Eo *)eo_it, tmp, elm_wdg_item_disabled_get()))
|
eo_do_ret((Eo *)eo_it, tmp, elm_wdg_item_disabled_get()))
|
||||||
|
@ -4758,11 +4767,13 @@ _item_mouse_up_cb(void *data,
|
||||||
ELM_SAFE_FREE(sd->multi_timer, ecore_timer_del);
|
ELM_SAFE_FREE(sd->multi_timer, ecore_timer_del);
|
||||||
sd->multi_timeout = EINA_FALSE;
|
sd->multi_timeout = EINA_FALSE;
|
||||||
}
|
}
|
||||||
if (sd->on_hold)
|
if (sd->swipe)
|
||||||
{
|
{
|
||||||
if (sd->swipe) _swipe_do(it);
|
if (!sd->wasselected) _item_unselect(it);
|
||||||
|
_swipe_do(it);
|
||||||
sd->longpressed = EINA_FALSE;
|
sd->longpressed = EINA_FALSE;
|
||||||
sd->on_hold = EINA_FALSE;
|
sd->on_hold = EINA_FALSE;
|
||||||
|
sd->wasselected = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((sd->reorder_mode) && (sd->reorder_it))
|
if ((sd->reorder_mode) && (sd->reorder_it))
|
||||||
|
@ -4792,6 +4803,7 @@ _item_mouse_up_cb(void *data,
|
||||||
}
|
}
|
||||||
if (sd->longpressed)
|
if (sd->longpressed)
|
||||||
{
|
{
|
||||||
|
if (!sd->wasselected) _item_unselect(it);
|
||||||
sd->longpressed = EINA_FALSE;
|
sd->longpressed = EINA_FALSE;
|
||||||
sd->wasselected = EINA_FALSE;
|
sd->wasselected = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
|
@ -4807,10 +4819,10 @@ _item_mouse_up_cb(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_is_no_select(it) ||
|
if (_is_no_select(it) ||
|
||||||
(eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()) || (dragged)))
|
(eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || !it->base->still_in) return;
|
||||||
|
|
||||||
evas_object_ref(sd->obj);
|
evas_object_ref(sd->obj);
|
||||||
|
|
||||||
|
|
|
@ -1587,12 +1587,13 @@ _mouse_in_cb(void *data,
|
||||||
static void
|
static void
|
||||||
_mouse_move_cb(void *data,
|
_mouse_move_cb(void *data,
|
||||||
Evas *evas EINA_UNUSED,
|
Evas *evas EINA_UNUSED,
|
||||||
Evas_Object *o EINA_UNUSED,
|
Evas_Object *o,
|
||||||
void *event_info)
|
void *event_info)
|
||||||
{
|
{
|
||||||
Evas_Object *obj;
|
Evas_Object *obj;
|
||||||
Elm_List_Item_Data *it = data;
|
Elm_List_Item_Data *it = data;
|
||||||
Evas_Event_Mouse_Move *ev = event_info;
|
Evas_Event_Mouse_Move *ev = event_info;
|
||||||
|
Evas_Coord x = 0, y = 0, w = 0, h = 0;
|
||||||
|
|
||||||
ELM_LIST_ITEM_CHECK_OR_RETURN(it);
|
ELM_LIST_ITEM_CHECK_OR_RETURN(it);
|
||||||
obj = WIDGET(it);
|
obj = WIDGET(it);
|
||||||
|
@ -1601,6 +1602,8 @@ _mouse_move_cb(void *data,
|
||||||
evas_object_ref(obj);
|
evas_object_ref(obj);
|
||||||
_elm_list_walk(sd);
|
_elm_list_walk(sd);
|
||||||
|
|
||||||
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
||||||
|
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
||||||
{
|
{
|
||||||
if (!sd->on_hold)
|
if (!sd->on_hold)
|
||||||
|
@ -1613,18 +1616,35 @@ _mouse_move_cb(void *data,
|
||||||
_item_unselect(it);
|
_item_unselect(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sd->movements == ELM_LIST_SWIPE_MOVES) sd->swipe = EINA_TRUE;
|
}
|
||||||
else
|
else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y))
|
||||||
|
{
|
||||||
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
|
if (!sd->was_selected)
|
||||||
{
|
{
|
||||||
sd->history[sd->movements].x = ev->cur.canvas.x;
|
_item_unhighlight(it);
|
||||||
sd->history[sd->movements].y = ev->cur.canvas.y;
|
_item_unselect(it);
|
||||||
if (abs((sd->history[sd->movements].x - sd->history[0].x)) > 40)
|
|
||||||
sd->swipe = EINA_TRUE;
|
|
||||||
else
|
|
||||||
sd->movements++;
|
|
||||||
}
|
}
|
||||||
|
it->base->still_in = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sd->movements == ELM_LIST_SWIPE_MOVES)
|
||||||
|
{
|
||||||
|
sd->swipe = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sd->history[sd->movements].x = ev->cur.canvas.x;
|
||||||
|
sd->history[sd->movements].y = ev->cur.canvas.y;
|
||||||
|
if (abs((sd->history[sd->movements].x - sd->history[0].x)) > 40)
|
||||||
|
{
|
||||||
|
sd->swipe = EINA_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sd->movements++;
|
||||||
|
}
|
||||||
|
if (sd->swipe)
|
||||||
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
_elm_list_unwalk(obj, sd);
|
_elm_list_unwalk(obj, sd);
|
||||||
evas_object_unref(obj);
|
evas_object_unref(obj);
|
||||||
}
|
}
|
||||||
|
@ -1679,6 +1699,7 @@ _mouse_down_cb(void *data,
|
||||||
}
|
}
|
||||||
sd->swipe = EINA_FALSE;
|
sd->swipe = EINA_FALSE;
|
||||||
sd->movements = 0;
|
sd->movements = 0;
|
||||||
|
it->base->still_in = EINA_TRUE;
|
||||||
|
|
||||||
_elm_list_unwalk(obj, sd);
|
_elm_list_unwalk(obj, sd);
|
||||||
evas_object_unref(obj);
|
evas_object_unref(obj);
|
||||||
|
@ -1716,13 +1737,18 @@ _mouse_up_cb(void *data,
|
||||||
else sd->on_hold = EINA_FALSE;
|
else sd->on_hold = EINA_FALSE;
|
||||||
|
|
||||||
sd->mouse_down = EINA_FALSE;
|
sd->mouse_down = EINA_FALSE;
|
||||||
sd->longpressed = EINA_FALSE;
|
|
||||||
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
|
||||||
ELM_SAFE_FREE(it->swipe_timer, ecore_timer_del);
|
ELM_SAFE_FREE(it->swipe_timer, ecore_timer_del);
|
||||||
if (sd->on_hold)
|
if (sd->swipe)
|
||||||
{
|
{
|
||||||
if (sd->swipe) _swipe_do(data);
|
if (!sd->was_selected)
|
||||||
sd->on_hold = EINA_FALSE;
|
{
|
||||||
|
_item_unhighlight(it);
|
||||||
|
_item_unselect(it);
|
||||||
|
}
|
||||||
|
_swipe_do(data);
|
||||||
|
sd->swipe = EINA_FALSE;
|
||||||
|
sd->was_selected = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sd->longpressed)
|
if (sd->longpressed)
|
||||||
|
@ -1732,13 +1758,15 @@ _mouse_up_cb(void *data,
|
||||||
_item_unhighlight(it);
|
_item_unhighlight(it);
|
||||||
_item_unselect(it);
|
_item_unselect(it);
|
||||||
}
|
}
|
||||||
sd->was_selected = 0;
|
sd->longpressed = EINA_FALSE;
|
||||||
|
sd->was_selected = EINA_FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->base->disabled)
|
if (it->base->disabled)
|
||||||
return;
|
return;
|
||||||
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || !it->base->still_in)
|
||||||
|
return;
|
||||||
|
|
||||||
evas_object_ref(obj);
|
evas_object_ref(obj);
|
||||||
_elm_list_walk(sd);
|
_elm_list_walk(sd);
|
||||||
|
|
|
@ -621,6 +621,7 @@ struct _Elm_Widget_Item_Data
|
||||||
Eina_Bool disabled : 1;
|
Eina_Bool disabled : 1;
|
||||||
Eina_Bool on_deletion : 1;
|
Eina_Bool on_deletion : 1;
|
||||||
Eina_Bool on_translate : 1;
|
Eina_Bool on_translate : 1;
|
||||||
|
Eina_Bool still_in : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ELM_NEW(t) calloc(1, sizeof(t))
|
#define ELM_NEW(t) calloc(1, sizeof(t))
|
||||||
|
|
Loading…
Reference in New Issue