summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHosang Kim <hosang12.kim@samsung.com>2015-06-25 16:33:57 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-25 17:24:08 +0200
commit3373d6f12ac0eefbee34b1f0ecbd368e60ce6d65 (patch)
tree7de3e841251a7f5bf4a7993736d1d63e0046540f
parentb8959e778090547ef9df79601bef0c7cd9b3cd21 (diff)
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>
-rw-r--r--src/lib/elm_gengrid.c28
-rw-r--r--src/lib/elm_genlist.c24
-rw-r--r--src/lib/elm_list.c58
-rw-r--r--src/lib/elm_widget.h1
4 files changed, 81 insertions, 30 deletions
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 8d01e5ded..c996b63ed 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -558,10 +558,11 @@ _item_mouse_move_cb(void *data,
558 Elm_Gen_Item *it = data; 558 Elm_Gen_Item *it = data;
559 Evas_Event_Mouse_Move *ev = event_info; 559 Evas_Event_Mouse_Move *ev = event_info;
560 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y; 560 Evas_Coord ox, oy, ow, oh, it_scrl_x, it_scrl_y;
561 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady; 561 Evas_Coord minw = 0, minh = 0, x, y, w, h, dx, dy, adx, ady;
562 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd); 562 ELM_GENGRID_DATA_GET_FROM_ITEM(it, sd);
563 Elm_Object_Item *eo_it = EO_OBJ(it); 563 Elm_Object_Item *eo_it = EO_OBJ(it);
564 564
565 evas_object_geometry_get(obj, &x, &y, &w, &h);
565 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) 566 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
566 { 567 {
567 if (!sd->on_hold) 568 if (!sd->on_hold)
@@ -574,6 +575,14 @@ _item_mouse_move_cb(void *data,
574 } 575 }
575 } 576 }
576 } 577 }
578 else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y) &&
579 !sd->reorder_it )
580 {
581 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
582 if (!sd->was_selected)
583 it->unsel_cb(it);
584 it->base->still_in = EINA_FALSE;
585 }
577 586
578 if ((it->dragging) && (it->down)) 587 if ((it->dragging) && (it->down))
579 { 588 {
@@ -612,7 +621,6 @@ _item_mouse_move_cb(void *data,
612 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) 621 if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
613 elm_coords_finger_size_adjust(1, &minw, 1, &minh); 622 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
614 623
615 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
616 x = ev->cur.canvas.x - x; 624 x = ev->cur.canvas.x - x;
617 y = ev->cur.canvas.y - y; 625 y = ev->cur.canvas.y - y;
618 dx = x - it->dx; 626 dx = x - it->dx;
@@ -1052,12 +1060,7 @@ _item_mouse_up_cb(void *data,
1052 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, eo_it); 1060 evas_object_smart_callback_call(WIDGET(it), SIG_DRAG_STOP, eo_it);
1053 dragged = EINA_TRUE; 1061 dragged = EINA_TRUE;
1054 } 1062 }
1055 if (sd->on_hold) 1063
1056 {
1057 sd->longpressed = EINA_FALSE;
1058 sd->on_hold = EINA_FALSE;
1059 return;
1060 }
1061 if ((sd->reorder_mode) && 1064 if ((sd->reorder_mode) &&
1062 (sd->reorder_it)) 1065 (sd->reorder_it))
1063 { 1066 {
@@ -1092,7 +1095,14 @@ _item_mouse_up_cb(void *data,
1092 _elm_gengrid_item_unrealize(it, EINA_FALSE); 1095 _elm_gengrid_item_unrealize(it, EINA_FALSE);
1093 } 1096 }
1094 1097
1095 if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get()) || (dragged)) return; 1098 if (eo_do_ret(eo_it, tmp, elm_wdg_item_disabled_get())) return;
1099
1100 if (sd->on_hold || it->base->still_in)
1101 {
1102 sd->longpressed = EINA_FALSE;
1103 sd->on_hold = EINA_FALSE;
1104 return;
1105 }
1096 1106
1097 if (sd->focused_item != eo_it) 1107 if (sd->focused_item != eo_it)
1098 elm_object_item_focus_set(eo_it, EINA_TRUE); 1108 elm_object_item_focus_set(eo_it, EINA_TRUE);
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index a5d44ba5a..e2b0e5683 100644
--- a/src/lib/elm_genlist.c
+++ b/src/lib/elm_genlist.c
@@ -3712,6 +3712,7 @@ _item_mouse_move_cb(void *data,
3712 ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd); 3712 ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
3713 Elm_Object_Item *eo_it = EO_OBJ(it); 3713 Elm_Object_Item *eo_it = EO_OBJ(it);
3714 3714
3715 evas_object_geometry_get(obj, &x, &y, &w, &h);
3715 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) 3716 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
3716 { 3717 {
3717 if (!sd->on_hold) 3718 if (!sd->on_hold)
@@ -3721,6 +3722,15 @@ _item_mouse_move_cb(void *data,
3721 _item_unselect(it); 3722 _item_unselect(it);
3722 } 3723 }
3723 } 3724 }
3725 else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y) &&
3726 !sd->reorder_it)
3727 {
3728 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
3729 if ((!sd->wasselected) && (!it->flipped))
3730 _item_unselect(it);
3731 it->base->still_in = EINA_FALSE;
3732 }
3733
3724 if (sd->multi_touched) 3734 if (sd->multi_touched)
3725 { 3735 {
3726 sd->cur_x = ev->cur.canvas.x; 3736 sd->cur_x = ev->cur.canvas.x;
@@ -3815,8 +3825,6 @@ _item_mouse_move_cb(void *data,
3815 { 3825 {
3816 it->dragging = EINA_TRUE; 3826 it->dragging = EINA_TRUE;
3817 ELM_SAFE_FREE(it->long_timer, ecore_timer_del); 3827 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
3818 if (!sd->wasselected)
3819 _item_unselect(it);
3820 if (dy < 0) 3828 if (dy < 0)
3821 { 3829 {
3822 if (ady > adx) 3830 if (ady > adx)
@@ -4135,6 +4143,7 @@ _item_mouse_down_cb(void *data,
4135 it->long_timer = NULL; 4143 it->long_timer = NULL;
4136 sd->swipe = EINA_FALSE; 4144 sd->swipe = EINA_FALSE;
4137 sd->movements = 0; 4145 sd->movements = 0;
4146 it->base->still_in = EINA_TRUE;
4138 4147
4139 if (_is_no_select(it) || 4148 if (_is_no_select(it) ||
4140 eo_do_ret((Eo *)eo_it, tmp, elm_wdg_item_disabled_get())) 4149 eo_do_ret((Eo *)eo_it, tmp, elm_wdg_item_disabled_get()))
@@ -4758,11 +4767,13 @@ _item_mouse_up_cb(void *data,
4758 ELM_SAFE_FREE(sd->multi_timer, ecore_timer_del); 4767 ELM_SAFE_FREE(sd->multi_timer, ecore_timer_del);
4759 sd->multi_timeout = EINA_FALSE; 4768 sd->multi_timeout = EINA_FALSE;
4760 } 4769 }
4761 if (sd->on_hold) 4770 if (sd->swipe)
4762 { 4771 {
4763 if (sd->swipe) _swipe_do(it); 4772 if (!sd->wasselected) _item_unselect(it);
4773 _swipe_do(it);
4764 sd->longpressed = EINA_FALSE; 4774 sd->longpressed = EINA_FALSE;
4765 sd->on_hold = EINA_FALSE; 4775 sd->on_hold = EINA_FALSE;
4776 sd->wasselected = EINA_FALSE;
4766 return; 4777 return;
4767 } 4778 }
4768 if ((sd->reorder_mode) && (sd->reorder_it)) 4779 if ((sd->reorder_mode) && (sd->reorder_it))
@@ -4792,6 +4803,7 @@ _item_mouse_up_cb(void *data,
4792 } 4803 }
4793 if (sd->longpressed) 4804 if (sd->longpressed)
4794 { 4805 {
4806 if (!sd->wasselected) _item_unselect(it);
4795 sd->longpressed = EINA_FALSE; 4807 sd->longpressed = EINA_FALSE;
4796 sd->wasselected = EINA_FALSE; 4808 sd->wasselected = EINA_FALSE;
4797 return; 4809 return;
@@ -4807,10 +4819,10 @@ _item_mouse_up_cb(void *data,
4807 } 4819 }
4808 4820
4809 if (_is_no_select(it) || 4821 if (_is_no_select(it) ||
4810 (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get()) || (dragged))) 4822 (eo_do_ret(EO_OBJ(it), tmp, elm_wdg_item_disabled_get())))
4811 return; 4823 return;
4812 4824
4813 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 4825 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || !it->base->still_in) return;
4814 4826
4815 evas_object_ref(sd->obj); 4827 evas_object_ref(sd->obj);
4816 4828
diff --git a/src/lib/elm_list.c b/src/lib/elm_list.c
index 09aa88a49..596e51928 100644
--- a/src/lib/elm_list.c
+++ b/src/lib/elm_list.c
@@ -1587,12 +1587,13 @@ _mouse_in_cb(void *data,
1587static void 1587static void
1588_mouse_move_cb(void *data, 1588_mouse_move_cb(void *data,
1589 Evas *evas EINA_UNUSED, 1589 Evas *evas EINA_UNUSED,
1590 Evas_Object *o EINA_UNUSED, 1590 Evas_Object *o,
1591 void *event_info) 1591 void *event_info)
1592{ 1592{
1593 Evas_Object *obj; 1593 Evas_Object *obj;
1594 Elm_List_Item_Data *it = data; 1594 Elm_List_Item_Data *it = data;
1595 Evas_Event_Mouse_Move *ev = event_info; 1595 Evas_Event_Mouse_Move *ev = event_info;
1596 Evas_Coord x = 0, y = 0, w = 0, h = 0;
1596 1597
1597 ELM_LIST_ITEM_CHECK_OR_RETURN(it); 1598 ELM_LIST_ITEM_CHECK_OR_RETURN(it);
1598 obj = WIDGET(it); 1599 obj = WIDGET(it);
@@ -1601,6 +1602,8 @@ _mouse_move_cb(void *data,
1601 evas_object_ref(obj); 1602 evas_object_ref(obj);
1602 _elm_list_walk(sd); 1603 _elm_list_walk(sd);
1603 1604
1605 evas_object_geometry_get(o, &x, &y, &w, &h);
1606
1604 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) 1607 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1605 { 1608 {
1606 if (!sd->on_hold) 1609 if (!sd->on_hold)
@@ -1613,18 +1616,35 @@ _mouse_move_cb(void *data,
1613 _item_unselect(it); 1616 _item_unselect(it);
1614 } 1617 }
1615 } 1618 }
1616 if (sd->movements == ELM_LIST_SWIPE_MOVES) sd->swipe = EINA_TRUE; 1619 }
1617 else 1620 else if (ELM_RECTS_POINT_OUT(x, y, w, h, ev->cur.canvas.x, ev->cur.canvas.y))
1621 {
1622 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
1623 if (!sd->was_selected)
1618 { 1624 {
1619 sd->history[sd->movements].x = ev->cur.canvas.x; 1625 _item_unhighlight(it);
1620 sd->history[sd->movements].y = ev->cur.canvas.y; 1626 _item_unselect(it);
1621 if (abs((sd->history[sd->movements].x - sd->history[0].x)) > 40)
1622 sd->swipe = EINA_TRUE;
1623 else
1624 sd->movements++;
1625 } 1627 }
1628 it->base->still_in = EINA_FALSE;
1626 } 1629 }
1627 1630
1631 if (sd->movements == ELM_LIST_SWIPE_MOVES)
1632 {
1633 sd->swipe = EINA_TRUE;
1634 }
1635 else
1636 {
1637 sd->history[sd->movements].x = ev->cur.canvas.x;
1638 sd->history[sd->movements].y = ev->cur.canvas.y;
1639 if (abs((sd->history[sd->movements].x - sd->history[0].x)) > 40)
1640 {
1641 sd->swipe = EINA_TRUE;
1642 }
1643 else
1644 sd->movements++;
1645 }
1646 if (sd->swipe)
1647 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
1628 _elm_list_unwalk(obj, sd); 1648 _elm_list_unwalk(obj, sd);
1629 evas_object_unref(obj); 1649 evas_object_unref(obj);
1630} 1650}
@@ -1679,6 +1699,7 @@ _mouse_down_cb(void *data,
1679 } 1699 }
1680 sd->swipe = EINA_FALSE; 1700 sd->swipe = EINA_FALSE;
1681 sd->movements = 0; 1701 sd->movements = 0;
1702 it->base->still_in = EINA_TRUE;
1682 1703
1683 _elm_list_unwalk(obj, sd); 1704 _elm_list_unwalk(obj, sd);
1684 evas_object_unref(obj); 1705 evas_object_unref(obj);
@@ -1716,13 +1737,18 @@ _mouse_up_cb(void *data,
1716 else sd->on_hold = EINA_FALSE; 1737 else sd->on_hold = EINA_FALSE;
1717 1738
1718 sd->mouse_down = EINA_FALSE; 1739 sd->mouse_down = EINA_FALSE;
1719 sd->longpressed = EINA_FALSE;
1720 ELM_SAFE_FREE(it->long_timer, ecore_timer_del); 1740 ELM_SAFE_FREE(it->long_timer, ecore_timer_del);
1721 ELM_SAFE_FREE(it->swipe_timer, ecore_timer_del); 1741 ELM_SAFE_FREE(it->swipe_timer, ecore_timer_del);
1722 if (sd->on_hold) 1742 if (sd->swipe)
1723 { 1743 {
1724 if (sd->swipe) _swipe_do(data); 1744 if (!sd->was_selected)
1725 sd->on_hold = EINA_FALSE; 1745 {
1746 _item_unhighlight(it);
1747 _item_unselect(it);
1748 }
1749 _swipe_do(data);
1750 sd->swipe = EINA_FALSE;
1751 sd->was_selected = EINA_FALSE;
1726 return; 1752 return;
1727 } 1753 }
1728 if (sd->longpressed) 1754 if (sd->longpressed)
@@ -1732,13 +1758,15 @@ _mouse_up_cb(void *data,
1732 _item_unhighlight(it); 1758 _item_unhighlight(it);
1733 _item_unselect(it); 1759 _item_unselect(it);
1734 } 1760 }
1735 sd->was_selected = 0; 1761 sd->longpressed = EINA_FALSE;
1762 sd->was_selected = EINA_FALSE;
1736 return; 1763 return;
1737 } 1764 }
1738 1765
1739 if (it->base->disabled) 1766 if (it->base->disabled)
1740 return; 1767 return;
1741 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 1768 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD || !it->base->still_in)
1769 return;
1742 1770
1743 evas_object_ref(obj); 1771 evas_object_ref(obj);
1744 _elm_list_walk(sd); 1772 _elm_list_walk(sd);
diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h
index 5c173c684..a78a8e9bb 100644
--- a/src/lib/elm_widget.h
+++ b/src/lib/elm_widget.h
@@ -621,6 +621,7 @@ struct _Elm_Widget_Item_Data
621 Eina_Bool disabled : 1; 621 Eina_Bool disabled : 1;
622 Eina_Bool on_deletion : 1; 622 Eina_Bool on_deletion : 1;
623 Eina_Bool on_translate : 1; 623 Eina_Bool on_translate : 1;
624 Eina_Bool still_in : 1;
624}; 625};
625 626
626#define ELM_NEW(t) calloc(1, sizeof(t)) 627#define ELM_NEW(t) calloc(1, sizeof(t))