From 5c5581fc9579144c7c2251461ef50df5d26ffe70 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 17 Jun 2011 11:25:30 +0000 Subject: [PATCH] evas table -> allow packing of same object again to update packing parameters SVN revision: 60446 --- legacy/evas/ChangeLog | 6 ++ .../evas/src/lib/canvas/evas_object_table.c | 92 ++++++++++++------- 2 files changed, 67 insertions(+), 31 deletions(-) diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog index 837433ddf4..4d40965b72 100644 --- a/legacy/evas/ChangeLog +++ b/legacy/evas/ChangeLog @@ -402,3 +402,9 @@ * Use Eina_File for JPEG loader. * Add evas_object_image_load_orientation_get and evas_object_image_load_orientation_set, that tell if we should honor the orientation information when loading image file. + +2011-06-17 Carsten Haitzler (The Rasterman) + + * Allow evas table to re-pack the same object without error and just + update packing parameters + diff --git a/legacy/evas/src/lib/canvas/evas_object_table.c b/legacy/evas/src/lib/canvas/evas_object_table.c index 20b6a2d6eb..533d9ab4a4 100644 --- a/legacy/evas/src/lib/canvas/evas_object_table.c +++ b/legacy/evas/src/lib/canvas/evas_object_table.c @@ -1064,17 +1064,14 @@ evas_object_table_pack(Evas_Object *o, Evas_Object *child, unsigned short col, u } opt = _evas_object_table_option_get(child); - if (opt) - { - ERR("cannot add object that is already part of a table!"); - return EINA_FALSE; - } - - opt = malloc(sizeof(*opt)); if (!opt) { - ERR("could not allocate table option data."); - return EINA_FALSE; + opt = malloc(sizeof(*opt)); + if (!opt) + { + ERR("could not allocate table option data."); + return EINA_FALSE; + } } opt->obj = child; @@ -1084,32 +1081,65 @@ evas_object_table_pack(Evas_Object *o, Evas_Object *child, unsigned short col, u opt->rowspan = rowspan; opt->end_col = col + colspan; opt->end_row = row + rowspan; - opt->min.w = 0; - opt->min.h = 0; - opt->max.w = 0; - opt->max.h = 0; - opt->align.h = 0.5; - opt->align.v = 0.5; - opt->pad.l = 0; - opt->pad.r = 0; - opt->pad.t = 0; - opt->pad.b = 0; - opt->expand_h = 0; - opt->expand_v = 0; + + if (evas_object_smart_parent_get(child) == o) + { + Eina_Bool need_shrink = EINA_FALSE; + + if (priv->size.cols < opt->end_col) + priv->size.cols = opt->end_col; + else + need_shrink = EINA_TRUE; + if (priv->size.rows < opt->end_row) + priv->size.rows = opt->end_row; + else + need_shrink = EINA_TRUE; - priv->children = eina_list_append(priv->children, opt); + if (need_shrink) + { + Eina_List *l; + Evas_Object_Table_Option *opt2; + int max_row, max_col; + + max_row = 0; + max_col = 0; + EINA_LIST_FOREACH(priv->children, l, opt2) + { + if (max_col < opt->end_col) max_col = opt->end_col; + if (max_row < opt->end_row) max_row = opt->end_row; + } + priv->size.cols = max_col; + priv->size.rows = max_row; + } + } + else + { + opt->min.w = 0; + opt->min.h = 0; + opt->max.w = 0; + opt->max.h = 0; + opt->align.h = 0.5; + opt->align.v = 0.5; + opt->pad.l = 0; + opt->pad.r = 0; + opt->pad.t = 0; + opt->pad.b = 0; + opt->expand_h = 0; + opt->expand_v = 0; - if (priv->size.cols < opt->end_col) - priv->size.cols = opt->end_col; - if (priv->size.rows < opt->end_row) - priv->size.rows = opt->end_row; - - _evas_object_table_option_set(child, opt); - evas_object_smart_member_add(child, o); - _evas_object_table_child_connect(o, child); + priv->children = eina_list_append(priv->children, opt); + + if (priv->size.cols < opt->end_col) + priv->size.cols = opt->end_col; + if (priv->size.rows < opt->end_row) + priv->size.rows = opt->end_row; + + _evas_object_table_option_set(child, opt); + evas_object_smart_member_add(child, o); + _evas_object_table_child_connect(o, child); + } _evas_object_table_cache_invalidate(priv); evas_object_smart_changed(o); - return EINA_TRUE; }