summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-12-01 16:34:13 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-12-01 16:34:13 +0200
commit590bc48bdffe2b4fd8fcecb4064d85060cf9d353 (patch)
tree6f9c57bc5c58f6dedf795cc936fef2cfa929dc99 /src/bin
parent93b67e2aa1f4d7d2c97bb2c3a1627165c2a6f27e (diff)
Fix canvas drop position
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/editor.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index c3655e3..c30e8a6 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -25,6 +25,8 @@
25#include "elm_widget.h" 25#include "elm_widget.h"
26 26
27#define MAIN_WDG_INFO "main_wdg_info_key" 27#define MAIN_WDG_INFO "main_wdg_info_key"
28#define CURSOR_DROP_X "cursor_drop_x"
29#define CURSOR_DROP_Y "cursor_drop_y"
28 30
29/* Function to call in the end of undo/redo in order to update view. 31/* Function to call in the end of undo/redo in order to update view.
30 * Update is made according to head memento. */ 32 * Update is made according to head memento. */
@@ -1099,6 +1101,9 @@ typedef struct
1099 int table_pack_x; 1101 int table_pack_x;
1100 int table_pack_y; 1102 int table_pack_y;
1101 Eina_List *table_borders; 1103 Eina_List *table_borders;
1104
1105 int pointer_x;
1106 int pointer_y;
1102} 1107}
1103DnD_Info; 1108DnD_Info;
1104 1109
@@ -1289,7 +1294,7 @@ _drop_target_leave(void *data, Evas_Object *obj EINA_UNUSED)
1289} 1294}
1290 1295
1291static Gui_Widget* 1296static Gui_Widget*
1292_editor_factory_wdg_create(const char *class_name, const Gui_Widget *focused_wdg); 1297_editor_factory_wdg_create(const char *class_name, const Gui_Widget *focused_wdg, Evas_Coord main_wdg_x, Evas_Coord main_wdg_y);
1293 1298
1294static Eina_Bool 1299static Eina_Bool
1295_drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev) 1300_drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
@@ -1314,7 +1319,7 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
1314 if (di->eo_cur) eo_del(di->eo_cur); 1319 if (di->eo_cur) eo_del(di->eo_cur);
1315 1320
1316 const char *drag_data = ev->data; 1321 const char *drag_data = ev->data;
1317 Gui_Widget *new_wdg = _editor_factory_wdg_create(drag_data, wdg); 1322 Gui_Widget *new_wdg = _editor_factory_wdg_create(drag_data, wdg, di->pointer_x, di->pointer_y);
1318 1323
1319 if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS)) 1324 if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
1320 { 1325 {
@@ -1454,8 +1459,12 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1454 else 1459 else
1455 { 1460 {
1456 ERR("Drop target is wrong. If you see this message something is terribly wrong!"); 1461 ERR("Drop target is wrong. If you see this message something is terribly wrong!");
1462 return;
1457 } 1463 }
1458 1464
1465 di->pointer_x = x;
1466 di->pointer_y = y;
1467
1459 if (!di->packed) 1468 if (!di->packed)
1460 eo_do(di->eo_cur, evas_obj_position_set(obj_x + x, obj_y + y)); 1469 eo_do(di->eo_cur, evas_obj_position_set(obj_x + x, obj_y + y));
1461 1470
@@ -1738,8 +1747,15 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1738 eo_do(smart_parent, evas_obj_smart_member_add(fr)); 1747 eo_do(smart_parent, evas_obj_smart_member_add(fr));
1739 eo_do(smart_parent, evas_obj_position_get(&x_par, &y_par)); 1748 eo_do(smart_parent, evas_obj_position_get(&x_par, &y_par));
1740 1749
1741 /* Before elm run, smart_parent will have some weird position, so need to make correction. */ 1750 /* If widget was DnD'ed from factory, these fields won't be empty... */
1742 _canvas_free_coords_get(wdg_context_get(wdg), x_par, y_par, &x, &y); 1751 x = (intptr_t) wdg_data_get(wdg, CURSOR_DROP_X);
1752 y = (intptr_t) wdg_data_get(wdg, CURSOR_DROP_Y);
1753
1754 /* ...if they are empty, calculate automatic coordinates. */
1755 if ((x == 0) && (y == 0))
1756 {
1757 _canvas_free_coords_get(wdg_context_get(wdg), x_par, y_par, &x, &y);
1758 }
1743 eo_do(fr, evas_obj_position_set(x, y)); 1759 eo_do(fr, evas_obj_position_set(x, y));
1744 1760
1745 wi = main_wdg_info_new(); 1761 wi = main_wdg_info_new();
@@ -2363,7 +2379,7 @@ _editor_selected_wdg_del_cb()
2363} 2379}
2364 2380
2365static Gui_Widget* 2381static Gui_Widget*
2366_editor_factory_wdg_create(const char *class_name, const Gui_Widget *focused_wdg) 2382_editor_factory_wdg_create(const char *class_name, const Gui_Widget *focused_wdg, Evas_Coord main_wdg_x, Evas_Coord main_wdg_y)
2367{ 2383{
2368 const Gui_Widget *parent_win = NULL; 2384 const Gui_Widget *parent_win = NULL;
2369 const char *parent_name = NULL; 2385 const char *parent_name = NULL;
@@ -2434,6 +2450,13 @@ _editor_factory_wdg_create(const char *class_name, const Gui_Widget *focused_wdg
2434 wdg_prop_add(wdg, prop); 2450 wdg_prop_add(wdg, prop);
2435 } 2451 }
2436 2452
2453 /* Save drop coordinates in internal data of widget, in order to set position of the frame */
2454 if (IS_MAIN(wdg))
2455 {
2456 wdg_data_set(wdg, CURSOR_DROP_X, (void *) (intptr_t) main_wdg_x);
2457 wdg_data_set(wdg, CURSOR_DROP_Y, (void *) (intptr_t) main_wdg_y);
2458 }
2459
2437 // Set default property values 2460 // Set default property values
2438 Eina_List *kl_list = eo_class_mro_get(class_name), *itr; 2461 Eina_List *kl_list = eo_class_mro_get(class_name), *itr;
2439 const char *kl_name; 2462 const char *kl_name;