yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=2fc15e5ad760862d247c89fee6681e00a3cf17d8

commit 2fc15e5ad760862d247c89fee6681e00a3cf17d8
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Mon Nov 23 16:51:46 2015 +0200

    Fix calculation of relative coords in drop target.
    
    Coordinates relative to drop_candidate were passed into _drop_target_pos().
    This is wrong. Fixed.
    For table: added calculation of caoods within table - this is need
    to calculate proper cell.
---
 src/bin/gui/dnd.c    | 12 +-----------
 src/bin/gui/editor.c | 11 ++++++++---
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/bin/gui/dnd.c b/src/bin/gui/dnd.c
index 4b816f5..b327917 100644
--- a/src/bin/gui/dnd.c
+++ b/src/bin/gui/dnd.c
@@ -347,13 +347,11 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, 
Elm_Xdnd_Action action
         return;
      }
 
-   Eo *wdg_eo;
    Gui_Widget *drop_candidate = (Gui_Widget *) wdg;
    const Gui_Context *ctx = wdg_context_get(wdg);
    double scale = gui_context_scale_get(ctx);
 
    Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(ctx);
-   wdg_eo = session_eo_get(session, wdg);
    _drop_target_iterate(&drop_candidate, session, x / scale, y / scale);
 
    if (main_wdg_ti->drop_target != drop_candidate)
@@ -381,15 +379,7 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, 
Elm_Xdnd_Action action
         main_wdg_ti->drop_target = drop_candidate;
      }
 
-   /* Need to calculate coord inside object */
-   if (drop_candidate != wdg)
-     {
-        wdg_eo = session_eo_get(session, drop_candidate);
-        Evas_Coord obj_x, obj_y;
-        eo_do(wdg_eo, efl_gfx_position_get(&obj_x, &obj_y));
-        x -= obj_x;
-        y -= obj_y;
-     }
+   dnd_debug("--->Drop Candidate: %s; Coords within: %d %d", 
wdg_name_get(drop_candidate), x, y);
 
    /* Simulate poscb inside drop candidate.
     * Get callbacks from drop candidate and call. */
diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 19c9816..a047fd8 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -1990,7 +1990,7 @@ _table_cell_segment_get(int x, int y, int cell_w, int 
cell_h, int *_part_x, int
    if (_part_y) *_part_y = part_y;
 }
 
-/* x, y - coordinates of pointers relative to droppable object. */
+/* x, y - coordinates of pointer relative main object(window). */
 static void
 _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, 
Elm_Xdnd_Action action EINA_UNUSED)
 {
@@ -2110,10 +2110,15 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, 
Evas_Coord y, Elm_Xdnd_Actio
         const Eina_List *lst = 
wdg_obj_container_contents_list_get(drop_target_wdg), *l;
         Object_Container_Item *it;
         int cell_w = 0, cell_h = 0;
-        int table_w = 0, table_h = 0;
+        int table_w = 0, table_h = 0, table_x, table_y;
         int pack_x = 0, pack_y = 0;
         int pointer_x_cell = 0, pointer_y_cell = 0;
-        eo_do(drop_target_wdg_eo, efl_gfx_size_get(&table_w, &table_h));
+        eo_do(drop_target_wdg_eo, efl_gfx_size_get(&table_w, &table_h),
+                                  efl_gfx_position_get(&table_x, &table_y));
+
+        /* Need to calculate coords within table in order to find proper 
cell.*/
+        x -= table_x;
+        y -= table_y;
 
         cell_w = table_w / di->table_w;
         cell_h = table_h / di->table_h;

-- 


Reply via email to