rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=dece636420ab1c43480be920e9804bb18e7f73d5
commit dece636420ab1c43480be920e9804bb18e7f73d5 Author: Vyacheslav Reutskiy <[email protected]> Date: Tue Nov 24 12:39:38 2015 +0200 groupedit: improve box calculation Change-Id: Iac9c9783da9ffdb5d34ade1a4786794d1dd1cfc8 --- data/themes/default/widgets/layout.edc | 6 + po/POTFILES.in | 1 - src/bin/Makefile.am | 1 - src/bin/ui/workspace/groupedit_box_layouts.c | 1514 -------------------------- src/bin/ui/workspace/groupedit_calc.c | 379 +++---- 5 files changed, 146 insertions(+), 1755 deletions(-) diff --git a/data/themes/default/widgets/layout.edc b/data/themes/default/widgets/layout.edc index 8c317b5..a906411 100644 --- a/data/themes/default/widgets/layout.edc +++ b/data/themes/default/widgets/layout.edc @@ -3472,6 +3472,12 @@ group { name: "elm/layout/groupview/default"; BG(box, bg_box.png) #undef BG } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 0; + } + } part { name: "border"; type: IMAGE; description { state: "default" 0.0; diff --git a/po/POTFILES.in b/po/POTFILES.in index 0d0b12f..e20b2fa 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -79,7 +79,6 @@ src/bin/ui/splash.c src/bin/ui/tab_home_open.c src/bin/ui/tabs.c src/bin/ui/workspace/groupedit.c -src/bin/ui/workspace/groupedit_box_layouts.c src/bin/ui/workspace/groupedit_calc.c src/bin/ui/workspace/highlight.c src/bin/ui/workspace/workspace.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index d4d40f8..ecd3ca2 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -72,7 +72,6 @@ libete_a_SOURCES = \ ../../src/bin/ui/workspace/workspace.c \ ../../src/bin/ui/workspace/groupedit_calc.c \ ../../src/bin/ui/workspace/groupedit.c \ -../../src/bin/ui/workspace/groupedit_box_layouts.c \ ../../src/bin/ui/workspace/highlight.c \ ../../src/bin/ui/live_view/demo.c \ ../../src/bin/ui/live_view/live_view_prop.c \ diff --git a/src/bin/ui/workspace/groupedit_box_layouts.c b/src/bin/ui/workspace/groupedit_box_layouts.c deleted file mode 100644 index 989219f..0000000 --- a/src/bin/ui/workspace/groupedit_box_layouts.c +++ /dev/null @@ -1,1514 +0,0 @@ -/* - * Copyright (C) 2002-2012 Carsten Haitzler, Dan Sinclair, Mike Blumenkrantz, - * Samsung Electronics. EFL. - * That code is public domain and can be freely used or copied. - * https://git.enlightenment.org/core/efl.git - * https://enlightenment.org - */ - -#include "groupedit_private.h" - -static void -_fixed_point_divide_and_decompose_integer(int dividend, int divisor, int *int_part, int *frac_part) -{ - assert(int_part != NULL); - assert(frac_part != NULL); - assert(divisor != 0); - - int quotient = ((long long)dividend << 16) / divisor; - *frac_part = quotient & 0xffff; - *int_part = quotient >> 16; -} - -static void -_layout_dimension_change_min_max_cell_bound(int dim, int *new_dim, int min_d, int max_d, int cell_sz) -{ - assert(new_dim != NULL); - - if (dim > cell_sz) - { - if ((min_d != 0) && (cell_sz < min_d)) - *new_dim = min_d; - else - *new_dim = cell_sz; - } - else - { - if ((max_d != -1) && (cell_sz > max_d)) - *new_dim = max_d; - else - *new_dim = cell_sz; - } -} - -static void -_layout_set_offset_and_expand_dimension_space_max_bounded(int dim, int *new_dim, int space_sz, int max_dim, int *offset_current, int *offset_top, int *offset_bottom, double align, int pad_before, int pad_after) -{ - assert(new_dim != NULL); - assert(offset_current != NULL); - assert(offset_top != NULL); - assert(offset_bottom != NULL); - - if (align >= 0.0) - { - *new_dim = dim; - *offset_current = (space_sz - (dim + pad_before + pad_after)) * align - + pad_before; - *offset_top = pad_before; - *offset_bottom = (space_sz - (dim + pad_before + pad_after)) - + pad_before; - } - else - { - if ((max_dim != -1) && (space_sz > max_dim)) - { - *new_dim = max_dim; - *offset_current = (space_sz - (max_dim + pad_before + pad_after)) * 0.5 - + pad_before; - *offset_top = (space_sz - (max_dim + pad_before + pad_after)) * 0.5 - + pad_before; - *offset_bottom = (space_sz - (max_dim + pad_before + pad_after)) * 0.5 - + pad_before; - } - else - { - *new_dim = space_sz; - *offset_current = 0; - *offset_top = 0; - *offset_bottom = 0; - } - } -} - -static void -_layout_set_offset_and_change_dimension_min_max_cell_bounded(int dim, int *new_dim, int min_dim, int max_dim, int cell_sz, int *offset_current, int *offset_top, int *offset_bottom, double align, int pad_before, int pad_after) -{ - assert(new_dim != NULL); - assert(offset_current != NULL); - assert(offset_top != NULL); - assert(offset_bottom != NULL); - - if (align >= 0.0) - { - *new_dim = dim; - *offset_current = - (cell_sz - (dim + pad_before + pad_after)) * align + pad_before; - *offset_top = pad_before; - *offset_bottom = - (cell_sz - (dim + pad_before + pad_after)) + pad_before; - } - else - { - *offset_current = pad_before; - *offset_top = pad_before; - *offset_bottom = pad_before; - _layout_dimension_change_min_max_cell_bound - (dim, new_dim, min_dim, max_dim, cell_sz - pad_before - pad_after); - } -} - -static void -_sizing_eval(Evas_Object *obj) -{ - Evas_Coord minw, minh, maxw, maxh; - Evas_Coord w, h; - - assert(obj != NULL); - - evas_object_size_hint_min_get(obj, &minw, &minh); - evas_object_size_hint_max_get(obj, &maxw, &maxh); - evas_object_geometry_get(obj, NULL, NULL, &w, &h); - - if (w < minw) w = minw; - if (h < minh) h = minh; - if ((maxw >= 0) && (w > maxw)) w = maxw; - if ((maxh >= 0) && (h > maxh)) h = maxh; - - evas_object_resize(obj, w, h); -} - -static int -_evas_object_box_layout_horizontal_weight_apply(Evas_Object_Box_Data *priv, Evas_Object_Box_Option **objects, int n_objects, int remaining, double weight_total) -{ - int rem_diff = 0; - int i; - - assert(priv != NULL); - - for (i = 0; i < n_objects; i++) - { - Evas_Object_Box_Option *opt = objects[i]; - Evas_Object *o = opt->obj; - int h; - - evas_object_geometry_get(o, NULL, NULL, NULL, &h); - - if (remaining <= 0) - { - int min_w; - - evas_object_size_hint_min_get(o, &min_w, NULL); - evas_object_resize(o, min_w, h); - } - else - { - double normal_weight, weight_x; - int target_size; - int max_w; - - evas_object_size_hint_weight_get(o, &weight_x, NULL); - normal_weight = weight_x / weight_total; - target_size = (int)((double)remaining * normal_weight); - - evas_object_size_hint_max_get(o, &max_w, NULL); - if ((max_w != -1) && (target_size > max_w)) - { - evas_object_resize(o, max_w, h); - rem_diff += max_w; - objects[i] = objects[n_objects - 1]; - weight_total -= weight_x; - n_objects--; - return _evas_object_box_layout_horizontal_weight_apply - (priv, objects, n_objects, remaining - rem_diff, - weight_total); - } - else - { - evas_object_resize(o, target_size, h); - rem_diff += target_size; - } - } - } - - return remaining - rem_diff; -} - -void -_box_layout_horizontal(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int pad_inc = 0, sub_pixel = 0; - int req_w, global_pad, remaining, top_h = 0; - double weight_total = 0.0; - int weight_use = 0; - int x, y, w, h; - int n_children; - Evas_Object_Box_Option *opt; - Evas_Object_Box_Option **objects; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - objects = (Evas_Object_Box_Option **)alloca(sizeof(Evas_Object_Box_Option *) * n_children); - if (!objects) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - global_pad = priv->pad.h; - req_w = global_pad * (n_children - 1); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - int padding_l, padding_r; - double weight_x; - - _sizing_eval(opt->obj); - evas_object_size_hint_weight_get(opt->obj, &weight_x, NULL); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, NULL, NULL); - req_w += padding_l + padding_r; - - if (!weight_x) - { - int child_w; - - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, NULL); - req_w += child_w; - } - else - { - objects[weight_use] = opt; - weight_use++; - weight_total += weight_x; - } - } - - remaining = w - req_w; - - if (weight_use) - remaining = _evas_object_box_layout_horizontal_weight_apply - (priv, objects, weight_use, remaining, weight_total); - - if (priv->align.h >= 0.0) - x += remaining * priv->align.h; - else if (n_children == 1) - x += remaining / 2; - else - { /* justified */ - _fixed_point_divide_and_decompose_integer - (remaining, n_children - 1, &global_pad, &pad_inc); - global_pad += priv->pad.h; - } - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, max_h, new_h, off_x, off_y, off_y_t, off_y_b; - int padding_l, padding_r, padding_t, padding_b; - double align_y; - - evas_object_size_hint_align_get(opt->obj, NULL, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, NULL, &max_h); - - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - off_x = padding_l; - new_h = child_h; - if (new_h > top_h) top_h = new_h; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_h, &new_h, h, max_h, &off_y, &off_y_t, &off_y_b, align_y, padding_t, padding_b); - - if (new_h != child_h) - evas_object_resize(opt->obj, child_w, new_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, child_w, new_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, child_w, new_h + abs(off_y_t - off_y_b)); - - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - x += child_w + padding_l + padding_r + global_pad; - sub_pixel += pad_inc; - if (sub_pixel >= 1 << 16) - { - x++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, req_w, top_h); -} - -static int -_evas_object_box_layout_vertical_weight_apply(Evas_Object_Box_Data *priv, Evas_Object_Box_Option **objects, int n_objects, int remaining, double weight_total) -{ - int rem_diff = 0; - int i; - - assert(priv != NULL); - - for (i = 0; i < n_objects; i++) - { - Evas_Object_Box_Option *opt = objects[i]; - Evas_Object *o = opt->obj; - int w; - - evas_object_geometry_get(o, NULL, NULL, &w, NULL); - - if (remaining <= 0) - { - int min_h; - - evas_object_size_hint_min_get(o, NULL, &min_h); - evas_object_resize(o, w, min_h); - } - else - { - double normal_weight, weight_y; - int target_size; - int max_h; - - evas_object_size_hint_weight_get(o, NULL, &weight_y); - normal_weight = weight_y / weight_total; - target_size = (int)((double)remaining * normal_weight); - - evas_object_size_hint_max_get(o, NULL, &max_h); - if ((max_h != -1) && (target_size > max_h)) - { - evas_object_resize(o, w, max_h); - rem_diff += max_h; - objects[i] = objects[n_objects - 1]; - weight_total -= weight_y; - n_objects--; - return _evas_object_box_layout_vertical_weight_apply - (priv, objects, n_objects, remaining - rem_diff, - weight_total); - } - else - { - evas_object_resize(o, w, target_size); - rem_diff += target_size; - } - } - } - - return remaining - rem_diff; -} - -void -_box_layout_vertical(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int pad_inc = 0, sub_pixel = 0; - int req_h, global_pad, remaining, top_w = 0; - double weight_total = 0.0; - int weight_use = 0; - int x, y, w, h; - int n_children; - Evas_Object_Box_Option *opt; - Evas_Object_Box_Option **objects; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - objects = (Evas_Object_Box_Option **)alloca(sizeof(Evas_Object_Box_Option *) * n_children); - if (!objects) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - global_pad = priv->pad.v; - req_h = global_pad * (n_children - 1); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - int padding_t, padding_b; - double weight_y; - - _sizing_eval(opt->obj); - evas_object_size_hint_weight_get(opt->obj, NULL, &weight_y); - evas_object_size_hint_padding_get - (opt->obj, NULL, NULL, &padding_t, &padding_b); - req_h += padding_t + padding_b; - - if (!weight_y) - { - int child_h; - - evas_object_geometry_get(opt->obj, NULL, NULL, NULL, &child_h); - req_h += child_h; - } - else - { - objects[weight_use] = opt; - weight_use++; - weight_total += weight_y; - } - } - - remaining = h - req_h; - - if (weight_use) - remaining = _evas_object_box_layout_vertical_weight_apply - (priv, objects, weight_use, remaining, weight_total); - - if (priv->align.v >= 0.0) - y += remaining * priv->align.v; - else if (n_children == 1) - y += remaining / 2; - else - { /* justified */ - _fixed_point_divide_and_decompose_integer - (remaining, n_children - 1, &global_pad, &pad_inc); - global_pad += priv->pad.v; - } - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, max_w, new_w, off_x, off_x_t, off_x_b, off_y; - int padding_l, padding_r, padding_t, padding_b; - double align_x; - - evas_object_size_hint_align_get(opt->obj, &align_x, NULL); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, &max_w, NULL); - - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - off_y = padding_t; - new_w = child_w; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_w, &new_w, w, max_w, &off_x, &off_x_t, &off_x_b, align_x, padding_l, padding_r); - - if (new_w > top_w) top_w = new_w; - - if (new_w != child_w) - evas_object_resize(opt->obj, new_w, child_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, new_w, child_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, new_w + abs(off_x_t - off_x_b), child_h); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - y += child_h + padding_t + padding_b + global_pad; - sub_pixel += pad_inc; - if (sub_pixel >= 1 << 16) - { - y++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, top_w, req_h); -} - -void -_box_layout_homogeneous_horizontal(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int cell_sz, share, inc; - int sub_pixel = 0; - int x, y, w, h; - int n_children; - Evas_Object_Box_Option *opt; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - - share = w - priv->pad.h * (n_children - 1); - _fixed_point_divide_and_decompose_integer - (share, n_children, &cell_sz, &inc); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, max_h, min_w, max_w, new_w, new_h; - int off_x, off_x_t, off_x_b, off_y_b, off_y_t, off_y; - int padding_l, padding_r, padding_t, padding_b; - double align_x, align_y; - - evas_object_size_hint_align_get(opt->obj, &align_x, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, &max_w, &max_h); - evas_object_size_hint_min_get(opt->obj, &min_w, NULL); - - _sizing_eval(opt->obj); - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - new_w = child_w; - new_h = child_h; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_h, &new_h, h, max_h, &off_y, &off_y_t, &off_y_b, align_y, padding_t, padding_b); - - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_w, &new_w, min_w, max_w, cell_sz, &off_x, &off_x_t, &off_x_b, align_x, - padding_l, padding_r); - - if ((new_w != child_w) || (new_h != child_h)) - evas_object_resize(opt->obj, new_w, new_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, new_w, new_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, - new_w + abs(off_x_t - off_x_b), - new_h + abs(off_y_t - off_y_b)); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - x += cell_sz + priv->pad.h; - sub_pixel += inc; - if (sub_pixel >= 1 << 16) - { - x++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, w, h); -} - -void -_box_layout_homogeneous_vertical(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int cell_sz, share, inc; - int sub_pixel = 0; - int x, y, w, h; - int n_children; - Evas_Object_Box_Option *opt; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - - share = h - priv->pad.v * (n_children - 1); - _fixed_point_divide_and_decompose_integer - (share, n_children, &cell_sz, &inc); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, max_w, min_h, max_h, new_w, new_h; - int off_x, off_x_t, off_x_b, off_y, off_y_t, off_y_b; - int padding_l, padding_r, padding_t, padding_b; - double align_x, align_y; - - evas_object_size_hint_align_get(opt->obj, &align_x, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, &max_w, &max_h); - evas_object_size_hint_min_get(opt->obj, NULL, &min_h); - - _sizing_eval(opt->obj); - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - new_w = child_w; - new_h = child_h; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_w, &new_w, w, max_w, &off_x, &off_x_t, &off_x_b, align_x, padding_l, padding_r); - - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_h, &new_h, min_h, max_h, cell_sz, &off_y, &off_y_t, &off_y_b, align_y, - padding_t, padding_b); - - if ((new_w != child_w) || (new_h != child_h)) - evas_object_resize(opt->obj, new_w, new_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, new_w, new_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, - new_w + abs(off_x_t - off_x_b), - new_h + abs(off_y_t - off_y_b)); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - y += cell_sz + priv->pad.v; - sub_pixel += inc; - if (sub_pixel >= 1 << 16) - { - y++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, w, h); -} - -void -_box_layout_homogeneous_max_size_horizontal(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int remaining, global_pad, pad_inc = 0, sub_pixel = 0; - int cell_sz = 0; - int x, y, w, h; - int top_h = 0; - int n_children; - Evas_Object_Box_Option *opt; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - int child_w, padding_l, padding_r; - - _sizing_eval(opt->obj); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, NULL, NULL); - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, NULL); - if (child_w + padding_l + padding_r > cell_sz) - cell_sz = child_w + padding_l + padding_r; - } - - global_pad = priv->pad.h; - remaining = w - n_children * cell_sz - global_pad * (n_children - 1); - - if (priv->align.h >= 0.0) - x += remaining * priv->align.h; - else if (n_children == 1) - x += remaining / 2; - else - { /* justified */ - _fixed_point_divide_and_decompose_integer - (remaining, n_children - 1, &global_pad, &pad_inc); - global_pad += priv->pad.h; - } - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, min_w, max_w, max_h, new_w, new_h; - int off_x, off_x_t, off_x_b, off_y, off_y_t, off_y_b; - int padding_l, padding_r, padding_t, padding_b; - double align_x, align_y; - - evas_object_size_hint_align_get(opt->obj, &align_x, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, &max_w, &max_h); - evas_object_size_hint_min_get(opt->obj, &min_w, NULL); - - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - new_w = child_w; - new_h = child_h; - if (new_h > top_h) top_h = new_h; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_h, &new_h, h, max_h, &off_y, &off_y_t, &off_y_b, align_y, padding_t, padding_b); - - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_w, &new_w, min_w, max_w, cell_sz, &off_x, &off_x_t, &off_x_b, align_x, - padding_l, padding_r); - - if ((new_w != child_w) || (new_h != child_h)) - evas_object_resize(opt->obj, new_w, new_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, new_w, new_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, - new_w + abs(off_x_t - off_x_b), - new_h + abs(off_y_t - off_y_b)); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - x += cell_sz + global_pad; - sub_pixel += pad_inc; - if (sub_pixel >= 1 << 16) - { - x++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, x, top_h); -} - -void -_box_layout_homogeneous_max_size_vertical(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int remaining, global_pad, pad_inc = 0, sub_pixel = 0; - int cell_sz = 0; - int x, y, w, h; - int top_w = 0; - int n_children; - Evas_Object_Box_Option *opt; - Eina_List *l, *spread = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - evas_object_geometry_get(o, &x, &y, &w, &h); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - int child_h, padding_t, padding_b; - - _sizing_eval(opt->obj); - evas_object_size_hint_padding_get - (opt->obj, NULL, NULL, &padding_t, &padding_b); - evas_object_geometry_get(opt->obj, NULL, NULL, NULL, &child_h); - if (child_h + padding_t + padding_b > cell_sz) - cell_sz = child_h + padding_t + padding_b; - } - - global_pad = priv->pad.v; - remaining = h - n_children * cell_sz - global_pad * (n_children - 1); - - if (priv->align.v >= 0.0) - y += remaining * priv->align.v; - else if (n_children == 1) - y += remaining / 2; - else - { /* justified */ - _fixed_point_divide_and_decompose_integer - (remaining, n_children - 1, &global_pad, &pad_inc); - global_pad += priv->pad.v; - } - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - int child_w, child_h, max_h, min_h, max_w, new_w, new_h; - int off_x, off_x_t, off_x_b, off_y, off_y_t, off_y_b; - int padding_l, padding_r, padding_t, padding_b; - double align_x, align_y; - - evas_object_size_hint_align_get(opt->obj, &align_x, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - evas_object_size_hint_max_get(opt->obj, &max_w, &max_h); - evas_object_size_hint_min_get(opt->obj, NULL, &min_h); - - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - new_w = child_w; - new_h = child_h; - if (new_w > top_w) top_w = new_w; - - _layout_set_offset_and_expand_dimension_space_max_bounded - (child_w, &new_w, w, max_w, &off_x, &off_x_t, &off_x_b, align_x, padding_l, padding_r); - - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_h, &new_h, min_h, max_h, cell_sz, &off_y, &off_y_t, &off_y_b, align_y, - padding_t, padding_b); - - if ((new_w != child_w) || (new_h != child_h)) - evas_object_resize(opt->obj, new_w, new_h); - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_resize(ge_item->highlight, new_w, new_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, - new_w + abs(off_x_t - off_x_b), - new_h + abs(off_y_t - off_y_b)); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, x + off_x, y + off_y); - - y += cell_sz + global_pad; - sub_pixel += pad_inc; - if (sub_pixel >= 1 << 16) - { - y++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, top_w, y); -} - -void -_evas_object_box_layout_flow_horizontal_row_info_collect(Evas_Object_Box_Data *priv, int box_w, int *row_count, int *row_max_h, int *row_break, int *row_width, int *off_y_ret, int *max_w_ret, int *max_h_ret) -{ - assert(priv != NULL); - assert(row_count != NULL); - assert(row_max_h != NULL); - assert(row_break != NULL); - assert(row_width != NULL); - assert(off_y_ret != NULL); - assert(max_w_ret != NULL); - assert(max_h_ret != NULL); - - int i, remain_w = box_w, start_i = 0; - int off_y = 0, max_w = 0, max_h = 0, n_rows = 0; - Eina_List *l; - - for (i = 0, l = priv->children; l; i++, l = l->next) - { - Evas_Object_Box_Option *opt = l->data; - int padding_l, padding_r, padding_t, padding_b; - int child_w, child_h, off_x = 0; - - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - - _sizing_eval(opt->obj); - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - child_w += padding_l + padding_r + priv->pad.h; - child_h += padding_t + padding_b; - if (child_w > max_w) - max_w = child_w; - - remain_w -= child_w; - if (remain_w + priv->pad.h >= 0) - { /* continue "line" */ - if (child_h > max_h) - max_h = child_h; - - off_x += child_w; - row_width[n_rows] += child_w; - } - else - { /* break line */ - if (i == start_i) - { /* obj goes to actual line */ - max_h = child_h; - row_width[n_rows] = child_w; - } - else - { /* obj goes to next line */ - row_max_h[n_rows] = max_h; - row_break[n_rows] = i - 1; - n_rows++; - - off_x = child_w; - off_y += max_h; - max_h = child_h; - - row_width[n_rows] = child_w; - start_i = i; - - remain_w = box_w - off_x; - } - } - } - - row_break[n_rows] = i - 1; - row_max_h[n_rows] = max_h; - - *row_count = n_rows; - *off_y_ret = off_y; - *max_w_ret = max_w; - *max_h_ret = max_h; -} - -void -_box_layout_flow_horizontal(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int n_children; - int r, row_count = 0; - int min_w = 0, min_h = 0; - int max_h, inc_y; - int item_w, item_h; - int remain_y, i; - int x, y, w, h; - Eina_List *l, *spread = NULL; - int *row_max_h; - int *row_break; - int *row_width; - int offset_y; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - /* *per row* arrays */ - row_max_h = (int *)alloca(sizeof(int) * n_children); - row_break = (int *)alloca(sizeof(int) * n_children); - row_width = (int *)alloca(sizeof(int) * n_children); - - memset(row_width, 0, sizeof(int) * n_children); - - evas_object_geometry_get(o, &x, &y, &w, &h); - - _evas_object_box_layout_flow_horizontal_row_info_collect - (priv, w, &row_count, row_max_h, row_break, row_width, &offset_y, &min_w, &max_h); - - inc_y = 0; - remain_y = h - (offset_y + max_h); - - if (remain_y > 0) - { - if (priv->align.v >= 0.0) - inc_y = priv->align.v * remain_y; - else if (row_count == 0) - y += remain_y / 2; - else /* y-justified */ - inc_y = remain_y / row_count; - } - - inc_y += priv->pad.v; - - for (i = 0, r = 0, l = priv->children; r <= row_count; r++) - { - int row_justify = 0, just_inc = 0, sub_pixel = 0; - int row_size, remain_x; - - row_size = row_break[r] - i; - remain_x = (w - row_width[r]); - - if (priv->align.h < 0.0) - { - if (row_size == 0) - x += remain_x / 2; - else - _fixed_point_divide_and_decompose_integer - (remain_x, row_size, &row_justify, &just_inc); - } - - row_justify += priv->pad.h; - - for (; i <= row_break[r]; i++, l = l->next) - { - ge_item = eina_list_data_get(spread ? spread : items); - - Evas_Object_Box_Option *opt = l->data; - int off_x, off_y, y_remain; - int padding_l, padding_r; - int child_w, child_h; - double align_y; - - evas_object_size_hint_align_get(opt->obj, NULL, &align_y); - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, NULL, NULL); - - evas_object_geometry_get - (opt->obj, NULL, NULL, &child_w, &child_h); - - y_remain = row_max_h[r] - child_h; - - off_x = padding_l; - if (priv->align.h >= 0.0) - off_x += remain_x * priv->align.h; - off_y = y_remain * align_y; - - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_geometry_get(opt->obj, NULL, NULL, &item_w, &item_h); - - evas_object_resize(ge_item->highlight, item_w, item_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, item_w, item_h + y_remain); - evas_object_move(ge_item->border, x + off_x, y); - - x += child_w + padding_l + padding_r + row_justify; - - sub_pixel += just_inc; - if (sub_pixel >= 1 << 16) - { - x++; - sub_pixel -= 1 << 16; - } - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_geometry_get(o, &x, NULL, NULL, NULL); - min_h += row_max_h[r]; - y += row_max_h[r] + inc_y; - } - - evas_object_size_hint_min_set(o, min_w, min_h); -} - -static void -_evas_object_box_layout_flow_vertical_col_info_collect(Evas_Object_Box_Data *priv, int box_h, int *col_count, int *col_max_w, int *col_break, int *col_height, int *off_x_ret, int *max_w_ret, int *max_h_ret) -{ - int i, remain_h = box_h, start_i = 0; - int off_x = 0, max_w = 0, max_h = 0, n_cols = 0; - Eina_List *l; - - assert(priv != NULL); - assert(col_count != NULL); - assert(col_max_w != NULL); - assert(col_break != NULL); - assert(col_height != NULL); - assert(off_x_ret != NULL); - assert(max_w_ret != NULL); - assert(max_h_ret != NULL); - - for (i = 0, l = priv->children; l; i++, l = l->next) - { - Evas_Object_Box_Option *opt = l->data; - int padding_l, padding_r, padding_t, padding_b; - int child_w, child_h, off_y = 0; - - evas_object_size_hint_padding_get - (opt->obj, &padding_l, &padding_r, &padding_t, &padding_b); - - _sizing_eval(opt->obj); - evas_object_geometry_get(opt->obj, NULL, NULL, &child_w, &child_h); - - child_w += padding_l + padding_r; - child_h += padding_t + padding_b + priv->pad.v; - if (child_h > max_h) - max_h = child_h; - - remain_h -= child_h; - if (remain_h + priv->pad.v >= 0) - { /* continue "col" */ - if (child_w > max_w) - max_w = child_w; - - off_y += child_h; - col_height[n_cols] += child_h; - } - else - { - /* break col */ - if (i == start_i) - { /* obj goes to actual col */ - max_w = child_w; - col_height[n_cols] = child_h; - } - else - { /* obj goes to next col */ - col_max_w[n_cols] = max_w; - col_break[n_cols] = i - 1; - n_cols++; - - off_x += max_w; - off_y = child_h; - max_w = child_w; - - col_height[n_cols] = child_h; - start_i = i; - - remain_h = box_h - off_y; - } - } - } - - col_break[n_cols] = i - 1; - col_max_w[n_cols] = max_w; - - *col_count = n_cols; - *off_x_ret = off_x; - *max_w_ret = max_w; - *max_h_ret = max_h; -} - -void -_box_layout_flow_vertical(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - int n_children; - int c, col_count; - int min_w = 0, min_h = 0; - int item_w, item_h; - int max_w, inc_x; - int remain_x, i; - int x, y, w, h; - Eina_List *l, *spread = NULL; - int *col_max_w; - int *col_break; - int *col_height; - int offset_x; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - n_children = eina_list_count(priv->children); - if (!n_children) - { - evas_object_size_hint_min_set(o, 0, 0); - return; - } - - /* *per col* arrays */ - col_max_w = (int *)alloca(sizeof(int) * n_children); - col_break = (int *)alloca(sizeof(int) * n_children); - col_height = (int *)alloca(sizeof(int) * n_children); - - memset(col_height, 0, sizeof(int) * n_children); - - evas_object_geometry_get(o, &x, &y, &w, &h); - - _evas_object_box_layout_flow_vertical_col_info_collect - (priv, h, &col_count, col_max_w, col_break, col_height, &offset_x, &max_w, &min_h); - - inc_x = 0; - remain_x = w - (offset_x + max_w); - - if (remain_x > 0) - { - if (priv->align.h >= 0) - inc_x = priv->align.h * remain_x; - else if (col_count == 0) - x += remain_x / 2; - else /* x-justified */ - inc_x = remain_x / col_count; - } - - inc_x += priv->pad.h; - - for (i = 0, c = 0, l = priv->children; c <= col_count; c++) - { - int col_justify = 0, just_inc = 0, sub_pixel = 0; - int col_size, remain_y; - - col_size = col_break[c] - i; - remain_y = (h - col_height[c]); - - if (priv->align.v < 0.0) - { - if (col_size == 0) - y += remain_y / 2; - else - _fixed_point_divide_and_decompose_integer - (remain_y, col_size, &col_justify, &just_inc); - } - - col_justify += priv->pad.v; - - for (; i <= col_break[c]; i++, l = l->next) - { - ge_item = eina_list_data_get(spread ? spread : items); - - Evas_Object_Box_Option *opt = l->data; - int off_x, off_y, x_remain; - int padding_t, padding_b; - int child_w, child_h; - double align_x; - - evas_object_size_hint_align_get(opt->obj, &align_x, NULL); - evas_object_size_hint_padding_get - (opt->obj, NULL, NULL, &padding_t, &padding_b); - - evas_object_geometry_get - (opt->obj, NULL, NULL, &child_w, &child_h); - - x_remain = col_max_w[c] - child_w; - - off_x = x_remain * align_x; - off_y = padding_t; - if (priv->align.v >= 0.0) - off_y += remain_y * priv->align.v; - - evas_object_move(opt->obj, x + off_x, y + off_y); - - evas_object_geometry_get(opt->obj, NULL, NULL, &item_w, &item_h); - evas_object_resize(ge_item->highlight, item_w, item_h); - evas_object_move(ge_item->highlight, x + off_x, y + off_y); - - evas_object_resize(ge_item->border, item_w + x_remain, item_h); - evas_object_move(ge_item->border, x, y + off_y); - - y += child_h + padding_t + padding_b + col_justify; - - sub_pixel += just_inc; - if (sub_pixel >= 1 << 16) - { - y++; - sub_pixel -= 1 << 16; - } - - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_geometry_get(o, NULL, &y, NULL, NULL); - min_w += col_max_w[c]; - x += col_max_w[c] + inc_x; - } - - evas_object_size_hint_min_set(o, min_w, min_h); -} - -void -_box_layout_stack(Evas_Box *o, Evas_Object_Box_Data *priv, void *data) -{ - Eina_List *l, *spread = NULL; - Evas_Coord ox, oy, ow, oh; - Evas_Coord top_w = 0, top_h = 0; - Evas_Object_Box_Option *opt; - Evas_Object *old_child = NULL; - Groupedit_Item *ge_item = NULL; - - Eina_List *items = (Eina_List *)data; - - assert(o != NULL); - assert(priv != NULL); - - evas_object_geometry_get(o, &ox, &oy, &ow, &oh); - - EINA_LIST_FOREACH(priv->children, l, opt) - { - ge_item = eina_list_data_get(spread ? spread : items); - - Evas_Object *child = opt->obj; - Evas_Coord max_w, max_h, min_w, min_h, pad_l, pad_r, pad_t, pad_b; - Evas_Coord child_w, child_h, new_w, new_h; - Evas_Coord off_x, off_x_t, off_x_b, off_y, off_y_t, off_y_b; - double align_x, align_y; - - evas_object_size_hint_align_get(child, &align_x, &align_y); - evas_object_size_hint_padding_get - (child, &pad_l, &pad_r, &pad_t, &pad_b); - evas_object_size_hint_max_get(child, &max_w, &max_h); - evas_object_size_hint_min_get(child, &min_w, &min_h); - - _sizing_eval(opt->obj); - evas_object_geometry_get(child, NULL, NULL, &child_w, &child_h); - new_w = child_w; - new_h = child_h; - - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_w, &new_w, min_w, max_w, ow, &off_x, &off_x_t, &off_x_b, align_x, pad_l, pad_r); - _layout_set_offset_and_change_dimension_min_max_cell_bounded - (child_h, &new_h, min_h, max_h, oh, &off_y, &off_y_t, &off_y_b, align_y, pad_t, pad_b); - - if (new_w > top_w) top_w = new_w; - if (new_h > top_h) top_h = new_h; - - if ((new_w != child_w) || (new_h != child_h)) - evas_object_resize(child, new_w, new_h); - evas_object_move(child, ox + off_x, oy + off_y); - - evas_object_resize(ge_item->highlight, new_w, new_h); - evas_object_move(ge_item->highlight, ox + off_x, oy + off_y); - - evas_object_resize(ge_item->border, - new_w + abs(off_x_t - off_x_b), - new_h + abs(off_y_t - off_y_b)); - - if (align_x >= 0) - off_x = (off_x_t > off_x_b) ? off_x_b : off_x_t; - if (align_y >= 0) - off_y = (off_y_t > off_y_b) ? off_y_b : off_y_t; - - evas_object_move(ge_item->border, ox + off_x, oy + off_y); - - if (old_child) - evas_object_stack_above(child, old_child); - old_child = child; - - if (!spread) - { - if (ge_item->spread) - spread = ge_item->spread; - else - items = eina_list_next(items); - } - else - { - spread = eina_list_next(spread); - if (!spread) - { - ge_item = NULL; - items = eina_list_next(items); - } - } - } - - evas_object_size_hint_min_set(o, top_w, top_h); -} diff --git a/src/bin/ui/workspace/groupedit_calc.c b/src/bin/ui/workspace/groupedit_calc.c index 0cdd56a..9e971fd 100644 --- a/src/bin/ui/workspace/groupedit_calc.c +++ b/src/bin/ui/workspace/groupedit_calc.c @@ -47,9 +47,6 @@ _item_draw_add(Ws_Groupedit_Smart_Data *sd, Part_ *part, Eina_Stringshare *item) static void _item_draw_del(Groupedit_Item *ge_item); -static Evas_Object * -_part_container_add(Ws_Groupedit_Smart_Data *sd, Part_ *part, Eina_List **items); - static void _part_object_area_calc(Ws_Groupedit_Smart_Data *sd); @@ -645,6 +642,137 @@ _part_table_items_add(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) } } +/* get from edje_util.c:2935 */ +struct edje_box_layout_builtin +{ + const char *name; + Evas_Object_Box_Layout cb; +}; + +static Evas_Object_Box_Layout +_edje_box_layout_builtin_find(const char *name) +{ + const struct edje_box_layout_builtin _edje_box_layout_builtin[] = { + {"horizontal", evas_object_box_layout_horizontal}, + {"horizontal_flow", evas_object_box_layout_flow_horizontal}, + {"horizontal_homogeneous", evas_object_box_layout_homogeneous_horizontal}, + {"horizontal_max", evas_object_box_layout_homogeneous_max_size_horizontal}, + {"stack", evas_object_box_layout_stack}, + {"vertical", evas_object_box_layout_vertical}, + {"vertical_flow", evas_object_box_layout_flow_vertical}, + {"vertical_homogeneous", evas_object_box_layout_homogeneous_vertical}, + {"vertical_max", evas_object_box_layout_homogeneous_max_size_vertical}, + {NULL, NULL} + }; + const struct edje_box_layout_builtin *base; + + switch (name[0]) + { + case 'h': + base = _edje_box_layout_builtin + 0; + break; + + case 's': + base = _edje_box_layout_builtin + 4; + break; + + case 'v': + base = _edje_box_layout_builtin + 5; + break; + + default: + return NULL; + } + + for (; (base->name) && (base->name[0] == name[0]); base++) + if (strcmp(base->name, name) == 0) + return base->cb; + + return NULL; +} + +static void +_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; + Evas_Object *cell, *cell_content; + + assert(gp->container == NULL); + + gp->container = evas_object_box_add(sd->e); + elm_box_pack_end(gp->draw, gp->container); + evas_object_show(gp->container); + + EINA_LIST_FOREACH(gp->part->items, l, str) + { + spread_w = edje_edit_part_item_spread_w_get(sd->group->edit_object, gp->part->name, str); + spread_h = edje_edit_part_item_spread_h_get(sd->group->edit_object, gp->part->name, str); + for (i = 0; i < (spread_w * spread_h); i++) + { + cell = elm_layout_add(sd->parent); + evas_object_size_hint_align_set(cell, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_layout_theme_set(cell, "layout", "groupview", "default"); + 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); + + elm_object_content_set(cell, cell_content); + evas_object_hide(cell_content); + evas_object_box_append(gp->container, cell); + } + } +} + +static void +_box_param_update(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) +{ + double align_x = 0, align_y = 0; + int pad_x, pad_y; + Eina_Stringshare *layout; + + assert(sd != NULL); + assert(gp != NULL); + + PART_STATE_GET(sd->group->edit_object, gp->part->name) + + layout = edje_edit_state_box_layout_get(sd->group->edit_object, gp->part->name, state, value); + evas_object_box_layout_set(gp->container, _edje_box_layout_builtin_find(layout), NULL, NULL); + + align_x = edje_edit_state_container_align_x_get(sd->group->edit_object, gp->part->name, state, value); + align_y = edje_edit_state_container_align_y_get(sd->group->edit_object, gp->part->name, state, value); + evas_object_box_align_set(gp->container, align_x, align_y); + + pad_x = edje_edit_state_container_padding_x_get(sd->group->edit_object, gp->part->name, state, value); + pad_y = edje_edit_state_container_padding_y_get(sd->group->edit_object, gp->part->name, state, value); + evas_object_box_padding_set(gp->container, pad_x, pad_y); + + PART_STATE_FREE +} + #define GP_GEOMETRY_SET \ if (gp->bg) \ { \ @@ -727,6 +855,8 @@ _part_recalc_apply(Ws_Groupedit_Smart_Data *sd, evas_object_size_hint_min_set(gp->layout, w, h); evas_object_size_hint_max_set(gp->layout, w, h); + if (gp->container) evas_object_size_hint_max_set(gp->container, w, h); + evas_object_resize(gp->container, w, h); evas_object_move(gp->container, (x * sd->zoom_factor + xe + offset_x), (y * sd->zoom_factor + ye + offset_y)); @@ -891,6 +1021,7 @@ _parts_recalc(Ws_Groupedit_Smart_Data *sd) break; case EDJE_PART_TYPE_BOX: _box_param_update(sd, gp); + _common_param_update(gp, sd->group->edit_object); _part_recalc_apply(sd, gp, offset_x, offset_y); break; case EDJE_PART_TYPE_SPACER: @@ -997,8 +1128,11 @@ _part_draw_add(Ws_Groupedit_Smart_Data *sd, Part_ *part) _part_table_items_add(sd, gp); break; case EDJE_PART_TYPE_BOX: - IMAGE_ADD_NEW(sd->obj, gp->bg, "bg", "box") - gp->draw = _part_container_add(sd, part, &(gp->items)); + PART_VIEW_ADD() + PART_VIEW_PROXY_SET() + elm_object_signal_emit(gp->layout, "border,box", "eflete"); + _part_box_add(sd, gp); + break; case EDJE_PART_TYPE_EXTERNAL: default: @@ -1118,36 +1252,6 @@ _move_border_to_top(Ws_Groupedit_Smart_Data *sd) evas_object_smart_member_add(sd->handler_BR.obj, sd->obj); } -static Evas_Object * -_part_container_add(Ws_Groupedit_Smart_Data *sd, Part_ *part, Eina_List **items) -{ - Evas_Object *container; - Eina_List *l_items = NULL, *l_n_items = NULL; - Eina_Stringshare *item_name = NULL; - Groupedit_Item *ge_item = NULL; - - assert(sd != NULL); - assert(part != NULL); - - if (part->type == EDJE_PART_TYPE_BOX) - container = evas_object_box_add(sd->e); - else if (part->type == EDJE_PART_TYPE_TABLE) - container = evas_object_table_add(sd->e); - else - return NULL; - evas_object_show(container); - - EINA_LIST_FOREACH_SAFE(part->items, l_items, l_n_items, item_name) - { - ge_item = _item_draw_add(sd, part, item_name); - *items = eina_list_append(*items, ge_item); - } - - evas_object_smart_calculate(container); - - return container; -} - static inline void _colors_get(Groupedit_Part *gp, Evas_Object *edit_obj, const char *state, double value, int *r, int *g, int *b, int *a, @@ -1380,6 +1484,7 @@ _table_param_update(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) assert(gp != NULL); PART_STATE_GET(sd->group->edit_object, gp->part->name) + homogeneous = edje_edit_state_table_homogeneous_get(sd->group->edit_object, gp->part->name, state, value); evas_object_table_homogeneous_set(gp->container, homogeneous); @@ -1394,210 +1499,6 @@ _table_param_update(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) PART_STATE_FREE } -static Evas_Object_Box_Layout -_box_layout_function_get(const char *primary, const char *fallback) -{ - const struct edje_box_layouts *base = _edje_box_layouts; - const struct edje_box_layouts *base_fallback = _edje_box_layouts; - - if (primary) - { - for (; base->name; base++) - if (strcmp(base->name, primary) == 0) - return base->cb; - } - if (fallback) - { - for (; base_fallback->name; base_fallback++) - if (strcmp(base_fallback->name, fallback) == 0) - return base_fallback->cb; - } - - return _box_layout_horizontal; -} - - -static void -_box_param_update(Ws_Groupedit_Smart_Data *sd, Groupedit_Part *gp) -{ - Groupedit_Item *ge_item = NULL, *spread_item = NULL; - Eina_List *l_items, *l_n_items; - Eina_Stringshare *part = gp->part->name; - Eina_Stringshare *item_source = NULL; - Eina_Stringshare *primary_layout = NULL; - Eina_Stringshare *fallback_layout = NULL; - - int w, h; /* Geometry values */ - int min_w, max_w, prefer_w, min_h, max_h, prefer_h; /* Hints values */ - int spread_col, spread_row, old_spread_row; /* Position values */ - Evas_Aspect_Control aspect = EVAS_ASPECT_CONTROL_NONE; - int aspect_x, aspect_y; - double align_x = 0, align_y = 0, weight_x = 0, weight_y = 0; /* Align object in cell */ - int pad_l = 0, pad_r = 0, pad_t = 0, pad_b = 0; - int r = 0, g = 0, b = 0, a = 0; - double box_align_x, box_align_y; - int pad_x, pad_y; - - assert(sd != NULL); - assert(gp != NULL); - - TODO("get items from box and edje_unload them, remove them, destroy them") - evas_object_box_remove_all(gp->draw, false); - - PART_STATE_GET(sd->group->edit_object, part) - _colors_get(gp, sd->group->edit_object, state, value, &r, &g, &b, &a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - PART_STATE_FREE - - box_align_x = edje_edit_state_container_align_x_get(sd->group->edit_object, part, state, value); - box_align_y = edje_edit_state_container_align_y_get(sd->group->edit_object, part, state, value); - evas_object_box_align_set(gp->draw, box_align_x, box_align_y); - pad_x = edje_edit_state_container_padding_x_get(sd->group->edit_object, part, state, value); - pad_y = edje_edit_state_container_padding_y_get(sd->group->edit_object, part, state, value); - evas_object_box_padding_set(gp->draw, pad_x, pad_y); - - /* Changing layout according to edje_edit params! */ - primary_layout = edje_edit_state_box_layout_get(sd->group->edit_object, part, state, value); - fallback_layout = edje_edit_state_box_alt_layout_get(sd->group->edit_object, part, state, value); - evas_object_box_layout_set(gp->draw, - _box_layout_function_get(primary_layout, fallback_layout), gp->items, NULL); - eina_stringshare_del(primary_layout); - eina_stringshare_del(fallback_layout); - - EINA_LIST_FOREACH_SAFE(gp->items, l_items, l_n_items, ge_item) - { - evas_object_del(ge_item->draw); - ge_item->draw = edje_object_add(sd->e); - evas_object_show(ge_item->draw); - - item_source = edje_edit_part_item_source_get(sd->group->edit_object, part, ge_item->name); - edje_object_file_set(ge_item->draw, ap.project->dev, item_source); - - evas_object_box_append(gp->draw, ge_item->draw); - - min_w = edje_edit_part_item_min_w_get(sd->group->edit_object, part, ge_item->name); - min_h = edje_edit_part_item_min_h_get(sd->group->edit_object, part, ge_item->name); - - if ((min_w <= 0) && (min_h <= 0)) - { - edje_object_size_min_get(ge_item->draw, &w, &h); - if ((w <= 0) && (h <= 0)) - edje_object_size_min_calc(ge_item->draw, &w, &h); - } - if (((min_w <= 0) && (min_h <= 0)) && ((w > 0) || (h > 0))) - evas_object_size_hint_min_set(ge_item->draw, w, h); - else - { - w = min_w; - h = min_h; - evas_object_size_hint_min_set(ge_item->draw, min_w, min_h); - } - max_w = edje_edit_part_item_max_w_get(sd->group->edit_object, part, ge_item->name); - max_h = edje_edit_part_item_max_h_get(sd->group->edit_object, part, ge_item->name); - evas_object_size_hint_max_set(ge_item->draw, max_w, max_h); - prefer_w = edje_edit_part_item_prefer_w_get(sd->group->edit_object, part, ge_item->name); - prefer_h = edje_edit_part_item_prefer_h_get(sd->group->edit_object, part, ge_item->name); - evas_object_size_hint_request_set(ge_item->draw, prefer_w, prefer_h); - edje_edit_part_item_padding_get(sd->group->edit_object, part, ge_item->name, &pad_l, &pad_r, &pad_t, &pad_b); - evas_object_size_hint_padding_set(ge_item->draw, pad_l, pad_r, pad_t, pad_b); - align_x = edje_edit_part_item_align_x_get(sd->group->edit_object, part, ge_item->name); - align_y = edje_edit_part_item_align_y_get(sd->group->edit_object, part, ge_item->name); - evas_object_size_hint_align_set(ge_item->draw, align_x, align_y); - weight_x = edje_edit_part_item_weight_x_get(sd->group->edit_object, part, ge_item->name); - weight_y = edje_edit_part_item_weight_y_get(sd->group->edit_object, part, ge_item->name); - evas_object_size_hint_weight_set(ge_item->draw, weight_x, weight_y); - switch(edje_edit_part_item_aspect_mode_get(sd->group->edit_object, part, ge_item->name)) - { - case EDJE_ASPECT_CONTROL_NONE: aspect = EVAS_ASPECT_CONTROL_NONE; break; - case EDJE_ASPECT_CONTROL_NEITHER: aspect = EVAS_ASPECT_CONTROL_NEITHER; break; - case EDJE_ASPECT_CONTROL_HORIZONTAL: aspect = EVAS_ASPECT_CONTROL_HORIZONTAL; break; - case EDJE_ASPECT_CONTROL_VERTICAL: aspect = EVAS_ASPECT_CONTROL_VERTICAL; break; - case EDJE_ASPECT_CONTROL_BOTH: aspect = EVAS_ASPECT_CONTROL_BOTH; break; - } - aspect_x = edje_edit_part_item_aspect_w_get(sd->group->edit_object, part, ge_item->name); - aspect_y = edje_edit_part_item_aspect_h_get(sd->group->edit_object, part, ge_item->name); - evas_object_size_hint_aspect_set(ge_item->draw, aspect, aspect_x, aspect_y); - - spread_col = edje_edit_part_item_spread_w_get(sd->group->edit_object, part, ge_item->name); - spread_row = edje_edit_part_item_spread_h_get(sd->group->edit_object, part, ge_item->name); - - EINA_LIST_FREE(ge_item->spread, spread_item) - { - evas_object_smart_member_del(spread_item->border); - evas_object_smart_member_del(spread_item->draw); - evas_object_smart_member_del(spread_item->highlight); - evas_object_del(spread_item->border); - evas_object_del(spread_item->draw); - evas_object_del(spread_item->highlight); - free(spread_item); - } - old_spread_row = spread_row; - - while((spread_col > 1) || (spread_row > 1)) - { - spread_item = (Groupedit_Item *)mem_calloc(1, sizeof(Groupedit_Item)); - - IMAGE_ADD_NEW(sd->obj, spread_item->border, "bg", "part_item") - evas_object_size_hint_min_set(spread_item->border, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_align_set(spread_item->border, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(spread_item->border, EVAS_HINT_FILL, EVAS_HINT_FILL); - - IMAGE_ADD_NEW(sd->obj, spread_item->highlight, "border", "1px"); - evas_object_size_hint_min_set(spread_item->highlight, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_align_set(spread_item->highlight, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(spread_item->highlight, EVAS_HINT_FILL, EVAS_HINT_FILL); - - if (ge_item->selected) - { - edje_object_file_set(spread_item->highlight, EFLETE_THEME, "elm/image/border/2px"); - evas_object_color_set(spread_item->highlight, 0, 253, 255, 255); - } - else - { - edje_object_file_set(spread_item->highlight, EFLETE_THEME, "elm/image/border/1px"); - evas_object_color_set(spread_item->highlight, 49, 140, 141, 255); - } - - spread_item->draw = edje_object_add(sd->e); - edje_object_file_set(spread_item->draw, ap.project->dev, item_source); - evas_object_size_hint_max_set(spread_item->draw, max_w, max_h); - evas_object_size_hint_request_set(spread_item->draw, prefer_w, prefer_h); - evas_object_size_hint_min_set(spread_item->draw, min_w, min_h); - evas_object_size_hint_padding_set(spread_item->draw, pad_l, pad_r, pad_t, pad_b); - evas_object_size_hint_align_set(spread_item->draw, align_x, align_y); - evas_object_size_hint_weight_set(spread_item->draw, weight_x, weight_y); - evas_object_size_hint_aspect_set(spread_item->draw, aspect, aspect_x, aspect_y); - - ge_item->spread = eina_list_append(ge_item->spread, spread_item); - evas_object_box_append(gp->draw, spread_item->draw); - - evas_object_smart_member_add(spread_item->draw, gp->draw); - evas_object_smart_member_add(spread_item->border, gp->draw); - evas_object_smart_member_add(spread_item->highlight, gp->draw); - - evas_object_show(spread_item->border); - evas_object_show(spread_item->draw); - evas_object_show(spread_item->highlight); - evas_object_raise(spread_item->draw); - evas_object_raise(spread_item->highlight); - evas_object_lower(spread_item->border); - - if (spread_row > 1) spread_row--; - else if (spread_col > 1) {spread_col--; spread_row = old_spread_row; } - evas_object_color_set(spread_item->draw, r, g, b, a); - } - - evas_object_color_set(ge_item->draw, r, g, b, a); - - evas_object_smart_member_add(ge_item->border, gp->draw); - evas_object_smart_member_add(ge_item->draw, gp->draw); - evas_object_smart_member_add(ge_item->highlight, gp->draw); - evas_object_raise(ge_item->highlight); - - evas_object_show(ge_item->border); - evas_object_show(ge_item->highlight); - } -} - static void _part_object_area_calc(Ws_Groupedit_Smart_Data *sd) { --
