summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-11-24 12:06:55 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-12-15 11:42:35 +0200
commit1dd8a56f5273734c84c02a9acff6bee1e45cf524 (patch)
tree8d3ddad44ca4579412e068df40e8555cc0bea592 /src/bin
parent7ca86758789309f3af4c2d8b8873e93740e1fe30 (diff)
DnD. Part 2
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/dnd.c90
-rw-r--r--src/bin/egui_gui/dnd.h15
-rw-r--r--src/bin/egui_gui/editor.c801
3 files changed, 708 insertions, 198 deletions
diff --git a/src/bin/egui_gui/dnd.c b/src/bin/egui_gui/dnd.c
index 1543d09..0579639 100644
--- a/src/bin/egui_gui/dnd.c
+++ b/src/bin/egui_gui/dnd.c
@@ -11,12 +11,16 @@ typedef struct
11 const char *data; /*DnD data*/ 11 const char *data; /*DnD data*/
12 Eo *image; /* image for DnD icon. */ 12 Eo *image; /* image for DnD icon. */
13 Eo *obj; /*object, where drag starts */ 13 Eo *obj; /*object, where drag starts */
14 const Gui_Widget *wdg; /* let's think about it as about DnD data. */
15
16 void (*_drag_start_cb)(const Gui_Widget *wdg, const Eo *obj);
14} Drag_Info; 17} Drag_Info;
15 18
16typedef struct 19typedef struct
17{ 20{
18 Ecore_Timer *tm; 21 Ecore_Timer *tm;
19 Drag_Info *drag_info; 22 Drag_Info *drag_info;
23 int dnd_in_out; /* Main objects enter/leave counter*/
20} DnD_Info; 24} DnD_Info;
21 25
22typedef struct 26typedef struct
@@ -41,6 +45,12 @@ typedef struct
41 45
42static DnD_Info _dnd_info; 46static DnD_Info _dnd_info;
43 47
48/* Determine if dragged object is inside droppable. */
49Eina_Bool
50dnd_is_in_drop_target()
51{
52 return !!_dnd_info.dnd_in_out;
53}
44 54
45const char* 55const char*
46dnd_drag_data_get() 56dnd_drag_data_get()
@@ -48,6 +58,18 @@ dnd_drag_data_get()
48 return _dnd_info.drag_info->data; 58 return _dnd_info.drag_info->data;
49} 59}
50 60
61const Eo*
62dnd_drag_obj_get()
63{
64 return _dnd_info.drag_info->obj;
65}
66
67const Gui_Widget*
68dnd_drag_wdg_get()
69{
70 return _dnd_info.drag_info->wdg;
71}
72
51static void 73static void
52_dragpos(void *data EINA_UNUSED, Eo * obj EINA_UNUSED, Evas_Coord x EINA_UNUSED, Evas_Coord y EINA_UNUSED, Elm_Xdnd_Action action EINA_UNUSED) 74_dragpos(void *data EINA_UNUSED, Eo * obj EINA_UNUSED, Evas_Coord x EINA_UNUSED, Evas_Coord y EINA_UNUSED, Elm_Xdnd_Action action EINA_UNUSED)
53{ 75{
@@ -72,6 +94,7 @@ _dragstate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
72static void 94static void
73_dropenter(void *data, Evas_Object *obj) 95_dropenter(void *data, Evas_Object *obj)
74{ 96{
97 _dnd_info.dnd_in_out++;
75 Target_Info *ti = data; 98 Target_Info *ti = data;
76 ti->drop_target = ti->wdg; 99 ti->drop_target = ti->wdg;
77 100
@@ -86,6 +109,7 @@ static void
86_dropleave(void *data, Evas_Object *obj) 109_dropleave(void *data, Evas_Object *obj)
87{ 110{
88 Target_Info *main_wdg_ti = data; 111 Target_Info *main_wdg_ti = data;
112 _dnd_info.dnd_in_out--;
89 113
90 /* if ti->drop_target is not current main widget, then it means, 114 /* if ti->drop_target is not current main widget, then it means,
91 * that prev drop target, box for example wasn't leaved properly. 115 * that prev drop target, box for example wasn't leaved properly.
@@ -125,7 +149,7 @@ _dropcb(void *data EINA_UNUSED, Evas_Object *obj, Elm_Selection_Data *ev)
125} 149}
126 150
127static void 151static void
128_drop_target_iterate(Gui_Widget **drop_candidate, Gui_Session *session, Evas_Coord x, Evas_Coord y) 152_drop_target_iterate(Gui_Widget **drop_candidate, const Gui_Session *session, Evas_Coord x, Evas_Coord y)
129{ 153{
130 Eina_Bool stop = EINA_TRUE; 154 Eina_Bool stop = EINA_TRUE;
131 Dep_Id *wdg_id; 155 Dep_Id *wdg_id;
@@ -134,13 +158,18 @@ _drop_target_iterate(Gui_Widget **drop_candidate, Gui_Session *session, Evas_Coo
134 double aprx = 0.05; 158 double aprx = 0.05;
135 159
136 const Eina_List *lst, *l; 160 const Eina_List *lst, *l;
161 const Gui_Widget *dragged_wdg = dnd_drag_wdg_get();
137 lst = wdg_children_list_get(*drop_candidate); 162 lst = wdg_children_list_get(*drop_candidate);
138 EINA_LIST_FOREACH(lst, l, wdg_id) 163 EINA_LIST_FOREACH(lst, l, wdg_id)
139 { 164 {
140 Gui_Widget *w = wdg_get(wdg_id); 165 Gui_Widget *w = wdg_get(wdg_id);
141 /* if widget is not active, or is not a drop target, continue. */ 166 /* If widget is not active, or is not a drop target, continue. */
142 if (!w || !wdg_data_get(w, DROP_TARGET)) 167 if (!w || !wdg_data_get(w, DROP_TARGET))
143 continue; 168 continue;
169 /* If iterated object is dragged one, continue.
170 * This can happen when start dragging some drop target. */
171 if (w == dragged_wdg)
172 continue;
144 o = session_eo_get(session, w); 173 o = session_eo_get(session, w);
145 eo_do(o, evas_obj_position_get(&ox, &oy)); 174 eo_do(o, evas_obj_position_get(&ox, &oy));
146 eo_do(o, evas_obj_size_get(&ow, &oh)); 175 eo_do(o, evas_obj_size_get(&ow, &oh));
@@ -172,7 +201,6 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action
172 /* For canvas only*/ 201 /* For canvas only*/
173 if (!wdg) 202 if (!wdg)
174 { 203 {
175 ERR("drop target: MAIN CANVAS:: %d %d", x, y);
176 if (main_wdg_ti->drop_target_pos) 204 if (main_wdg_ti->drop_target_pos)
177 { 205 {
178 main_wdg_ti->drop_target_pos(main_wdg_ti->posdata, obj, x, y, action); 206 main_wdg_ti->drop_target_pos(main_wdg_ti->posdata, obj, x, y, action);
@@ -180,8 +208,6 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action
180 return; 208 return;
181 } 209 }
182 210
183 ERR("drop target: %s:: %d %d", wdg_name_get(wdg), x, y);
184
185 Eo *wdg_eo, *iwin; 211 Eo *wdg_eo, *iwin;
186 Evas_Coord p_x = 0, p_y = 0; 212 Evas_Coord p_x = 0, p_y = 0;
187 Evas_Coord iwin_x = 0, iwin_y = 0; 213 Evas_Coord iwin_x = 0, iwin_y = 0;
@@ -206,7 +232,6 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action
206 p_x = x - iwin_x; 232 p_x = x - iwin_x;
207 p_y = y - iwin_y; 233 p_y = y - iwin_y;
208 _drop_target_iterate(&drop_candidate, session, p_x, p_y); 234 _drop_target_iterate(&drop_candidate, session, p_x, p_y);
209 ERR("Drop Candidate: %s", wdg_class_name_get(drop_candidate));
210 235
211 if (main_wdg_ti->drop_target != drop_candidate) 236 if (main_wdg_ti->drop_target != drop_candidate)
212 { 237 {
@@ -256,7 +281,8 @@ _droppos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action
256static Evas_Object * 281static Evas_Object *
257_image_create_icon(void *data, Evas_Object *parent, Evas_Coord *xoff, Evas_Coord *yoff) 282_image_create_icon(void *data, Evas_Object *parent, Evas_Coord *xoff, Evas_Coord *yoff)
258{ 283{
259 Evas_Object *ic; 284 //if (!data) return NULL;
285 Evas_Object *ic = NULL;
260 Evas_Object *io = data; 286 Evas_Object *io = data;
261 const char *f, *g; 287 const char *f, *g;
262 Evas_Coord x, y, w, h, xm, ym; 288 Evas_Coord x, y, w, h, xm, ym;
@@ -280,14 +306,23 @@ static Eina_Bool
280_drag_start(void *data) 306_drag_start(void *data)
281{ 307{
282 Drag_Info *di = data; 308 Drag_Info *di = data;
309 Evas_Object *(*image_create_icon_f)(void *data, Evas_Object *parent, Evas_Coord *xoff, Evas_Coord *yoff) = NULL;
310 Evas_Object *drag_image = di->image;
311 if (drag_image)
312 image_create_icon_f = _image_create_icon;
313
283 _dnd_info.tm = NULL; 314 _dnd_info.tm = NULL;
284 _dnd_info.drag_info = di; 315 _dnd_info.drag_info = di;
285 elm_drag_start(di->obj, ELM_SEL_FORMAT_TEXT, 316 elm_drag_start(di->obj, ELM_SEL_FORMAT_TEXT,
286 di->data, ELM_XDND_ACTION_COPY, 317 di->data, ELM_XDND_ACTION_COPY,
287 _image_create_icon, di->image, 318 image_create_icon_f, drag_image,
288 _dragpos, "drag", 319 _dragpos, NULL,
289 _dragaccept, NULL, 320 _dragaccept, NULL,
290 _dragstate, "drag"); 321 _dragstate, NULL);
322 if (di->_drag_start_cb)
323 {
324 di->_drag_start_cb(di->wdg, di->obj);
325 }
291 return ECORE_CALLBACK_CANCEL; 326 return ECORE_CALLBACK_CANCEL;
292} 327}
293 328
@@ -319,9 +354,12 @@ _drag_data_free(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *des
319{ 354{
320 Drag_Info *di = data; 355 Drag_Info *di = data;
321 free(di); 356 free(di);
357 _dnd_info.drag_info = NULL;
322 return EO_CALLBACK_CONTINUE; 358 return EO_CALLBACK_CONTINUE;
323} 359}
324 360
361/* Function to make Eo object draggable, when mouse down/up are handled inside.
362 * Dragging from factory. */
325void 363void
326drag_add(Eo *obj, Eo *image, const char *data) 364drag_add(Eo *obj, Eo *image, const char *data)
327{ 365{
@@ -333,6 +371,38 @@ drag_add(Eo *obj, Eo *image, const char *data)
333 eo_do(obj, eo_event_callback_add(EVAS_OBJECT_EVENT_DEL, _drag_data_free, di)); 371 eo_do(obj, eo_event_callback_add(EVAS_OBJECT_EVENT_DEL, _drag_data_free, di));
334} 372}
335 373
374/* Function to start dragging, when mouse down/up are handled outside.
375 * Dragging widgets. */
376void
377drag_start(Eo *obj, Eo *image, const char *data, const Gui_Widget *wdg, void (*cb)(const Gui_Widget *, const Eo *))
378{
379 Drag_Info *di = calloc(1, sizeof(Drag_Info));
380 di->image = image;
381 di->data = data;
382 di->obj = obj;
383 di->wdg = wdg;
384 di->_drag_start_cb = cb;
385 _dnd_info.drag_info = di;
386
387 ecore_timer_del(_dnd_info.tm);
388 _dnd_info.tm = ecore_timer_add(TIME_TO_DRAG, _drag_start, di);
389}
390
391/* Function to stop dragging, when mouse down/up are handled outside.
392 * Dragging widgets. */
393void
394drag_stop()
395{
396 if (_dnd_info.tm)
397 {
398 ecore_timer_del(_dnd_info.tm);
399 _dnd_info.tm = NULL;
400 }
401 free(_dnd_info.drag_info);
402 _dnd_info.drag_info = NULL;
403 _dnd_info.dnd_in_out = 0;
404}
405
336static Target_Info* 406static Target_Info*
337_target_info_new(Gui_Widget *wdg, Eo *obj) 407_target_info_new(Gui_Widget *wdg, Eo *obj)
338{ 408{
diff --git a/src/bin/egui_gui/dnd.h b/src/bin/egui_gui/dnd.h
index 8f214b5..bb7d6c3 100644
--- a/src/bin/egui_gui/dnd.h
+++ b/src/bin/egui_gui/dnd.h
@@ -6,6 +6,12 @@ void
6drag_add(Eo *obj, Eo *image, const char *data); 6drag_add(Eo *obj, Eo *image, const char *data);
7 7
8void 8void
9drag_start(Eo *obj, Eo *image, const char *data, const Gui_Widget *wdg, void (*cb)(const Gui_Widget *, const Eo *));
10
11void
12drag_stop();
13
14void
9drop_target_wdg_set(Gui_Widget *wdg, 15drop_target_wdg_set(Gui_Widget *wdg,
10 void (*drop_target_enter)(void *, Evas_Object *obj), void *enterdata, 16 void (*drop_target_enter)(void *, Evas_Object *obj), void *enterdata,
11 void (*drop_target_leave)(void *, Evas_Object *obj), void *leavedata, 17 void (*drop_target_leave)(void *, Evas_Object *obj), void *leavedata,
@@ -25,4 +31,13 @@ drop_target_wdg_del(Gui_Widget *wdg, Eo *obj);
25const char* 31const char*
26dnd_drag_data_get(); 32dnd_drag_data_get();
27 33
34const Eo*
35dnd_drag_obj_get();
36
37const Gui_Widget*
38dnd_drag_wdg_get();
39
40Eina_Bool
41dnd_is_in_drop_target();
42
28#endif 43#endif
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index d20859f..2f89c0c 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -28,6 +28,33 @@
28#define CURSOR_DROP_X "cursor_drop_x" 28#define CURSOR_DROP_X "cursor_drop_x"
29#define CURSOR_DROP_Y "cursor_drop_y" 29#define CURSOR_DROP_Y "cursor_drop_y"
30 30
31#define EDITOR_DND_DATA "__EDITOR_DND_DATA__"
32#define EDITOR_DRAG_DATA "__EDITOR_DRAG_DATA__"
33#define DND_SESSION "__DND_SESSION__"
34
35typedef struct
36{
37 Eo *eo_cur;
38
39 Eina_Bool packed; /* Need this, because no API to check if object is packed into table
40 and unpack causes error message. */
41 int box_pack_idx;
42
43 int cell_part_x; /* Which fifth part of sell was selected*/
44 int cell_part_y; /* Used in order to check if need to repack or not. */
45
46 int table_w; /* Table width/height. Calculate it once in the beginning. */
47 int table_h;
48
49 int table_pack_x;
50 int table_pack_y;
51 Eina_List *table_borders;
52
53 int pointer_x;
54 int pointer_y;
55}
56DnD_Info;
57
31/* Function to call in the end of undo/redo in order to update view. 58/* Function to call in the end of undo/redo in order to update view.
32 * Update is made according to head memento. */ 59 * Update is made according to head memento. */
33static void 60static void
@@ -297,7 +324,6 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility, int border_type_co
297 } 324 }
298 } 325 }
299 326
300
301 switch (border_type_color) 327 switch (border_type_color)
302 { 328 {
303 case BORDER_SELECTION: 329 case BORDER_SELECTION:
@@ -332,46 +358,6 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility, int border_type_co
332#undef STR 358#undef STR
333 359
334static void 360static void
335_on_mouse_move_widget_drag(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
336void *event_info)
337{
338 Gui_Context *ctx = data;
339 static int cx, cy;
340 Evas_Coord ox, oy;
341 Evas_Event_Mouse_Move *ev = event_info;
342
343 /*FIXME: remove static stuff after tripple callback wil be fixed*/
344 if ((cx == ev->cur.canvas.x) && (cy == ev->cur.canvas.y))
345 return;
346
347 eo_do(obj, evas_obj_position_get(&ox, &oy));
348 ox = ox + (ev->cur.canvas.x - ev->prev.canvas.x);
349 oy = oy + (ev->cur.canvas.y - ev->prev.canvas.y);
350
351 eo_do(obj, evas_obj_position_set(ox, oy));
352 {
353 Gui_Widget *wdg = wdg_find_by_eo(gui_context_editor_session_get(ctx), ctx, obj);
354 Gui_Widget_Property *prop;
355 Gui_Value *val;
356
357 if (wdg)
358 {
359 prop = wdg_prop_get(wdg, DB_DEF_EVAS_OBJECT_CLASS, POSITION_SET);
360 if (prop)
361 {
362 val = prop_value_nth_get(prop, 0);
363 gui_value_int_set(val, ox);
364 val = prop_value_nth_get(prop, 1);
365 gui_value_int_set(val, oy);
366 propview_item_update(prop);
367 }
368 }
369 }
370 cx = ev->cur.canvas.x;
371 cy = ev->cur.canvas.y;
372}
373
374static void
375_frame_mouse_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *fr, void *event_info) 361_frame_mouse_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *fr, void *event_info)
376{ 362{
377 Evas_Coord ox, oy; 363 Evas_Coord ox, oy;
@@ -508,34 +494,91 @@ _key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU
508 ERR("key down"); 494 ERR("key down");
509} 495}
510 496
511/* Callback, which adds MOUSE_MOVE callback,
512 * to implement drag-and-drop in editor mode*/
513static void 497static void
514_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 498_drag_widget_iterate(Gui_Widget **drag_candidate, const Gui_Session *session, Evas_Coord x, Evas_Coord y)
515{ 499{
516 Gui_Context *ctx = data; 500 Eina_Bool stop = EINA_TRUE;
517 const Gui_Session *session = gui_context_editor_session_get(ctx); 501 Dep_Id *wdg_id;
518 Gui_Widget *wdg = wdg_find_by_eo(session, ctx, obj); 502 Eo *o;
519 EINA_SAFETY_ON_NULL_RETURN(wdg); 503 Evas_Coord ox, oy, ow, oh;
504 double aprx = 0.05;
505
506 const Eina_List *lst, *l;
507 lst = wdg_children_list_get(*drag_candidate);
508 EINA_LIST_FOREACH(lst, l, wdg_id)
509 {
510 Gui_Widget *w = wdg_get(wdg_id);
511 /* if widget is not active, continue. */
512 if (!w)
513 continue;
514 o = session_eo_get(session, w);
515 eo_do(o, evas_obj_position_get(&ox, &oy));
516 eo_do(o, evas_obj_size_get(&ow, &oh));
517 if (((x >= ox) && (x <= ox + ow)) &&
518 ((y >= oy) && (y <= oy + oh)))
519 {
520 *drag_candidate = w;
521 /* Suppose we have win, a resize object box, and a table packed into the box.
522 * We drag, so want to enter the box first, and table after.
523 * So while pointer in in 5% of width of the box, force to return the box as a drop target. */
524 if (((x > ox + (Evas_Coord) (ow * aprx)) && (x <= ox + (Evas_Coord) (ow * (1- aprx)))) &&
525 ((y > oy + (Evas_Coord) (oh * aprx)) && (y <= oy + (Evas_Coord) (oh * (1- aprx)))))
526 stop = EINA_FALSE;
527 }
528 }
529
530 if (!stop)
531 _drag_widget_iterate(drag_candidate, session, x, y);
532}
533
534void
535_drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo);
536
537/* Callback, called on mouse_down on window image,
538 * resolves widget under a cursor. */
539static void
540_mouse_down_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
541{
542 Eo *wdg_eo = NULL;
543 Evas_Event_Mouse_Down *ev = event_info;
544 Gui_Widget *wdg_main = data, *drag_candidate = NULL, *wdg;
545 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg_main));
546 drag_candidate = wdg_main;
547 Evas_Coord x, y;
548 eo_do(obj, evas_obj_position_get(&x, &y));
549 _drag_widget_iterate(&drag_candidate, session, ev->canvas.x - x, ev->canvas.y - y);
550
551 wdg = drag_candidate;
552 wdg_eo = session_eo_get(session, wdg);
553
554 drag_start(wdg_eo, NULL, EDITOR_DRAG_DATA, wdg, _drag_start_cb);
520 555
521 Eo *wdg_eo = session_eo_get(session, wdg);
522 evas_object_focus_set(wdg_eo, EINA_TRUE); 556 evas_object_focus_set(wdg_eo, EINA_TRUE);
523 _editor_wdg_selected_set(wdg); 557 _editor_wdg_selected_set(wdg);
524 objtree_item_selected_set(wdg); 558 objtree_item_selected_set(wdg);
525
526 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag, ctx);
527} 559}
528 560
529/* Callback, which deletes MOUSE_MOVE callback, 561/* Callback, called when depress mouse button */
530 * to implement drag-and-drop*/ 562static void
531static Eina_Bool 563_mouse_up_main(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
532_mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
533{ 564{
534 /* Delete all callbacks, 565 if (!dnd_is_in_drop_target())
535 * because sometimes _mouse_down is called several times. */ 566 {
536 while(evas_object_event_callback_del 567 /* Check if dragged object is visible.
537 (obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag)); 568 * If not, means that _drag_start_cb was called, so need to reload main wdg. */
538 return EO_CALLBACK_CONTINUE; 569 const Gui_Widget *drag_widget = dnd_drag_wdg_get();
570 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(drag_widget));
571 const Eo *wdg_eo = session_eo_get(session, drag_widget);
572 Eina_Bool vis = eo_do(wdg_eo, evas_obj_visibility_get());
573
574 drag_stop();
575 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
576 if (!vis)
577 {
578 Gui_Widget *wdg_main = data;
579 _wdg_parent_win_reload(wdg_main);
580 }
581 }
539} 582}
540 583
541static Eina_Bool 584static Eina_Bool
@@ -783,7 +826,17 @@ _frame_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj,
783 _editor_wdg_selected_set(wdg); 826 _editor_wdg_selected_set(wdg);
784 objtree_item_selected_set(wdg); 827 objtree_item_selected_set(wdg);
785 828
786 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move, NULL); 829 /* Don't use dnd for dragging window around canvas. */
830 if (IS_WIN(wdg))
831 {
832 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move, NULL);
833 }
834 else
835 {
836 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
837 Eo *wdg_eo = session_eo_get(session, wdg);
838 drag_start(wdg_eo, NULL, EDITOR_DRAG_DATA, wdg, _drag_start_cb);
839 }
787} 840}
788 841
789static Eina_Bool 842static Eina_Bool
@@ -1100,31 +1153,6 @@ _content_set(Gui_Session *session, const Gui_Widget *container, const Gui_Widget
1100/************ DnD Functions ******************************/ 1153/************ DnD Functions ******************************/
1101/*********************************************************/ 1154/*********************************************************/
1102 1155
1103#define EDITOR_DND_DATA "__EDITOR_DND_DATA__"
1104
1105typedef struct
1106{
1107 Eo *eo_cur;
1108
1109 Eina_Bool packed; /* Need this, because no API to check if object is packed into table
1110 and unpack causes error message. */
1111 int box_pack_idx;
1112
1113 int cell_part_x; /* Which fifth part of sell was selected*/
1114 int cell_part_y; /* Used in order to check if need to repack or not. */
1115
1116 int table_w; /* Table width/height. Calculate it once in the beginning. */
1117 int table_h;
1118
1119 int table_pack_x;
1120 int table_pack_y;
1121 Eina_List *table_borders;
1122
1123 int pointer_x;
1124 int pointer_y;
1125}
1126DnD_Info;
1127
1128/* Draw border rectangles in table cells. */ 1156/* Draw border rectangles in table cells. */
1129static inline void 1157static inline void
1130_table_borders_draw(Eo *table, int w, int h, Eina_List **_border_objects) 1158_table_borders_draw(Eo *table, int w, int h, Eina_List **_border_objects)
@@ -1157,6 +1185,50 @@ _table_borders_draw(Eo *table, int w, int h, Eina_List **_border_objects)
1157 *_border_objects = border_objects; 1185 *_border_objects = border_objects;
1158} 1186}
1159 1187
1188/* Iteration to create dragged representation of object. */
1189static Eo*
1190_iter_dragged_widget_create(Gui_Session *session, const Gui_Widget *wdg, Eo *parent_win)
1191{
1192 const Eina_List *children = NULL, *l;
1193 Dep_Id *wid;
1194
1195 /* Windows are iterated separately. If parent is NULL, means that current object is not win.
1196 * If iterated object is win, I create it as inlined_image and add frame to simulate win.*/
1197 Eo *o = _ffi_eo_add(session, wdg, parent_win);
1198
1199 if (o)
1200 {
1201 session_eo_set(session, wdg, o);
1202 manager_widget_configure(session, wdg, MODE_EDITOR, NULL);
1203 children = wdg_children_list_get(wdg);
1204 EINA_LIST_FOREACH(children, l, wid)
1205 {
1206 Gui_Widget *w = wdg_get(wid);
1207 /* Window can not have child windows, so pass NULL. */
1208 if (w) _iter_dragged_widget_create(session, w, NULL);
1209 }
1210 }
1211 return o;
1212}
1213
1214static Eo*
1215_drag_obj_create(const Gui_Widget *dragged_wdg, Eo *canvas)
1216{
1217 Eo *ret;
1218 Gui_Session *dnd_session = session_new();
1219 eo_do(canvas, eo_key_data_set(DND_SESSION, dnd_session, NULL));
1220 ret = _iter_dragged_widget_create(dnd_session, dragged_wdg, canvas);
1221 return ret;
1222}
1223
1224static void
1225_drag_obj_del(const Gui_Widget *dragged_wdg, Eo *canvas)
1226{
1227 Gui_Session *dnd_session = eo_do(canvas, eo_key_data_get(DND_SESSION));
1228 manager_widget_delete(dnd_session, dragged_wdg, MODE_EDITOR, NULL);
1229 session_del(dnd_session);
1230}
1231
1160static void 1232static void
1161_drop_target_main_wdg_enter(void *data, Evas_Object *obj) 1233_drop_target_main_wdg_enter(void *data, Evas_Object *obj)
1162{ 1234{
@@ -1167,8 +1239,8 @@ _drop_target_main_wdg_enter(void *data, Evas_Object *obj)
1167 /* If wdg == NULL, then canvas is a drop target or we have a error.*/ 1239 /* If wdg == NULL, then canvas is a drop target or we have a error.*/
1168 if (wdg) 1240 if (wdg)
1169 { 1241 {
1170 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg)); 1242 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1171 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1243 di = wdg_data_get(wdg, EDITOR_DND_DATA);
1172 canvas = session_eo_get(session, wdg); 1244 canvas = session_eo_get(session, wdg);
1173 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET); 1245 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
1174 } 1246 }
@@ -1184,13 +1256,24 @@ _drop_target_main_wdg_enter(void *data, Evas_Object *obj)
1184 } 1256 }
1185 1257
1186 const Eo_Class* (*kl_func)(); 1258 const Eo_Class* (*kl_func)();
1187 kl_func = db_class_func_get(dnd_drag_data_get()); 1259 const char * _drag_data = dnd_drag_data_get(), *drag_obj_class_name;
1188 if (di->eo_cur) eo_del(di->eo_cur); 1260 const Gui_Widget *dragged_wdg = dnd_drag_wdg_get();
1189 di->eo_cur = eo_add(kl_func(), canvas); 1261
1190 eo_do(di->eo_cur, evas_obj_size_set(80, 30)); 1262 if (!di->eo_cur)
1191 eo_do(di->eo_cur, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)); 1263 {
1192 eo_do(di->eo_cur, evas_obj_visibility_set(EINA_TRUE)); 1264 if (dragged_wdg)
1193 eo_do(di->eo_cur, elm_obj_widget_part_text_set(NULL, dnd_drag_data_get())); 1265 {
1266 di->eo_cur = _drag_obj_create(dragged_wdg, canvas);
1267 }
1268 else
1269 {
1270 drag_obj_class_name = _drag_data;
1271 kl_func = db_class_func_get(drag_obj_class_name);
1272 di->eo_cur = eo_add(kl_func(), canvas);
1273 eo_do(di->eo_cur, evas_obj_visibility_set(EINA_TRUE),
1274 elm_obj_widget_part_text_set(NULL, drag_obj_class_name));
1275 }
1276 }
1194} 1277}
1195 1278
1196static void 1279static void
@@ -1198,22 +1281,37 @@ _drop_target_main_wdg_leave(void *data, Evas_Object *obj)
1198{ 1281{
1199 Gui_Widget *wdg = data; 1282 Gui_Widget *wdg = data;
1200 Eo *canvas_drop_target = obj; 1283 Eo *canvas_drop_target = obj;
1284 Eo *canvas = NULL;
1201 DnD_Info *di; 1285 DnD_Info *di;
1202 if (wdg) 1286 if (wdg)
1203 { 1287 {
1204 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1288 di = wdg_data_get(wdg, EDITOR_DND_DATA);
1289 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1290 canvas = session_eo_get(session, wdg);
1205 } 1291 }
1206 else if (canvas_drop_target != NULL) 1292 else if (canvas_drop_target != NULL)
1207 { 1293 {
1208 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA)); 1294 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA));
1295 canvas = canvas_drop_target;
1209 } 1296 }
1210 else 1297 else
1211 { 1298 {
1212 ERR("Drop target is wrong. If you see this message something is terribly wrong!"); 1299 ERR("Drop target is wrong. If you see this message something is terribly wrong!");
1213 } 1300 }
1214 1301
1215 eo_del(di->eo_cur); 1302 if (di->eo_cur)
1216 di->eo_cur = NULL; 1303 {
1304 const Gui_Widget *dragged_wdg = dnd_drag_wdg_get();
1305 if (dragged_wdg)
1306 {
1307 _drag_obj_del(dragged_wdg, canvas);
1308 }
1309 else
1310 {
1311 eo_del(di->eo_cur);
1312 }
1313 di->eo_cur = NULL;
1314 }
1217} 1315}
1218 1316
1219static void 1317static void
@@ -1222,11 +1320,10 @@ _drop_target_enter(void *data, Evas_Object *obj EINA_UNUSED)
1222 Gui_Widget *wdg = data; 1320 Gui_Widget *wdg = data;
1223 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET); 1321 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
1224 Eo *wdg_eo = NULL; 1322 Eo *wdg_eo = NULL;
1225 ERR("Enter: %s", wdg_name_get(wdg));
1226 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1323 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
1227 if (!IS_MAIN(wdg)) 1324 if (!IS_MAIN(wdg))
1228 { 1325 {
1229 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg)); 1326 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1230 wdg_eo = session_eo_get(session, wdg); 1327 wdg_eo = session_eo_get(session, wdg);
1231 } 1328 }
1232 if (wdg_eo && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS)) 1329 if (wdg_eo && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
@@ -1260,13 +1357,13 @@ static void
1260_drop_target_leave(void *data, Evas_Object *obj EINA_UNUSED) 1357_drop_target_leave(void *data, Evas_Object *obj EINA_UNUSED)
1261{ 1358{
1262 Gui_Widget *wdg = data; 1359 Gui_Widget *wdg = data;
1263 ERR("LEave: %s", wdg_name_get(wdg));
1264 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1360 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
1265 Eo *wdg_eo = NULL; 1361 Eo *wdg_eo = NULL;
1362 const Gui_Context *ctx = wdg_context_get(wdg);
1363 const Gui_Session *session = gui_context_editor_session_get(ctx);
1266 /* Coordinates of object relative to canvas. */ 1364 /* Coordinates of object relative to canvas. */
1267 if (!IS_MAIN(wdg)) 1365 if (!IS_MAIN(wdg))
1268 { 1366 {
1269 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg));
1270 wdg_eo = session_eo_get(session, wdg); 1367 wdg_eo = session_eo_get(session, wdg);
1271 } 1368 }
1272 if (wdg_eo && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS)) 1369 if (wdg_eo && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
@@ -1290,7 +1387,6 @@ _drop_target_leave(void *data, Evas_Object *obj EINA_UNUSED)
1290 di->table_borders = NULL; 1387 di->table_borders = NULL;
1291 eo_do(wdg_eo, elm_obj_table_unpack(di->eo_cur)); 1388 eo_do(wdg_eo, elm_obj_table_unpack(di->eo_cur));
1292 1389
1293 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg));
1294 Eina_List *lst = wdg_obj_container_contents_list_get(wdg), *l; 1390 Eina_List *lst = wdg_obj_container_contents_list_get(wdg), *l;
1295 Object_Container_Item *it; 1391 Object_Container_Item *it;
1296 EINA_LIST_FOREACH(lst, l, it) 1392 EINA_LIST_FOREACH(lst, l, it)
@@ -1319,115 +1415,339 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
1319{ 1415{
1320 Gui_Widget *wdg = data; 1416 Gui_Widget *wdg = data;
1321 Eo *canvas_drop_target = obj; 1417 Eo *canvas_drop_target = obj;
1418 Eo *canvas = NULL;
1322 DnD_Info *di; 1419 DnD_Info *di;
1323 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET); 1420 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
1324 if (wdg) 1421 if (wdg)
1325 { 1422 {
1326 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1423 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
1424 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1425 canvas = session_eo_get(session, wdg_main_wdg_get(wdg));
1327 } 1426 }
1328 else if (canvas_drop_target != NULL) 1427 else if (canvas_drop_target != NULL)
1329 { 1428 {
1330 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA)); 1429 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA));
1430 canvas = canvas_drop_target;
1331 } 1431 }
1332 else 1432 else
1333 { 1433 {
1334 ERR("Drop target is wrong. If you see this message something is terribly wrong!"); 1434 ERR("Drop target is wrong. If you see this message something is terribly wrong!");
1335 } 1435 }
1336 1436
1337 if (di->eo_cur) eo_del(di->eo_cur);
1338
1339 const char *drag_data = ev->data; 1437 const char *drag_data = ev->data;
1340 Gui_Widget *new_wdg = _editor_factory_wdg_create(drag_data, wdg, di->pointer_x, di->pointer_y); 1438 const Gui_Widget *new_wdg = NULL;
1439 const Gui_Context *ctx = _active_context_get();
1440 const Gui_Session *session = gui_context_editor_session_get(ctx);
1441 if (strcmp(drag_data, EDITOR_DRAG_DATA))
1442 {
1443 /* Don't allow to drop Window from factory into Main Obj*/
1444 if (!strcmp(DB_DEF_WIN_CLASS , drag_data) && wdg)
1445 {
1446 goto end;
1447 }
1448 new_wdg = _editor_factory_wdg_create(drag_data, wdg, di->pointer_x, di->pointer_y);
1449 }
1450 else
1451 {
1452 new_wdg = dnd_drag_wdg_get();
1453 }
1341 1454
1342 if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS)) 1455 /* Check if new_widget was packed previously: take it's parent and check
1456 * if widget is packed into it's parent.
1457 * If so, we need to unpack widget and delete from contents*/
1458 Gui_Widget *wdg_parent = (Gui_Widget *) wdg_parent_get(new_wdg), *prev_wdg_container = NULL;
1459 if (wdg_parent && wdg_obj_container_item_get(wdg_parent, -1, wdg_name_get(new_wdg)))
1460 prev_wdg_container = wdg_parent;
1461
1462 /* Dragging inside the same container. */
1463 if (prev_wdg_container && (prev_wdg_container == wdg))
1343 { 1464 {
1344 /* Append content memento to the creation memento (which was created in _editor_factory_wdg_create() 1465 /* Dragging inside the same box, just reorder items. */
1345 * in order to correctly manage internals. */ 1466 if (!strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
1346 Object_Container *_old_container, *_new_container; 1467 {
1347 _old_container = (Object_Container *) wdg_obj_container_get(wdg); 1468 /* Get current(previous) index of draggable wdg. */
1348 _new_container = obj_container_copy(_old_container); 1469 int cur_visual_idx = wdg_obj_container_item_idx_get(wdg, wdg_dep_id_get(new_wdg), EINA_TRUE);
1470 int reorder_delta = di->box_pack_idx - cur_visual_idx;
1349 1471
1350 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(wdg), 1472 Object_Container *_old_container, *_new_container;
1351 MEMENTO_OBJ_CONTAINER_ITEM, 1473 _old_container = (Object_Container *) wdg_obj_container_get((Gui_Widget *) wdg);
1352 _old_container, _new_container); 1474 _new_container = obj_container_copy(_old_container);
1353 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(wdg_context_get(wdg)), memento_next); 1475
1354 wdg_obj_container_unset(wdg); 1476 obj_container_ref(_old_container);
1355 wdg_obj_container_set(wdg, _new_container); 1477 wdg_obj_container_unset((Gui_Widget *) wdg);
1478 wdg_obj_container_set((Gui_Widget *) wdg, _new_container);
1356 1479
1357 const Op_Desc *op_desc = db_container_desc_op_desc_get(db_container_desc_get(wdg_class_name_get(wdg)), CONTAINER_PACK); 1480 /* If anything was reordered, need to reload content. */
1358 Gui_Widget_Property *prop = prop_create_for_op(op_desc); 1481 if (wdg_obj_container_content_reorder(wdg, cur_visual_idx, reorder_delta))
1359 Gui_Value *val = prop_value_nth_get(prop, 0); 1482 {
1360 gui_value_name_id_set(val, GUI_TYPE_OBJECT, wdg_dep_id_get(new_wdg)); 1483 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_OBJ_CONTAINER_ITEM, _old_container, _new_container);
1484 gui_context_memento_add(_active_context_get(), memento);
1485 }
1486 obj_container_unref(_old_container);
1487 }
1488 else if (!strcmp(wdg_class_name_get(wdg), DB_DEF_TABLE_CLASS))
1489 {
1490 Object_Container_Item *ci = wdg_obj_container_item_get(wdg, -1, wdg_name_get(new_wdg));
1491 Dep_Id *ci_dep_id = obj_container_item_dep_id_get(ci);
1492 const Gui_Widget_Property *ci_prop = obj_container_item_prop_get(ci);
1493 if ((INT_GET(prop_value_nth_get(ci_prop, 1)) != di->table_pack_x) ||
1494 (INT_GET(prop_value_nth_get(ci_prop, 2)) != di->table_pack_y))
1495 {
1496 Object_Container *_old_container, *_new_container;
1497 _old_container = (Object_Container *) wdg_obj_container_get((Gui_Widget *) wdg);
1498 _new_container = obj_container_copy(_old_container);
1499
1500 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(wdg), MEMENTO_OBJ_CONTAINER_ITEM, _old_container, _new_container);
1501 gui_context_memento_add((Gui_Context *) ctx, memento);
1502
1503 Eina_List *old_lst = wdg_obj_container_contents_list_get(wdg);
1504 wdg_obj_container_unset((Gui_Widget *) wdg);
1505 wdg_obj_container_set((Gui_Widget *) wdg, _new_container);
1506
1507 /* Delete everything in new_container */
1508 wdg_obj_container_item_remove_all(wdg);
1509
1510 /* Iterate over old list and create new container items and properties.
1511 * Also get packing coordinates from Eo object and put it into property. */
1512 Eo *wdg_eo = session_eo_get(session, wdg);
1513 Object_Container_Item *it;
1514 Eina_List *l;
1515 EINA_LIST_FOREACH(old_lst, l, it)
1516 {
1517 int ix, iy, iw, ih;
1518 Gui_Widget_Property *prop = obj_container_item_prop_get(it);
1519 Dep_Id *dep_id = obj_container_item_dep_id_get(it);
1520 Gui_Widget_Property *new_prop = prop_copy(prop);
1521 Eo *c = session_eo_get(session, wdg_get(dep_id));
1522 eo_do(wdg_eo, elm_obj_table_pack_get(c, &ix, &iy, &iw, &ih));
1361 1523
1362 Object_Container_Item *ci = obj_container_item_new(prop, wdg_dep_id_get(new_wdg)); 1524 if (dep_id == ci_dep_id)
1363 wdg_obj_container_item_add(wdg, ci, di->box_pack_idx); 1525 {
1526 ix = di->table_pack_x;
1527 iy = di->table_pack_y;
1528 }
1529 gui_value_int_set(prop_value_nth_get(new_prop, 1), ix);
1530 gui_value_int_set(prop_value_nth_get(new_prop, 2), iy);
1364 1531
1365 _wdg_parent_win_reload(new_wdg); 1532 ci = obj_container_item_new(new_prop, dep_id);
1366 _editor_wdg_selected_set(new_wdg); 1533 wdg_obj_container_item_add((Gui_Widget *) wdg, ci, -1);
1367 objtree_item_selected_set(new_wdg); 1534 }
1535 }
1536 }
1537 goto end;
1368 } 1538 }
1369 else if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_TABLE_CLASS)) 1539 /* Dragging inside window - only change position. */
1540 else if ((wdg_parent == wdg) && IS_WIN(wdg))
1370 { 1541 {
1371 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg)); 1542 if (new_wdg)
1372 Eo *wdg_eo = session_eo_get(session, wdg); 1543 {
1373 Object_Container_Item *it; 1544 Gui_Widget_Property *old_prop, *prop;
1545 Gui_Value *val;
1546 old_prop = wdg_prop_get(new_wdg, DB_DEF_EVAS_OBJECT_CLASS, POSITION_SET);
1547 if (!old_prop)
1548 {
1549 Op_Desc *op = db_mro_op_desc_get(wdg_class_name_get(new_wdg), DB_DEF_EVAS_OBJECT_CLASS, POSITION_SET);
1550 prop = prop_create_for_op(op);
1551 }
1552 else
1553 {
1554 prop = prop_copy(old_prop);
1555 }
1374 1556
1375 Object_Container *_old_container, *_new_container; 1557 val = prop_value_nth_get(prop, 0);
1376 _old_container = (Object_Container *) wdg_obj_container_get(wdg); 1558 gui_value_int_set(val, di->pointer_x);
1377 _new_container = obj_container_copy(_old_container); 1559 val = prop_value_nth_get(prop, 1);
1560 gui_value_int_set(val, di->pointer_y);
1561 propview_item_update(prop);
1562
1563 Gui_Memento *memento = NULL;
1564 memento = gui_memento_new(wdg_dep_id_get(new_wdg), MEMENTO_PROPERTY, old_prop, prop);
1565
1566 /* If drag_data != EDITOR_DRAG_DATA then new widget wass dragged from the factory,
1567 * so memento must be added to the previous one. */
1568 if (strcmp(drag_data, EDITOR_DRAG_DATA))
1569 {
1570 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento);
1571 }
1572 else
1573 {
1574 gui_context_memento_add((Gui_Context *) ctx, memento);
1575 }
1378 1576
1379 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(wdg), 1577 if (old_prop)
1578 {
1579 wdg_prop_remove((Gui_Widget *) new_wdg, old_prop);
1580 }
1581 wdg_prop_add((Gui_Widget *) new_wdg, prop);
1582 }
1583 goto end;
1584 }
1585
1586 /* Dragging main wdg around canvas. */
1587 else if (!wdg_parent && !wdg)
1588 {
1589 wdg_data_set(new_wdg, CURSOR_DROP_X, (void *) (intptr_t) di->pointer_x);
1590 wdg_data_set(new_wdg, CURSOR_DROP_Y, (void *) (intptr_t) di->pointer_y);
1591 goto end;
1592 }
1593 /* If dragging from one container to another, unpack from the first one*/
1594 if (prev_wdg_container && (prev_wdg_container != wdg))
1595 {
1596 Object_Container *_old_prev_container, *_new_prev_container;
1597 _old_prev_container = (Object_Container *) wdg_obj_container_get((Gui_Widget *) prev_wdg_container);
1598 _new_prev_container = obj_container_copy(_old_prev_container);
1599 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(prev_wdg_container),
1380 MEMENTO_OBJ_CONTAINER_ITEM, 1600 MEMENTO_OBJ_CONTAINER_ITEM,
1381 _old_container, _new_container); 1601 _old_prev_container, _new_prev_container);
1382 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(wdg_context_get(wdg)), memento_next); 1602 gui_context_memento_add((Gui_Context *) ctx, memento);
1603 wdg_obj_container_unset((Gui_Widget *) prev_wdg_container);
1604 wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container);
1383 1605
1384 Eina_List *old_lst = wdg_obj_container_contents_list_get(wdg); 1606 /* Take old container's class name from content-property. */
1385 wdg_obj_container_unset(wdg); 1607 Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, wdg_name_get(new_wdg));
1386 wdg_obj_container_set(wdg, _new_container); 1608 wdg_obj_container_item_remove(prev_wdg_container, _ci);
1609 }
1610 /* If dragging from a widget(window), unset parent*/
1611 else if (wdg_parent && (wdg_parent != wdg))
1612 {
1613 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(new_wdg),
1614 MEMENTO_WIDGET_PARENT,
1615 wdg_parent_id_get(new_wdg), NULL);
1616 gui_context_memento_add((Gui_Context *) ctx, memento);
1617 wdg_parent_set((Gui_Widget *) new_wdg, NULL);
1618 }
1619 else if (!wdg_parent)
1620 {
1621 Gui_Memento *memento = gui_memento_new(wdg_dep_id_get(new_wdg),
1622 MEMENTO_WIDGET_PARENT,
1623 NULL, NULL);
1624 gui_context_memento_add((Gui_Context *) ctx, memento);
1625 }
1387 1626
1388 /* Delete everythin in new_container */ 1627 if (!wdg)
1389 Eina_List *lst = wdg_obj_container_contents_list_get(wdg), *l, *l2; 1628 {
1390 EINA_LIST_FOREACH_SAFE(lst, l, l2, it) 1629 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(new_wdg),
1630 MEMENTO_WIDGET_PARENT,
1631 wdg_parent_id_get(new_wdg), NULL);
1632 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next);
1633 wdg_parent_set((Gui_Widget *) new_wdg, NULL);
1634 if (IS_MAIN(new_wdg))
1391 { 1635 {
1392 wdg_obj_container_item_remove(wdg, it); 1636 wdg_data_set(new_wdg, CURSOR_DROP_X, (void *) (intptr_t) di->pointer_x);
1637 wdg_data_set(new_wdg, CURSOR_DROP_Y, (void *) (intptr_t) di->pointer_y);
1393 } 1638 }
1394 1639 }
1395 /* Iterate over old list and clreate new container items and properties. 1640 else if (wdg && IS_WIN(wdg))
1396 * Also get packing coordinates from Eo object and put it into property. */ 1641 {
1397 EINA_LIST_FOREACH(old_lst, l, it) 1642 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(new_wdg),
1643 MEMENTO_WIDGET_PARENT,
1644 wdg_parent_id_get(new_wdg), wdg_dep_id_get(wdg));
1645 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next);
1646 wdg_parent_set((Gui_Widget *) new_wdg, wdg_name_get(wdg));
1647 }
1648 else
1649 {
1650 if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_BOX_CLASS))
1398 { 1651 {
1399 Gui_Widget_Property *prop = obj_container_item_prop_get(it); 1652 /* Append content memento to the creation memento (which was created in _editor_factory_wdg_create())
1400 Gui_Widget_Property *new_prop = prop_copy(prop); 1653 * or to memento unpacking from previous container
1401 int ix, iy, iw, ih; 1654 * in order to correctly manage internals. */
1402 Dep_Id *dep_id = obj_container_item_dep_id_get(it); 1655 Object_Container *_old_container, *_new_container;
1403 Eo *c = session_eo_get(session, wdg_get(dep_id)); 1656 _old_container = (Object_Container *) wdg_obj_container_get(wdg);
1404 eo_do(wdg_eo, elm_obj_table_pack_get(c, &ix, &iy, &iw, &ih)); 1657 _new_container = obj_container_copy(_old_container);
1658
1659 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(wdg),
1660 MEMENTO_OBJ_CONTAINER_ITEM,
1661 _old_container, _new_container);
1662 /* Current memento is a memento created, during _factory _widget_create earlier in this func. */
1663 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next);
1664 wdg_obj_container_unset(wdg);
1665 wdg_obj_container_set(wdg, _new_container);
1405 1666
1406 gui_value_int_set(prop_value_nth_get(new_prop, 1), ix); 1667 const Op_Desc *op_desc = db_container_desc_op_desc_get(db_container_desc_get(wdg_class_name_get(wdg)), CONTAINER_PACK);
1407 gui_value_int_set(prop_value_nth_get(new_prop, 2), iy); 1668 Gui_Widget_Property *prop = prop_create_for_op(op_desc);
1669 Gui_Value *val = prop_value_nth_get(prop, 0);
1670 gui_value_name_id_set(val, GUI_TYPE_OBJECT, wdg_dep_id_get(new_wdg));
1408 1671
1409 Object_Container_Item *ci = obj_container_item_new(new_prop, dep_id); 1672 Object_Container_Item *ci = obj_container_item_new(prop, wdg_dep_id_get(new_wdg));
1410 wdg_obj_container_item_add((Gui_Widget *) wdg, ci, -1); 1673 wdg_obj_container_item_add(wdg, ci, di->box_pack_idx);
1411 } 1674 }
1675 else if (wdg && !strcmp(wdg_class_name_get(wdg), DB_DEF_TABLE_CLASS))
1676 {
1677 Eo *wdg_eo = session_eo_get(session, wdg);
1678 Object_Container_Item *it;
1679
1680 Object_Container *_old_container, *_new_container;
1681 _old_container = (Object_Container *) wdg_obj_container_get(wdg);
1682 _new_container = obj_container_copy(_old_container);
1683
1684 Gui_Memento *memento_next = gui_memento_new(wdg_dep_id_get(wdg),
1685 MEMENTO_OBJ_CONTAINER_ITEM,
1686 _old_container, _new_container);
1687 /* Current memento is a memento created, during _factory _widget_create earlier in this func. */
1688 gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento_next);
1689
1690 Eina_List *old_lst = wdg_obj_container_contents_list_get(wdg);
1691 wdg_obj_container_unset(wdg);
1692 wdg_obj_container_set(wdg, _new_container);
1693
1694 /* Delete everything in new_container */
1695 wdg_obj_container_item_remove_all(wdg);
1696
1697 /* Iterate over old list and create new container items and properties.
1698 * Also get packing coordinates from Eo object and put it into property. */
1699 Eina_List *l;
1700 EINA_LIST_FOREACH(old_lst, l, it)
1701 {
1702 Gui_Widget_Property *prop = obj_container_item_prop_get(it);
1703 Gui_Widget_Property *new_prop = prop_copy(prop);
1704 int ix, iy, iw, ih;
1705 Dep_Id *dep_id = obj_container_item_dep_id_get(it);
1706 Eo *c = session_eo_get(session, wdg_get(dep_id));
1707 eo_do(wdg_eo, elm_obj_table_pack_get(c, &ix, &iy, &iw, &ih));
1708
1709 gui_value_int_set(prop_value_nth_get(new_prop, 1), ix);
1710 gui_value_int_set(prop_value_nth_get(new_prop, 2), iy);
1711
1712 Object_Container_Item *ci = obj_container_item_new(new_prop, dep_id);
1713 wdg_obj_container_item_add((Gui_Widget *) wdg, ci, -1);
1714 }
1412 1715
1413 /* Add new element into the container */ 1716 /* Add new element into the container */
1414 const Op_Desc *op_desc = db_container_desc_op_desc_get(db_container_desc_get(wdg_class_name_get(wdg)), CONTAINER_PACK); 1717 const Op_Desc *op_desc = db_container_desc_op_desc_get(db_container_desc_get(wdg_class_name_get(wdg)), CONTAINER_PACK);
1415 Gui_Widget_Property *prop = prop_create_for_op(op_desc); 1718 Gui_Widget_Property *prop = prop_create_for_op(op_desc);
1416 1719
1417 gui_value_name_id_set(prop_value_nth_get(prop, 0), GUI_TYPE_OBJECT, wdg_dep_id_get(new_wdg)); 1720 gui_value_name_id_set(prop_value_nth_get(prop, 0), GUI_TYPE_OBJECT, wdg_dep_id_get(new_wdg));
1418 gui_value_int_set(prop_value_nth_get(prop, 1), di->table_pack_x); 1721 gui_value_int_set(prop_value_nth_get(prop, 1), di->table_pack_x);
1419 gui_value_int_set(prop_value_nth_get(prop, 2), di->table_pack_y); 1722 gui_value_int_set(prop_value_nth_get(prop, 2), di->table_pack_y);
1420 gui_value_int_set(prop_value_nth_get(prop, 3), 1); 1723 gui_value_int_set(prop_value_nth_get(prop, 3), 1);
1421 gui_value_int_set(prop_value_nth_get(prop, 4), 1); 1724 gui_value_int_set(prop_value_nth_get(prop, 4), 1);
1422 1725
1423 Object_Container_Item *ci = obj_container_item_new(prop, wdg_dep_id_get(new_wdg)); 1726 Object_Container_Item *ci = obj_container_item_new(prop, wdg_dep_id_get(new_wdg));
1424 wdg_obj_container_item_add(wdg, ci, -1); 1727 wdg_obj_container_item_add(wdg, ci, -1);
1728 }
1729 }
1730end:
1425 1731
1426 _wdg_parent_win_reload(new_wdg); 1732 if (di->eo_cur)
1427 _editor_wdg_selected_set(new_wdg); 1733 {
1428 objtree_item_selected_set(new_wdg); 1734 const Gui_Widget *dragged_wdg = dnd_drag_wdg_get();
1735 if (dragged_wdg)
1736 {
1737 _drag_obj_del(dragged_wdg, canvas);
1738 drag_stop();
1739 }
1740 else
1741 {
1742 eo_del(di->eo_cur);
1743 }
1744 di->eo_cur = NULL;
1429 } 1745 }
1430 1746
1747 _wdg_parent_win_reload(new_wdg);
1748 _editor_wdg_selected_set(new_wdg);
1749 objtree_item_selected_set(new_wdg);
1750
1431 return EINA_TRUE; 1751 return EINA_TRUE;
1432} 1752}
1433 1753
@@ -1447,7 +1767,6 @@ _table_cell_segment_get(int x, int y, int cell_w, int cell_h, int *_part_x, int
1447 if (_part_y) *_part_y = part_y; 1767 if (_part_y) *_part_y = part_y;
1448} 1768}
1449 1769
1450
1451/* x, y - coordinates of pointers relative to droppable object. */ 1770/* x, y - coordinates of pointers relative to droppable object. */
1452static void 1771static void
1453_drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action EINA_UNUSED) 1772_drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action EINA_UNUSED)
@@ -1458,10 +1777,9 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1458 Eo *wdg_eo; 1777 Eo *wdg_eo;
1459 Evas_Coord obj_x = 0, obj_y = 0; 1778 Evas_Coord obj_x = 0, obj_y = 0;
1460 /* If wdg == NULL, then canvas is a drop target or we have a error.*/ 1779 /* If wdg == NULL, then canvas is a drop target or we have a error.*/
1461 ERR("pointer: %d %d", x ,y);
1462 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg));
1463 if (wdg) 1780 if (wdg)
1464 { 1781 {
1782 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1465 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1783 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
1466 wdg_eo = session_eo_get(session, wdg); 1784 wdg_eo = session_eo_get(session, wdg);
1467 if (!IS_MAIN(wdg)) 1785 if (!IS_MAIN(wdg))
@@ -1490,7 +1808,7 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1490 { 1808 {
1491 Eo *child, *candidate = NULL; 1809 Eo *child, *candidate = NULL;
1492 int idx = 0; 1810 int idx = 0;
1493 if (di->packed) 1811 //if (di->packed)
1494 eo_do(wdg_eo, elm_obj_box_unpack(di->eo_cur)); 1812 eo_do(wdg_eo, elm_obj_box_unpack(di->eo_cur));
1495 Eina_List *box_chld = eo_do(wdg_eo, elm_obj_box_children_get()), *l; 1813 Eina_List *box_chld = eo_do(wdg_eo, elm_obj_box_children_get()), *l;
1496 di->box_pack_idx = 0; 1814 di->box_pack_idx = 0;
@@ -1639,6 +1957,10 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1639 iw = INT_GET(prop_value_nth_get(prop, 3)); 1957 iw = INT_GET(prop_value_nth_get(prop, 3));
1640 ih = INT_GET(prop_value_nth_get(prop, 4)); 1958 ih = INT_GET(prop_value_nth_get(prop, 4));
1641 dep_id = DEP_ID_GET(prop_value_nth_get(prop, 0)); 1959 dep_id = DEP_ID_GET(prop_value_nth_get(prop, 0));
1960 /* Don't pack widget which is currently dragged. */
1961 if (dnd_drag_wdg_get() == wdg_get(dep_id))
1962 continue;
1963 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1642 Eo *c = session_eo_get(session, wdg_get(dep_id)); 1964 Eo *c = session_eo_get(session, wdg_get(dep_id));
1643 eo_do(wdg_eo, elm_obj_table_pack_set(c, ix, iy, iw, ih)); 1965 eo_do(wdg_eo, elm_obj_table_pack_set(c, ix, iy, iw, ih));
1644 } 1966 }
@@ -1650,6 +1972,9 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1650 Gui_Widget_Property *prop = obj_container_item_prop_get(it); 1972 Gui_Widget_Property *prop = obj_container_item_prop_get(it);
1651 int ix, iy, iw, ih; 1973 int ix, iy, iw, ih;
1652 Dep_Id *dep_id = DEP_ID_GET(prop_value_nth_get(prop, 0)); 1974 Dep_Id *dep_id = DEP_ID_GET(prop_value_nth_get(prop, 0));
1975 if (dnd_drag_wdg_get() == wdg_get(dep_id))
1976 continue;
1977 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
1653 Eo *c = session_eo_get(session, wdg_get(dep_id)); 1978 Eo *c = session_eo_get(session, wdg_get(dep_id));
1654 1979
1655 eo_do(wdg_eo, elm_obj_table_pack_get(c, &ix, &iy, &iw, &ih)); 1980 eo_do(wdg_eo, elm_obj_table_pack_get(c, &ix, &iy, &iw, &ih));
@@ -1689,6 +2014,74 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1689 2014
1690/*********************************************************/ 2015/*********************************************************/
1691 2016
2017/* This callback is called only when widget is dragged,
2018 * so wdg is not NULL. */
2019void
2020_drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo)
2021{
2022 Eo *wdg_eo = (Eo *) _wdg_eo;
2023 eo_do(wdg_eo, evas_obj_visibility_set(EINA_FALSE));
2024 Gui_Widget *wdg_container = NULL;
2025 Gui_Widget *wdg_parent = (Gui_Widget *) wdg_parent_get(wdg);
2026
2027 /* Unset selected widget. */
2028 _editor_wdg_selected_set(NULL);
2029
2030 const Gui_Session *session = gui_context_editor_session_get(wdg_context_get(wdg));
2031 if (!wdg_obj_container_item_get(wdg_parent, -1, wdg_name_get(wdg)))
2032 wdg_container = wdg_parent;
2033
2034 /* Explicitly call enter cb in order to create object, which will be dragged. */
2035 Evas_Coord x, y;
2036 if (IS_MAIN(wdg))
2037 {
2038 _drop_target_main_wdg_enter(NULL, egui_layout_gui_get()->main_win->canvas_bg);
2039 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2040 Eo *fr = main_wdg_info_frame_get(wi);
2041 eo_do(fr, evas_obj_position_get(&x, &y));
2042 }
2043 else
2044 {
2045 _drop_target_main_wdg_enter((Gui_Widget *) wdg_main_wdg_get(wdg), NULL);
2046 eo_do(wdg_eo, evas_obj_position_get(&x, &y));
2047 }
2048 /* Unpack Eo object if dragging from container. */
2049 if (wdg_container)
2050 {
2051 Eo *wdg_cont_eo = session_eo_get(session, wdg_container);
2052
2053 if (!strcmp(wdg_class_name_get(wdg_container), DB_DEF_BOX_CLASS))
2054 {
2055 eo_do(wdg_cont_eo, elm_obj_box_unpack(wdg_eo));
2056 }
2057 else if (!strcmp(wdg_class_name_get(wdg_container), DB_DEF_TABLE_CLASS))
2058 {
2059 eo_do(wdg_cont_eo, elm_obj_table_unpack(wdg_eo));
2060 }
2061 /* Explicitly call target enter/pos cb, in order to calculate packing coords. */
2062 _drop_target_enter(wdg_container, NULL);
2063 _drop_target_pos(wdg_container, NULL, x, y, ELM_XDND_ACTION_UNKNOWN);
2064 }
2065 /* Case for main object. */
2066 else if (!wdg_parent)
2067 {
2068 _drop_target_pos(NULL, egui_layout_gui_get()->main_win->canvas_bg, x, y, ELM_XDND_ACTION_UNKNOWN);
2069
2070 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2071 wdg_data_set(wdg, MAIN_WDG_INFO, NULL);
2072 if (wi)
2073 {
2074 Eo *fr = main_wdg_info_frame_get(wi);
2075 Eo *o = session_eo_get(session, wdg);
2076 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2077 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2078 eo_del(optional_win);
2079 eo_del(fr);
2080 free(wi);
2081 }
2082 }
2083}
2084
1692static Eina_Bool 2085static Eina_Bool
1693_widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data) 2086_widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1694{ 2087{
@@ -1697,16 +2090,7 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1697 Eo *o = _ffi_eo_add(session, wdg, NULL); 2090 Eo *o = _ffi_eo_add(session, wdg, NULL);
1698 if (!o) return EINA_FALSE; 2091 if (!o) return EINA_FALSE;
1699 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg)); 2092 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg));
1700 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, wdg_context_get(wdg)); 2093
1701 //evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _mouse_up, NULL);
1702 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _mouse_up, NULL));
1703 /* To avoid dragging box, when want to drag button. */
1704 evas_object_propagate_events_set(o, EINA_FALSE);
1705 /* Add callbacks to show widget resize arrows */
1706#if 0
1707 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mouse_in, NULL);
1708 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mouse_out, NULL);
1709#endif
1710 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, NULL)); 2094 eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, NULL));
1711 /* Add specific callbacks, related to UI. */ 2095 /* Add specific callbacks, related to UI. */
1712 session_eo_set(session, wdg, o); 2096 session_eo_set(session, wdg, o);
@@ -1802,6 +2186,8 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data)
1802 eo_do(fr, eo_key_data_set("winwdg", wdg, NULL)); 2186 eo_do(fr, eo_key_data_set("winwdg", wdg, NULL));
1803 } 2187 }
1804 fr = main_wdg_info_frame_get(wi); 2188 fr = main_wdg_info_frame_get(wi);
2189 evas_object_event_callback_add(iwin, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_main, wdg);
2190 evas_object_event_callback_add(iwin, EVAS_CALLBACK_MOUSE_UP, _mouse_up_main, wdg);
1805 2191
1806 DnD_Info *di = calloc (1, sizeof(DnD_Info)); 2192 DnD_Info *di = calloc (1, sizeof(DnD_Info));
1807 wdg_data_set(wdg, EDITOR_DND_DATA, di); 2193 wdg_data_set(wdg, EDITOR_DND_DATA, di);
@@ -2091,8 +2477,28 @@ _editor_undo(const Gui_Context *ctx)
2091 case MEMENTO_WIDGET_PARENT: 2477 case MEMENTO_WIDGET_PARENT:
2092 { 2478 {
2093 Dep_Id *wdg_id = gui_memento_wdg_get(memento); 2479 Dep_Id *wdg_id = gui_memento_wdg_get(memento);
2480 Gui_Widget *wdg = wdg_get(wdg_id);
2481 /* According to current scenario, widget can be dragged from another and dropped to canvas.
2482 * Thus here can be only main_wdg which is going to be undoed.
2483 * So it's frame and editor window must be deleted and Main_Wdg_Info data must be freed. */
2484 if (IS_MAIN(wdg) && !IS_WIN(wdg))
2485 {
2486 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(_active_context_get());
2487 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2488 wdg_data_set(wdg, MAIN_WDG_INFO, NULL);
2489 if (wi)
2490 {
2491 Eo *fr = main_wdg_info_frame_get(wi);
2492 Eo *o = session_eo_get(session, wdg);
2493 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2494 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2495 eo_del(optional_win);
2496 eo_del(fr);
2497 free(wi);
2498 }
2499 }
2094 Dep_Id *old_parent_id = (Dep_Id *) gui_memento_old_pointer_get(memento); 2500 Dep_Id *old_parent_id = (Dep_Id *) gui_memento_old_pointer_get(memento);
2095 wdg_parent_set(wdg_get(wdg_id), dep_name_get(old_parent_id)); 2501 wdg_parent_set(wdg, dep_name_get(old_parent_id));
2096 break; 2502 break;
2097 } 2503 }
2098 case MEMENTO_ACTION: 2504 case MEMENTO_ACTION:
@@ -2276,8 +2682,28 @@ _editor_redo(const Gui_Context *ctx)
2276 case MEMENTO_WIDGET_PARENT: 2682 case MEMENTO_WIDGET_PARENT:
2277 { 2683 {
2278 Dep_Id *wdg_id = gui_memento_wdg_get(memento); 2684 Dep_Id *wdg_id = gui_memento_wdg_get(memento);
2685 Gui_Widget *wdg = wdg_get(wdg_id);
2686 /* According to current scenario, widget can be dragged from canvas and dropped into object.
2687 * Thus here can be only main_wdg which is going to be redoed.
2688 * So it's frame and editor window must be deleted and Main_Wdg_Info data must be freed. */
2689 if (IS_MAIN(wdg) && !IS_WIN(wdg))
2690 {
2691 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(_active_context_get());
2692 Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
2693 wdg_data_set(wdg, MAIN_WDG_INFO, NULL);
2694 if (wi)
2695 {
2696 Eo *fr = main_wdg_info_frame_get(wi);
2697 Eo *o = session_eo_get(session, wdg);
2698 Eo *optional_win = eo_do(o, eo_key_data_get("__editor_win"));
2699 //eo_do(fr, evas_obj_visibility_set(EINA_FALSE));
2700 eo_del(optional_win);
2701 eo_del(fr);
2702 free(wi);
2703 }
2704 }
2279 Dep_Id *new_parent_id = (Dep_Id *) gui_memento_new_pointer_get(memento); 2705 Dep_Id *new_parent_id = (Dep_Id *) gui_memento_new_pointer_get(memento);
2280 wdg_parent_set(wdg_get(wdg_id), dep_name_get(new_parent_id)); 2706 wdg_parent_set(wdg, dep_name_get(new_parent_id));
2281 break; 2707 break;
2282 } 2708 }
2283 case MEMENTO_ACTION: 2709 case MEMENTO_ACTION:
@@ -3403,7 +3829,6 @@ _content_change_from_propview(void *data EINA_UNUSED, Eo *obj, const Eo_Event_De
3403 wdg_obj_container_unset((Gui_Widget *) prev_wdg_container); 3829 wdg_obj_container_unset((Gui_Widget *) prev_wdg_container);
3404 wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container); 3830 wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container);
3405 3831
3406
3407 /* Take old container's class name from content-property. */ 3832 /* Take old container's class name from content-property. */
3408 Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, new_value); 3833 Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, new_value);
3409 Gui_Widget_Property *old_prop = obj_container_item_prop_get(_ci); 3834 Gui_Widget_Property *old_prop = obj_container_item_prop_get(_ci);