From 56dd43815f90fc53c4c23601073d1f69fbd89527 Mon Sep 17 00:00:00 2001 From: "deasung.kim" Date: Fri, 30 Sep 2011 15:48:30 +0900 Subject: [PATCH] [copy&paste module] copy & paste popup position move to selection's center Change-Id: I33eeb07597f1b774d7fe6f48c71d6a35efe932ac --- src/lib/elm_entry.c | 1 + src/lib/elm_module_priv.h | 2 +- src/modules/ctxpopup_copypasteUI/copypaste.c | 49 ++++++++++++++++------- src/modules/ctxpopup_copypasteshareUI/copypaste.c | 8 ---- src/modules/popup_copypasteUI/copypaste.c | 8 ---- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index a6df806..e56e98f 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -2886,6 +2886,7 @@ EAPI void elm_entry_extension_module_data_get(Evas_Object *obj,Elm_Entry_Extensi ext_mod->select = _select; ext_mod->selectall = _selectall; ext_mod->ent = wd->ent; + ext_mod->viewport_obj = _viewport_obj_get(obj); ext_mod->items = wd->items; ext_mod->editable = wd->editable; ext_mod->have_selection = wd->have_selection; diff --git a/src/lib/elm_module_priv.h b/src/lib/elm_module_priv.h index f9b8570..13b766a 100644 --- a/src/lib/elm_module_priv.h +++ b/src/lib/elm_module_priv.h @@ -8,7 +8,7 @@ struct _Elm_Entry_Extension_data { Evas_Object *popup; Evas_Object *ent; - Ecore_Timer *longpress_timer; + Evas_Object *viewport_obj; Eina_List *items; cpfunc select; cpfunc copy; diff --git a/src/modules/ctxpopup_copypasteUI/copypaste.c b/src/modules/ctxpopup_copypasteUI/copypaste.c index 0ad6794..7ec2dec 100644 --- a/src/modules/ctxpopup_copypasteUI/copypaste.c +++ b/src/modules/ctxpopup_copypasteUI/copypaste.c @@ -22,23 +22,45 @@ _ctxpopup_position(Evas_Object *obj) { if(!ext_mod) return; - Evas_Coord cx, cy, cw, ch, x, y, mw, mh; - evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL); - edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text", - &cx, &cy, &cw, &ch); - evas_object_size_hint_min_get(ext_mod->popup, &mw, &mh); - if (cw < mw) + Evas_Coord cx, cy, cw, ch, x, y, w, h; + if (!edje_object_part_text_selection_geometry_get(ext_mod->ent, "elm.text", &x, &y, &w, &h)) { - cx += (cw - mw) / 2; - cw = mw; + evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL); + edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text", + &cx, &cy, &cw, &ch); + evas_object_size_hint_min_get(ext_mod->popup, &w, &h); + if (cw < w) + { + cx += (cw - w) / 2; + cw = w; + } + if (ch < h) + { + cy += (ch - h) / 2; + ch = h; + } + evas_object_move(ext_mod->popup, x + cx, y + cy); + evas_object_resize(ext_mod->popup, cw, ch); } - if (ch < mh) + else { - cy += (ch - mh) / 2; - ch = mh; + if (ext_mod->viewport_obj) + { + Evas_Coord vx, vy, vw, vh, x2, y2; + x2 = x + w; + y2 = y + h; + evas_object_geometry_get(ext_mod->viewport_obj, &vx, &vy, &vw, &vh); + if (x < vx) x = vx; + if (y < vy) y = vy; + if (x2 > vx + vw) x2 = vx + vw; + if (y2 > vy + vh) y2 = vy + vh; + w = x2 - x; + h = y2 - y; + } + cx = x + (w / 2); + cy = y + (h / 2); + evas_object_move(ext_mod->popup, cx, cy); } - evas_object_move(ext_mod->popup, x + cx, y + cy); - evas_object_resize(ext_mod->popup, cw, ch); } static void @@ -285,7 +307,6 @@ obj_longpress(Evas_Object *obj) evas_object_show(ext_mod->popup); } } - ext_mod->longpress_timer = NULL; } EAPI void diff --git a/src/modules/ctxpopup_copypasteshareUI/copypaste.c b/src/modules/ctxpopup_copypasteshareUI/copypaste.c index 979b288..83c28df 100644 --- a/src/modules/ctxpopup_copypasteshareUI/copypaste.c +++ b/src/modules/ctxpopup_copypasteshareUI/copypaste.c @@ -275,7 +275,6 @@ obj_longpress(Evas_Object *obj) evas_object_show(ext_mod->popup); } } - ext_mod->longpress_timer = NULL; } EAPI void @@ -287,13 +286,6 @@ obj_mouseup(Evas_Object *obj) /*update*/ elm_entry_extension_module_data_get(obj,ext_mod); - if (ext_mod->longpress_timer) - { - if (ext_mod->have_selection ) - { - _cancel(obj,ext_mod->popup,NULL); - } - } } diff --git a/src/modules/popup_copypasteUI/copypaste.c b/src/modules/popup_copypasteUI/copypaste.c index 61e1a23..2a6ef7d 100644 --- a/src/modules/popup_copypasteUI/copypaste.c +++ b/src/modules/popup_copypasteUI/copypaste.c @@ -190,7 +190,6 @@ obj_longpress(Evas_Object *obj) evas_render( evas_object_evas_get( ext_mod->popup ) ); } } - ext_mod->longpress_timer = NULL; } EAPI void @@ -198,12 +197,5 @@ obj_mouseup(Evas_Object *obj) { /*update*/ elm_entry_extension_module_data_get(obj,ext_mod); - if (ext_mod->longpress_timer) - { - if (ext_mod->have_selection ) - { - _cancel(obj,ext_mod->popup,NULL); - } - } } -- 2.7.4