From d3deb1e6a74e9ab61b6ed8bb5b440c6988621a01 Mon Sep 17 00:00:00 2001 From: Subodh Kumar Date: Thu, 14 Jan 2016 16:05:08 +0000 Subject: [PATCH] Elm entry: Fix selection using handlers. Summary: Fix item selection using selection handler In case of selection using handler, there is a problem in case the entry has the item, mouse down over handler consider the current down coordinate to start selection and it becomes very difficult to select in the situation shown in the test plan. So I consider the next/previous line geometry to fix it. @fix Test Plan: 1.Enable selection handler 2. Have a look at the setup in the attached image {F27396} 3. Start selecting from last item and extent to cover the last text. 4.Observe that its impossible to select the last text until you move mouse out of the window So, in mobile device its almost impossible to select using handlers in this situation. Please use the attached application to test it. {F27402} Reviewers: thiepha, herdsman, tasn Reviewed By: tasn Subscribers: shilpasingh Differential Revision: https://phab.enlightenment.org/D3479 --- legacy/elementary/src/lib/elm_entry.c | 65 +++++++++++++-------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/legacy/elementary/src/lib/elm_entry.c b/legacy/elementary/src/lib/elm_entry.c index 226f5a59ea..1192f7dd29 100644 --- a/legacy/elementary/src/lib/elm_entry.c +++ b/legacy/elementary/src/lib/elm_entry.c @@ -3278,6 +3278,36 @@ _resize_cb(void *data, _elm_entry_resize_internal(data); } +static void +_selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler, Evas_Coord canvasx, Evas_Coord canvasy) +{ + Evas_Coord ex, ey; + Evas_Coord cx, cy, cw, ch; + Evas_Coord hh; + + ELM_ENTRY_DATA_GET(obj, sd); + + evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); + edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", + &cx, &cy, &cw, &ch); + edje_object_size_min_calc(handler, NULL, &hh); + + sd->ox = canvasx - (ex + cx + (cw / 2)); + if (ch > hh) + sd->oy = canvasy - (ey + cy + ch); + else + sd->oy = canvasy - (ey + cy + (ch / 2)); + + ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); + sd->long_pressed = EINA_FALSE; + if (_elm_config->magnifier_enable) + { + _magnifier_create(obj); + _magnifier_show(obj); + _magnifier_move(obj, ex + cx, ey + cy + (ch / 2)); + } +} + static void _start_handler_mouse_down_cb(void *data, Evas *e EINA_UNUSED, @@ -3287,8 +3317,6 @@ _start_handler_mouse_down_cb(void *data, ELM_ENTRY_DATA_GET(data, sd); Evas_Event_Mouse_Down *ev = event_info; - Evas_Coord ex, ey; - Evas_Coord cx, cy, cw, ch; int start_pos, end_pos, main_pos, pos; sd->start_handler_down = EINA_TRUE; @@ -3311,20 +3339,7 @@ _start_handler_mouse_down_cb(void *data, if (pos != main_pos) edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, pos); - edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", - &cx, &cy, &cw, &ch); - evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); - sd->ox = ev->canvas.x - (ex + cx + (cw / 2)); - sd->oy = ev->canvas.y - (ey + cy + (ch / 2)); - - ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); - sd->long_pressed = EINA_FALSE; - if (_elm_config->magnifier_enable) - { - _magnifier_create(data); - _magnifier_show(data); - _magnifier_move(data, ex + cx, ey + cy + (ch / 2)); - } + _selection_handlers_offset_calc(data, sd->start_handler, ev->canvas.x, ev->canvas.y); } static void @@ -3388,8 +3403,6 @@ _end_handler_mouse_down_cb(void *data, ELM_ENTRY_DATA_GET(data, sd); Evas_Event_Mouse_Down *ev = event_info; - Evas_Coord ex, ey; - Evas_Coord cx, cy, cw, ch; int pos, start_pos, end_pos, main_pos; sd->end_handler_down = EINA_TRUE; @@ -3412,21 +3425,7 @@ _end_handler_mouse_down_cb(void *data, if (pos != main_pos) edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, pos); - - edje_object_part_text_cursor_geometry_get(sd->entry_edje, "elm.text", - &cx, &cy, &cw, &ch); - evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL); - sd->ox = ev->canvas.x - (ex + cx + (cw / 2)); - sd->oy = ev->canvas.y - (ey + cy + (ch / 2)); - - ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); - sd->long_pressed = EINA_FALSE; - if (_elm_config->magnifier_enable) - { - _magnifier_create(data); - _magnifier_show(data); - _magnifier_move(data, ex + cx, ey + cy + (ch / 2)); - } + _selection_handlers_offset_calc(data, sd->end_handler, ev->canvas.x, ev->canvas.y); } static void