rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=4cc8275a8b6dc11a54c119eb3e8aefc57160045f
commit 4cc8275a8b6dc11a54c119eb3e8aefc57160045f Author: Vitalii Vorobiov <vi.vorob...@samsung.com> Date: Tue Oct 4 17:44:30 2016 +0300 editor: part item index above and below restack correct reimplementation --- src/bin/common/signals.h | 4 +- src/bin/editor/banned_edje_edit_api.h | 34 ++++++- src/bin/editor/editor.h | 7 +- src/bin/editor/editor_part.c | 113 +++++++++++----------- src/bin/resource_manager/resource_manager_react.c | 32 ++++-- src/bin/ui/tabs.c | 2 +- src/bin/ui/workspace/group_navigator.c | 66 +++++++------ src/bin/ui/workspace/group_navigator.h | 2 +- src/bin/ui/workspace/workspace.c | 4 +- src/bin/ui/workspace/workspace.h | 2 +- 10 files changed, 158 insertions(+), 108 deletions(-) diff --git a/src/bin/common/signals.h b/src/bin/common/signals.h index 1de2dec..94b61f2 100644 --- a/src/bin/common/signals.h +++ b/src/bin/common/signals.h @@ -491,10 +491,8 @@ typedef struct { typedef struct { const char *part_name; - const char *part_item; - const char *relative_part_item; unsigned int item_index; - unsigned int relative_item_index; + Eina_Bool item_move_up; } Editor_Part_Item_Restack; /** * emited when part item is restacked. diff --git a/src/bin/editor/banned_edje_edit_api.h b/src/bin/editor/banned_edje_edit_api.h index fb67ecd..04bc9f0 100644 --- a/src/bin/editor/banned_edje_edit_api.h +++ b/src/bin/editor/banned_edje_edit_api.h @@ -117,8 +117,38 @@ #pragma GCC poison edje_edit_part_drag_confine_set #pragma GCC poison edje_edit_part_drag_event_set #pragma GCC poison edje_edit_part_drag_threshold_set -//#pragma GCC poison edje_edit_part_item_append -//#pragma GCC poison edje_edit_part_item_del + +#pragma GCC poison edje_edit_part_item_move_below_index +#pragma GCC poison edje_edit_part_item_move_below_above +#pragma GCC poison edje_edit_part_item_index_append +#pragma GCC poison edje_edit_part_item_index_del +#pragma GCC poison edje_edit_part_item_index_source_set +#pragma GCC poison edje_edit_part_item_index_min_w_set +#pragma GCC poison edje_edit_part_item_index_min_h_set +#pragma GCC poison edje_edit_part_item_index_max_w_set +#pragma GCC poison edje_edit_part_item_index_max_h_set +#pragma GCC poison edje_edit_part_item_index_aspect_w_set +#pragma GCC poison edje_edit_part_item_index_aspect_h_set +#pragma GCC poison edje_edit_part_item_index_aspect_mode_set +#pragma GCC poison edje_edit_part_item_index_prefer_w_set +#pragma GCC poison edje_edit_part_item_index_prefer_h_set +#pragma GCC poison edje_edit_part_item_index_spread_w_set +#pragma GCC poison edje_edit_part_item_index_spread_h_set +#pragma GCC poison edje_edit_part_item_index_padding_set +#pragma GCC poison edje_edit_part_item_index_align_x_set +#pragma GCC poison edje_edit_part_item_index_align_y_set +#pragma GCC poison edje_edit_part_item_index_weight_x_set +#pragma GCC poison edje_edit_part_item_index_weight_y_set +#pragma GCC poison edje_edit_part_item_index_position_set +#pragma GCC poison edje_edit_part_item_index_position_col_set +#pragma GCC poison edje_edit_part_item_index_position_row_set +#pragma GCC poison edje_edit_part_item_index_span_set +#pragma GCC poison edje_edit_part_item_index_span_col_set +#pragma GCC poison edje_edit_part_item_index_span_row_set + +/* OLD PART ITEM API WE SHOULDN'T USE */ +#pragma GCC poison edje_edit_part_item_append +#pragma GCC poison edje_edit_part_item_del #pragma GCC poison edje_edit_part_item_source_set #pragma GCC poison edje_edit_part_item_min_w_set #pragma GCC poison edje_edit_part_item_min_h_set diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h index 3dc61cd..1569708 100644 --- a/src/bin/editor/editor.h +++ b/src/bin/editor/editor.h @@ -618,8 +618,11 @@ Eina_Bool editor_part_restack(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, const char *part_name, const char *relative_part) EINA_WARN_UNUSED_RESULT; Eina_Bool -editor_part_item_index_restack(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, - const char *part_name, unsigned int index, unsigned int index_relative, Eina_Bool relative) EINA_WARN_UNUSED_RESULT; +editor_part_item_index_restack_above(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, + const char *part_name, unsigned int index) EINA_WARN_UNUSED_RESULT; +Eina_Bool +editor_part_item_index_restack_below(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, + const char *part_name, unsigned int index) EINA_WARN_UNUSED_RESULT; Eina_Bool editor_part_item_index_append(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, const char *part_name, const char *item_name, const char *source_group) EINA_WARN_UNUSED_RESULT; diff --git a/src/bin/editor/editor_part.c b/src/bin/editor/editor_part.c index 5243a1e..d13d72b 100644 --- a/src/bin/editor/editor_part.c +++ b/src/bin/editor/editor_part.c @@ -637,7 +637,6 @@ editor_part_cursor_mode_set(Evas_Object *edit_object, Change *change, Eina_Bool return true; } -static Eina_Bool _part_item_restacking; Eina_Bool editor_part_item_index_reset(Evas_Object *edit_object, Change *change, Eina_Bool apply, const char *part_name, unsigned int index) @@ -679,8 +678,6 @@ editor_part_item_index_reset(Evas_Object *edit_object, Change *change, Eina_Bool res = res && editor_part_item_index_padding_bottom_reset(edit_object, change, apply, part_name, index); res = res && editor_part_item_index_padding_left_reset(edit_object, change, apply, part_name, index); res = res && editor_part_item_index_padding_right_reset(edit_object, change, apply, part_name, index); - if (!_part_item_restacking) - res = res && editor_part_item_index_restack(edit_object, change, false, apply, part_name, index, index, false); you_shall_pass_editor_signals(change); @@ -1134,85 +1131,85 @@ editor_part_restack(Evas_Object *edit_object, Change *change, Eina_Bool merge, E } Eina_Bool -editor_part_item_index_restack(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, - const char *part_name, unsigned int index, unsigned int index_relative, Eina_Bool relative) +editor_part_item_index_restack_above(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, + const char *part_name, unsigned int index) { Diff *diff; Editor_Part_Item_Restack event_info; - Change *virtual_change; - Eina_Bool res; - unsigned int count, i; assert(edit_object != NULL); assert(part_name != NULL); - count = edje_edit_part_items_count_get(edit_object, part_name); - if (change) { diff = mem_calloc(1, sizeof(Diff)); - diff->redo.type = FUNCTION_TYPE_STRING_UINT_UINT; - diff->redo.function = editor_part_item_index_restack; - diff->redo.args.type_suiui.s1 = eina_stringshare_add(part_name); - diff->redo.args.type_suiui.ui2 = index; - diff->redo.args.type_suiui.ui3 = index_relative; - diff->undo.type = FUNCTION_TYPE_STRING_UINT_UINT; - diff->undo.function = editor_part_item_index_restack; - diff->undo.args.type_suiui.s1 = eina_stringshare_add(part_name); - diff->undo.args.type_suiui.ui2 = index; - diff->undo.args.type_suiui.ui3 = index_relative; + diff->redo.type = FUNCTION_TYPE_STRING_UINT; + diff->redo.function = editor_part_item_index_restack_above; + diff->redo.args.type_sui.s1 = eina_stringshare_add(part_name); + diff->redo.args.type_sui.ui2 = index; + diff->undo.type = FUNCTION_TYPE_STRING_UINT; + diff->undo.function = editor_part_item_index_restack_below; + diff->undo.args.type_sui.s1 = eina_stringshare_add(part_name); + diff->undo.args.type_sui.ui2 = index + 1; if (merge) change_diff_merge_add(change, diff); else change_diff_add(change, diff); } - virtual_change = change_add(NULL); - you_shall_not_pass_editor_signals(NULL); - - _part_item_restacking = true; - if (relative) + if (apply) { - if (index + 1 != index_relative) + CRIT_ON_FAIL(edje_edit_part_item_move_above_index(edit_object, part_name, index)); + if (!_editor_signals_blocked) { - for(i = count - 1; i > index_relative; i--) - { - if (i == index) continue; - - res = editor_part_item_index_del(edit_object, virtual_change, false, apply, part_name, i); - assert(res); - - if (i == index_relative) break; - } - res = editor_part_item_index_del(edit_object, virtual_change, false, apply, part_name, index); - assert(res); - res = change_undo(edit_object, virtual_change); - assert(res); + event_info.part_name = eina_stringshare_add(part_name); + event_info.item_index = index; + event_info.item_move_up = false; + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_RESTACKED, &event_info); + eina_stringshare_del(event_info.part_name); } } - else + return true; +} + +Eina_Bool +editor_part_item_index_restack_below(Evas_Object *edit_object, Change *change, Eina_Bool merge, Eina_Bool apply, + const char *part_name, unsigned int index) +{ + Diff *diff; + Editor_Part_Item_Restack event_info; + + assert(edit_object != NULL); + assert(part_name != NULL); + + if (change) { - if (index + 2 < count) - { - res = editor_part_item_index_del(edit_object, virtual_change, false, apply, part_name, index); - assert(res); - res = change_undo(edit_object, virtual_change); - assert(res); - } + diff = mem_calloc(1, sizeof(Diff)); + diff->redo.type = FUNCTION_TYPE_STRING_UINT; + diff->redo.function = editor_part_item_index_restack_below; + diff->redo.args.type_sui.s1 = eina_stringshare_add(part_name); + diff->redo.args.type_sui.ui2 = index; + diff->undo.type = FUNCTION_TYPE_STRING_UINT; + diff->undo.function = editor_part_item_index_restack_above; + diff->undo.args.type_sui.s1 = eina_stringshare_add(part_name); + diff->undo.args.type_sui.ui2 = index - 1; + if (merge) + change_diff_merge_add(change, diff); + else + change_diff_add(change, diff); } - _part_item_restacking = false; - you_shall_pass_editor_signals(NULL); - change_free(virtual_change); - - _editor_project_changed(); - if (!_editor_signals_blocked) + if (apply) { - event_info.part_name = eina_stringshare_add(part_name); - event_info.item_index = index; - event_info.relative_item_index = index_relative; - evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_RESTACKED, &event_info); - eina_stringshare_del(event_info.part_name); + CRIT_ON_FAIL(edje_edit_part_item_move_below_index(edit_object, part_name, index)); + if (!_editor_signals_blocked) + { + event_info.part_name = eina_stringshare_add(part_name); + event_info.item_index = index; + event_info.item_move_up = true; + evas_object_smart_callback_call(ap.win, SIGNAL_EDITOR_PART_ITEM_RESTACKED, &event_info); + eina_stringshare_del(event_info.part_name); + } } return true; } diff --git a/src/bin/resource_manager/resource_manager_react.c b/src/bin/resource_manager/resource_manager_react.c index 875d62a..3af7aa2 100644 --- a/src/bin/resource_manager/resource_manager_react.c +++ b/src/bin/resource_manager/resource_manager_react.c @@ -864,19 +864,31 @@ _editor_part_item_restacked_cb(void *data __UNUSED__, Part_Item2 *part_item, *relative_part_item; Part2 *part = (Part2 *)resource_manager_find(group->parts, editor_part_item_restack->part_name); + part_item = (Part_Item2 *)resource_manager_id_find(part->items, editor_part_item_restack->item_index); - relative_part_item = (Part_Item2 *)resource_manager_id_find(part->items, - editor_part_item_restack->relative_item_index); - - part->items = eina_list_remove(part->items, part_item); - - if (relative_part_item) - part->items = eina_list_prepend_relative(part->items, - part_item, - relative_part_item); + if (editor_part_item_restack->item_move_up) + { + relative_part_item = (Part_Item2 *)resource_manager_id_find(part->items, + editor_part_item_restack->item_index - 1); + part->items = eina_list_remove(part->items, part_item); + part->items = eina_list_prepend_relative(part->items, + part_item, + relative_part_item); + relative_part_item->common.id++; + part_item->common.id--; + } else - part->items = eina_list_append(part->items, part_item); + { + relative_part_item = (Part_Item2 *)resource_manager_id_find(part->items, + editor_part_item_restack->item_index + 1); + part->items = eina_list_remove(part->items, part_item); + part->items = eina_list_append_relative(part->items, + part_item, + relative_part_item); + relative_part_item->common.id--; + part_item->common.id++; + } } static void diff --git a/src/bin/ui/tabs.c b/src/bin/ui/tabs.c index e9ad5ce..701e825 100644 --- a/src/bin/ui/tabs.c +++ b/src/bin/ui/tabs.c @@ -666,7 +666,7 @@ _editor_part_item_restacked_cb(void *data __UNUSED__, workspace_part_item_restack(tabs.current_workspace, editor_part_item_restack->part_name, editor_part_item_restack->item_index, - editor_part_item_restack->relative_part_item); + editor_part_item_restack->item_move_up); } static void diff --git a/src/bin/ui/workspace/group_navigator.c b/src/bin/ui/workspace/group_navigator.c index f68e228..c47d2b7 100644 --- a/src/bin/ui/workspace/group_navigator.c +++ b/src/bin/ui/workspace/group_navigator.c @@ -131,6 +131,8 @@ _item_label_get(void *data, buf = eina_strbuf_new(); eina_strbuf_append_printf(buf, "item [%d]", res->common.id); + if (res->common.name) + eina_strbuf_append_printf(buf, " - %s", res->common.name); result = strdup(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); @@ -2286,12 +2288,10 @@ group_navigator_part_restack(Evas_Object *obj, Part2 *part, Part2 *rel_part) static void _part_item_restack(Part_List *pl, Elm_Object_Item *glit, Eina_Bool move_up) { - Eina_Stringshare *part_item_name, *rel_part_item_name = NULL; Elm_Object_Item *rel_glit; Eina_Stringshare *msg; Change *change; Part_Item2 *part_item, *rel_part_item; - Eina_Bool flag; assert(pl != NULL); assert(pl->part != NULL); @@ -2315,61 +2315,71 @@ _part_item_restack(Part_List *pl, Elm_Object_Item *glit, Eina_Bool move_up) part_item = elm_object_item_data_get(glit); rel_part_item = elm_object_item_data_get(rel_glit); - part_item_name = eina_stringshare_ref(part_item->common.name); - if (rel_part_item) - rel_part_item_name = eina_stringshare_ref(rel_part_item->common.name); - - if (rel_part_item_name) + if (move_up) { - flag = true; - msg = eina_stringshare_printf(_("part item \"%s\" placed below part item \"%s\" in the stack"), part_item_name, rel_part_item_name); + if (rel_part_item) + msg = eina_stringshare_printf(_("part item \"%s\" restacked BELOW \"%s\""), + part_item->common.name, + rel_part_item->common.name); + else + msg = eina_stringshare_printf(_("part item \"%s\" restacked BELOW"), + part_item->common.name); + change = change_add(msg); + CRIT_ON_FAIL(editor_part_item_index_restack_below(pl->group->edit_object, change, false, true, + pl->part->common.name, + part_item->common.id)); } else { - flag = false; - msg = eina_stringshare_printf(_("part item \"%s\" restacked to the top of the stack"), part_item_name); + if (rel_part_item) + msg = eina_stringshare_printf(_("part item \"%s\" restacked ABOVE \"%s\""), + part_item->common.name, + rel_part_item->common.name); + else + msg = eina_stringshare_printf(_("part item \"%s\" restacked ABOVE"), + part_item->common.name); + change = change_add(msg); + CRIT_ON_FAIL(editor_part_item_index_restack_above(pl->group->edit_object, change, false, true, + pl->part->common.name, + part_item->common.id)); } - change = change_add(msg); - CRIT_ON_FAIL(editor_part_item_index_restack(pl->group->edit_object, change, false, true, - pl->part->common.name, - part_item->common.id, - rel_part_item->common.id, - flag)); + history_change_add(pl->group->history, change); eina_stringshare_del(msg); - eina_stringshare_del(part_item_name); - eina_stringshare_del(rel_part_item_name); } void group_navigator_part_item_restack(Evas_Object *obj, Part2 *part, unsigned int item_index, - Eina_Stringshare *relative_part_item __UNUSED__) + Eina_Bool move_up __UNUSED__) { Elm_Object_Item *part_glit; Part_List *pl = evas_object_data_get(obj, GROUP_NAVIGATOR_DATA); Elm_Object_Item *glit, *items_glit; - const Eina_List *l; + const Eina_List *l, *subitems; Part_Item2 *part_item; assert(pl != NULL); assert(part != NULL); - glit = _part_item_find(pl, part); - assert(glit != NULL); - part_glit = _part_item_find(pl, part); - assert(part_glit != NULL); - part_item = (Part_Item2 *)resource_manager_id_find(part->items, item_index); + if (move_up) + part_item = (Part_Item2 *)resource_manager_id_find(part->items, item_index - 1); + else + part_item = (Part_Item2 *)resource_manager_id_find(part->items, item_index + 1); + elm_genlist_item_expanded_set(part_glit, true); - items_glit = eina_list_data_get(eina_list_last(elm_genlist_item_subitems_get(part_glit))); + + subitems = elm_genlist_item_subitems_get(part_glit); + items_glit = eina_list_data_get(eina_list_last(subitems)); elm_genlist_item_expanded_set(items_glit, false); elm_genlist_item_expanded_set(items_glit, true); - EINA_LIST_FOREACH(elm_genlist_item_subitems_get(items_glit), l, glit) + subitems = elm_genlist_item_subitems_get(items_glit); + EINA_LIST_FOREACH(subitems, l, glit) { if (elm_object_item_data_get(glit) == part_item) { diff --git a/src/bin/ui/workspace/group_navigator.h b/src/bin/ui/workspace/group_navigator.h index 68bad01..a3f34ee 100644 --- a/src/bin/ui/workspace/group_navigator.h +++ b/src/bin/ui/workspace/group_navigator.h @@ -97,7 +97,7 @@ void group_navigator_part_item_restack(Evas_Object *obj, Part2 *part, unsigned int index, - Eina_Stringshare *relative_part_item); + Eina_Bool move_up); void group_navigator_program_add(Evas_Object *obj, Eina_Stringshare *program); diff --git a/src/bin/ui/workspace/workspace.c b/src/bin/ui/workspace/workspace.c index da6e01b..a2111fd 100644 --- a/src/bin/ui/workspace/workspace.c +++ b/src/bin/ui/workspace/workspace.c @@ -1909,7 +1909,7 @@ void workspace_part_item_restack(Evas_Object *obj, Eina_Stringshare *part_name, unsigned int item_index, - Eina_Stringshare *relative_part_item_name) + Eina_Bool move_up) { Part2 *part; WS_DATA_GET(obj); @@ -1917,7 +1917,7 @@ workspace_part_item_restack(Evas_Object *obj, part = (Part2 *)resource_manager_find(wd->group->parts, part_name); group_navigator_select(wd->group_navi, (Resource2 *)part); - group_navigator_part_item_restack(wd->group_navi, part, item_index, relative_part_item_name); + group_navigator_part_item_restack(wd->group_navi, part, item_index, move_up); groupview_hard_update(wd->normal.content); } diff --git a/src/bin/ui/workspace/workspace.h b/src/bin/ui/workspace/workspace.h index 0e0e1ae..e8d66b2 100644 --- a/src/bin/ui/workspace/workspace.h +++ b/src/bin/ui/workspace/workspace.h @@ -268,7 +268,7 @@ void workspace_part_item_restack(Evas_Object *obj, Eina_Stringshare *part_name, unsigned int item_index, - Eina_Stringshare *relative_part_item_name); + Eina_Bool move_up); /** * Set zoom factor for view zoommed style in groupspace. --