rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=553e98ecc753063a6e4c5e160d020502977691d0
commit 553e98ecc753063a6e4c5e160d020502977691d0 Author: Vyacheslav Reutskiy <v.reuts...@samsung.com> Date: Wed Dec 9 09:22:48 2015 +0200 groupedit: remove the code duplication Change-Id: I5053dfe3624bfefe83ae713f4138e2e07c129bc6 --- src/bin/ui/workspace/groupedit_calc.c | 94 +++++++++++++++-------------------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/src/bin/ui/workspace/groupedit_calc.c b/src/bin/ui/workspace/groupedit_calc.c index a7d7a9e..6b4d155 100644 --- a/src/bin/ui/workspace/groupedit_calc.c +++ b/src/bin/ui/workspace/groupedit_calc.c @@ -300,14 +300,48 @@ _part_select(void *data, (void *)gp->part); } +static Evas_Object * +_conteiner_cell_sizer_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp, const char *item_name) +{ + Evas_Object *cell_content; + Eina_Stringshare *item_source; + int min_w, min_h, max_w, max_h, w, h; + + cell_content = edje_object_add(sd->e); + item_source = edje_edit_part_item_source_get(sd->group->edit_object, gp->part->name, item_name); + edje_object_file_set(cell_content, ap.project->dev, item_source); + eina_stringshare_del(item_source); + /* hide this object, it need only for calculate cell size */ + evas_object_hide(cell_content); + + min_w = edje_edit_part_item_min_w_get(sd->group->edit_object, gp->part->name, item_name); + min_h = edje_edit_part_item_min_h_get(sd->group->edit_object, gp->part->name, item_name); + + // Calculation according to box/table item implementation in efl 1.13 at edje_load.c + if ((min_w <= 0) && (min_h <= 0)) + { + edje_object_size_min_get(cell_content, &w, &h); + if ((w <= 0) && (h <= 0)) + edje_object_size_min_calc(cell_content, &w, &h); + } + if (((min_w <= 0) && (min_h <= 0)) && ((w > 0) || (h > 0))) + evas_object_size_hint_min_set(cell_content, w, h); + else + evas_object_size_hint_min_set(cell_content, min_w, min_h); + + max_w = edje_edit_part_item_max_w_get(sd->group->edit_object, gp->part->name, item_name); + max_h = edje_edit_part_item_max_h_get(sd->group->edit_object, gp->part->name, item_name); + evas_object_size_hint_max_set(cell_content, max_w, max_h); + + return cell_content; +} + static void _part_table_items_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp, Eina_Stringshare ***items_draw) { const Evas_Object *table; Evas_Object *cell, *cell_content; - Eina_Stringshare *item_name, *item_source; - int w, h; /* Geometry values */ - int min_w, max_w, min_h, max_h; /* Hints values */ + Eina_Stringshare *item_name; int i, j, col, row; unsigned char span_col, span_row; Groupedit_Item *item; @@ -340,31 +374,7 @@ _part_table_items_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp, Eina_Stri span_col = edje_edit_part_item_span_col_get(sd->group->edit_object, gp->part->name, item_name); span_row = edje_edit_part_item_span_row_get(sd->group->edit_object, gp->part->name, item_name); - cell_content = edje_object_add(sd->e); - item_source = edje_edit_part_item_source_get(sd->group->edit_object, gp->part->name, item_name); - edje_object_file_set(cell_content, ap.project->dev, item_source); - eina_stringshare_del(item_source); - /* hide this object, it need only for calculate cell size */ - evas_object_hide(cell_content); - - min_w = edje_edit_part_item_min_w_get(sd->group->edit_object, gp->part->name, item_name); - min_h = edje_edit_part_item_min_h_get(sd->group->edit_object, gp->part->name, item_name); - - // Calculation according to box/table item implementation in efl 1.13 at edje_load.c - if ((min_w <= 0) && (min_h <= 0)) - { - edje_object_size_min_get(cell_content, &w, &h); - if ((w <= 0) && (h <= 0)) - edje_object_size_min_calc(cell_content, &w, &h); - } - if (((min_w <= 0) && (min_h <= 0)) && ((w > 0) || (h > 0))) - evas_object_size_hint_min_set(cell_content, w, h); - else - evas_object_size_hint_min_set(cell_content, min_w, min_h); - - max_w = edje_edit_part_item_max_w_get(sd->group->edit_object, gp->part->name, item_name); - max_h = edje_edit_part_item_max_h_get(sd->group->edit_object, gp->part->name, item_name); - evas_object_size_hint_max_set(cell_content, max_w, max_h); + cell_content = _conteiner_cell_sizer_add(sd, gp, item_name); evas_object_table_pack(gp->container, cell_content, i, j, span_col, span_row); item = mem_malloc(sizeof(Groupedit_Item)); @@ -486,9 +496,8 @@ _part_box_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) { Eina_List *l; - Eina_Stringshare *str, *item_source; - int spread_w, spread_h; - int min_w, min_h, max_w, max_h, w, h, i; + Eina_Stringshare *str; + int i, spread_w, spread_h; Evas_Object *cell, *cell_content; Groupedit_Item *item; @@ -510,29 +519,8 @@ _part_box_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) evas_object_show(cell); elm_object_signal_emit(cell, "border,part_item", "eflete"); - cell_content = edje_object_add(sd->e); - item_source = edje_edit_part_item_source_get(sd->group->edit_object, gp->part->name, str); - edje_object_file_set(cell_content, ap.project->dev, item_source); - - min_w = edje_edit_part_item_min_w_get(sd->group->edit_object, gp->part->name, str); - min_h = edje_edit_part_item_min_h_get(sd->group->edit_object, gp->part->name, str); - - if ((min_w <= 0) && (min_h <= 0)) - { - edje_object_size_min_get(cell_content, &w, &h); - if ((w <= 0) && (h <= 0)) - edje_object_size_min_calc(cell_content, &w, &h); - } - if (((min_w <= 0) && (min_h <= 0)) && ((w > 0) || (h > 0))) - evas_object_size_hint_min_set(cell_content, w, h); - else - evas_object_size_hint_min_set(cell_content, min_w, min_h); - max_w = edje_edit_part_item_max_w_get(sd->group->edit_object, gp->part->name, str); - max_h = edje_edit_part_item_max_h_get(sd->group->edit_object, gp->part->name, str); - evas_object_size_hint_max_set(cell_content, max_w, max_h); - + cell_content = _conteiner_cell_sizer_add(sd, gp, str); elm_object_content_set(cell, cell_content); - evas_object_hide(cell_content); evas_object_box_append(gp->container, cell); if (i == 0) { --