[copy&paste module] copy & paste popup position move to selection's center
authordeasung.kim <deasung.kim@samsung.com>
Fri, 30 Sep 2011 06:48:30 +0000 (15:48 +0900)
committerdeasung.kim <deasung.kim@samsung.com>
Fri, 30 Sep 2011 06:49:50 +0000 (15:49 +0900)
Change-Id: I33eeb07597f1b774d7fe6f48c71d6a35efe932ac

src/lib/elm_entry.c
src/lib/elm_module_priv.h
src/modules/ctxpopup_copypasteUI/copypaste.c
src/modules/ctxpopup_copypasteshareUI/copypaste.c
src/modules/popup_copypasteUI/copypaste.c

index a6df806..e56e98f 100644 (file)
@@ -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;
index f9b8570..13b766a 100644 (file)
@@ -8,7 +8,7 @@ struct _Elm_Entry_Extension_data
 {\r
        Evas_Object *popup;\r
        Evas_Object *ent;\r
-       Ecore_Timer *longpress_timer;\r
+       Evas_Object *viewport_obj;\r
        Eina_List *items;\r
        cpfunc select;\r
        cpfunc copy;\r
index 0ad6794..7ec2dec 100644 (file)
@@ -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
index 979b288..83c28df 100644 (file)
@@ -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);
-                       }
-     }
 }
 
 
index 61e1a23..2a6ef7d 100644 (file)
@@ -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);
-                       }
-     }
 }