yakov pushed a commit to branch master. http://git.enlightenment.org/tools/erigo.git/commit/?id=781bf31a5203f9274cb383f6b5d28e16668c1838
commit 781bf31a5203f9274cb383f6b5d28e16668c1838 Author: Yakov Goldberg <yako...@samsung.com> Date: Wed Nov 25 17:31:22 2015 +0200 Fix parent management when change widgets packing --- src/bin/gui/editor.c | 107 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 17 deletions(-) diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c index 42dd73f..7a05058 100644 --- a/src/bin/gui/editor.c +++ b/src/bin/gui/editor.c @@ -4147,6 +4147,7 @@ _content_change_from_propview(void *data EINA_UNUSED, Eo *obj, const Eo_Event_De /* Hoversel is used mainly to choose objects. * So here need to make most of the work on objects: adding, change dependencies, change parent, etc. */ + Eid *old_packed_eid = NULL; if (kl == ELM_HOVERSEL_CLASS) { const char *new_value = elm_object_item_part_text_get(event_info, NULL); @@ -4168,30 +4169,88 @@ _content_change_from_propview(void *data EINA_UNUSED, Eo *obj, const Eo_Event_De Eid *prev_parent_cont_eid = wdg_parent_container_eid_get(new_param_wdg); Gui_Widget *prev_wdg_container = prev_parent_cont_eid ? wdg_get(prev_parent_cont_eid) : NULL; - Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(ctx); - if (prev_wdg_container && (wdg_container_type_get(prev_wdg_container) == OBJ_CONTAINER)) + if (prev_wdg_container) { - 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); + if (wdg_container_type_get(prev_wdg_container) == OBJ_CONTAINER) + { + 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); - memento_command_add(wdg_eid_get(prev_wdg_container), - MEMENTO_OBJ_CONTAINER, - _old_prev_container, _new_prev_container); - wdg_obj_container_unset((Gui_Widget *) prev_wdg_container); - wdg_obj_container_set((Gui_Widget *) prev_wdg_container, _new_prev_container); + memento_command_add(wdg_eid_get(prev_wdg_container), + MEMENTO_OBJ_CONTAINER, + _old_prev_container, _new_prev_container); + 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, new_value); - Gui_Widget_Property *old_prop = obj_container_item_prop_get(_ci); + /* Take old container's class name from content-property. */ + Object_Container_Item *_ci = wdg_obj_container_item_get(prev_wdg_container, -1, new_value); + Gui_Widget_Property *old_prop = obj_container_item_prop_get(_ci); - const Op_Desc *old_op_desc = prop_op_desc_get(old_prop); - const char *old_container_name = db_op_desc_class_name_get(old_op_desc); + const Op_Desc *old_op_desc = prop_op_desc_get(old_prop); + const char *old_container_name = db_op_desc_class_name_get(old_op_desc); - manager_widget_content_unset(session, prev_wdg_container, old_container_name, old_prop, NULL); - wdg_obj_container_item_remove(prev_wdg_container, _ci); + Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(ctx); + manager_widget_content_unset(session, prev_wdg_container, old_container_name, old_prop, NULL); + wdg_obj_container_item_remove(prev_wdg_container, _ci); + } + else if (wdg_container_type_get(prev_wdg_container) == ITEM_CONTAINER) + { + const Eina_List *items_lst = item_container_item_subitems_get(wdg_item_container_root_get(prev_wdg_container)), *itr; + /* Detect if cursor is inside swallow object.*/ + Eid *eid_itr; + Item_Container_Item *cit; + const Gui_Widget_Property *it_prop; + int val_idx = 0; + Eina_Bool stop = EINA_FALSE; + EINA_LIST_FOREACH(items_lst, itr, eid_itr) + { + cit = item_container_item_get_from_id(eid_itr); + it_prop = item_container_item_prop_get(cit); + Eina_List *values = prop_value_get(it_prop), *itr2; + Gui_Value *it_val; + EINA_LIST_FOREACH(values, itr2, it_val) + { + if (gui_value_type_get(it_val) == GUI_TYPE_OBJECT) + { + if (new_name_id == EID_ID_GET(it_val)) + { + stop = EINA_TRUE; + break; + } + } + val_idx++; + } + if (stop) break; + val_idx = 0; + cit = NULL; + eid_itr = NULL; + it_prop = NULL; + } + + if (cit) + { + Item_Container_Item *new_wit = item_container_item_copy(cit); + memento_command_add(wdg_eid_get(prev_wdg_container), MEMENTO_ITEM_CONTAINER_ITEM, cit, new_wit); + + Gui_Widget_Property *new_it_prop = prop_copy(it_prop); + Gui_Value *it_val = prop_value_nth_get(new_it_prop, val_idx); + gui_value_name_id_set(it_val, GUI_TYPE_OBJECT, 0); + + item_container_item_prop_set(new_wit, new_it_prop); + item_container_item_set_on_id(item_container_item_eid_get(cit), new_wit); + + memento_command_add(wdg_eid_get(new_param_wdg), MEMENTO_WIDGET_PARENT, wdg_eid_get(prev_wdg_container), wdg_eid_get(wdg_main_wdg_get(prev_wdg_container))); + wdg_parent_set(new_param_wdg, wdg_name_get(wdg_main_wdg_get(prev_wdg_container))); + wdg_parent_container_eid_set(new_param_wdg, NULL); + } + } } + /* Need to unset object, which was packed in this place before*/ + Gui_Value *old_packed_val = prop_value_nth_get(prop, par_idx); + old_packed_eid = EID_ID_GET(old_packed_val); + Eid *eid = wdg_eid_get(new_param_wdg); gui_value_name_id_set(val, type, eid); @@ -4210,6 +4269,20 @@ _content_change_from_propview(void *data EINA_UNUSED, Eo *obj, const Eo_Event_De memento_command_add(wdg_eid_get(wdg), MEMENTO_OBJ_CONTAINER, _old_container, _new_container); obj_container_unref(_old_container); + if (old_packed_eid) + { + if (eid_is_dummy(old_packed_eid)) + { + memento_command_add(old_packed_eid, MEMENTO_WIDGET, (void *) (intptr_t) EINA_TRUE, (void *) (intptr_t) EINA_FALSE); + } + else + { + Gui_Widget *old_packed_wdg = wdg_get(old_packed_eid); + memento_command_add(old_packed_eid, MEMENTO_WIDGET_PARENT, wdg_eid_get(wdg_parent_get(old_packed_wdg)), wdg_eid_get(wdg_main_wdg_get(old_packed_wdg))); + wdg_parent_set(old_packed_wdg, wdg_name_get(wdg_main_wdg_get(old_packed_wdg))); + } + } + context_memento_finalize(ctx); return EO_CALLBACK_CONTINUE; --