yakov pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=e8824b1c6f45ae8bf08c17f552770c3f537e7df9
commit e8824b1c6f45ae8bf08c17f552770c3f537e7df9 Author: Yakov Goldberg <[email protected]> Date: Mon Jan 12 15:18:13 2015 +0200 DnD: fix If dragging from factory, don't check in which widget drag started --- src/bin/egui_gui/editor.c | 63 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c index 14566b8..cbf427e 100644 --- a/src/bin/egui_gui/editor.c +++ b/src/bin/egui_gui/editor.c @@ -1654,7 +1654,10 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev) const Gui_Widget *new_wdg = NULL; const Gui_Context *ctx = _active_context_get(); const Gui_Session *session = gui_context_editor_session_get(ctx); - if (strcmp(drag_data, EDITOR_DRAG_DATA)) + /* If drag_data != EDITOR_DRAG_DATA then new widget was dragged from the factory. */ + Eina_Bool drag_from_factory = !!strcmp(drag_data, EDITOR_DRAG_DATA); + /* Drop when dragging from factory. */ + if (drag_from_factory) { /* Don't allow to drop Window from factory into Main Obj*/ if (!strcmp(DB_DEF_WIN_CLASS , drag_data) && wdg) @@ -1795,9 +1798,8 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev) Gui_Memento *memento = NULL; memento = gui_memento_new(wdg_eid_get(new_wdg), MEMENTO_PROPERTY, old_prop, prop); - /* If drag_data != EDITOR_DRAG_DATA then new widget wass dragged from the factory, - * so memento must be added to the previous one. */ - if (strcmp(drag_data, EDITOR_DRAG_DATA)) + /* If new widget was dragged from the factory, memento must be added to the previous one. */ + if (drag_from_factory) { gui_memento_append((Gui_Memento *) gui_context_current_memento_get(ctx), memento); } @@ -1822,40 +1824,45 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev) wdg_data_set(new_wdg, CURSOR_DROP_Y, (void *) (intptr_t) di->pointer_y); goto end; } - /* If dragging from one container to another, unpack from the first one*/ - if (prev_wdg_container && (prev_wdg_container != wdg)) + + if (!drag_from_factory) { - Object_Container *_old_prev_container, *_new_prev_container; - _old_prev_container = (Object_Container *) wdg_obj_container_get((Gui_Widget *) prev_wdg_container); - _new_prev_container = obj_container_copy(_old_prev_container); - Gui_Memento *memento = gui_memento_new(wdg_eid_get(prev_wdg_container), + /* If dragging from one container to another, unpack from the first one*/ + if (prev_wdg_container && (prev_wdg_container != wdg)) + { + Object_Container *_old_prev_container, *_new_prev_container; + _old_prev_container = (Object_Container *) wdg_obj_container_get((Gui_Widget *) prev_wdg_container); + _new_prev_container = obj_container_copy(_old_prev_container); + Gui_Memento *memento = gui_memento_new(wdg_eid_get(prev_wdg_container), MEMENTO_OBJ_CONTAINER_ITEM, _old_prev_container, _new_prev_container); - gui_context_memento_add((Gui_Context *) ctx, memento); - wdg_obj_container_unset((Gui_Widget *) prev_wdg_container); - wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container); + gui_context_memento_add((Gui_Context *) ctx, memento); + wdg_obj_container_unset((Gui_Widget *) prev_wdg_container); + wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container); - /* Take old container's class name from content-property. */ - Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, wdg_name_get(new_wdg)); - wdg_obj_container_item_remove(prev_wdg_container, _ci); - } - /* If dragging from a widget(window), unset parent*/ - else if (wdg_parent && (wdg_parent != wdg)) - { - Gui_Memento *memento = gui_memento_new(wdg_eid_get(new_wdg), + /* Take old container's class name from content-property. */ + Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, wdg_name_get(new_wdg)); + wdg_obj_container_item_remove(prev_wdg_container, _ci); + } + /* If dragging from a widget(window), unset parent*/ + else if (wdg_parent && (wdg_parent != wdg)) + { + Gui_Memento *memento = gui_memento_new(wdg_eid_get(new_wdg), MEMENTO_WIDGET_PARENT, wdg_parent_id_get(new_wdg), NULL); - gui_context_memento_add((Gui_Context *) ctx, memento); - wdg_parent_set((Gui_Widget *) new_wdg, NULL); - } - else if (!wdg_parent) - { - Gui_Memento *memento = gui_memento_new(wdg_eid_get(new_wdg), + gui_context_memento_add((Gui_Context *) ctx, memento); + wdg_parent_set((Gui_Widget *) new_wdg, NULL); + } + else if (!wdg_parent) + { + Gui_Memento *memento = gui_memento_new(wdg_eid_get(new_wdg), MEMENTO_WIDGET_PARENT, NULL, NULL); - gui_context_memento_add((Gui_Context *) ctx, memento); + gui_context_memento_add((Gui_Context *) ctx, memento); + } } + /* Where to drop. */ if (!wdg) { Gui_Memento *memento_next = gui_memento_new(wdg_eid_get(new_wdg), --
