From: tasn Date: Tue, 31 Jan 2012 11:32:48 +0000 (+0000) Subject: Evas textblock: Fixed native size calculation - margins were not used. X-Git-Tag: submit/trunk/20120815.174732~513 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=218b9f473b926f7b1b454d36cf54ea5bc9bd7862;p=profile%2Fivi%2Fevas.git Evas textblock: Fixed native size calculation - margins were not used. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@67631 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 19ea238..53f9a77 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -9062,12 +9062,22 @@ _size_native_calc_line_finalize(const Evas_Object *obj, Eina_List *items, Eina_List *i; it = eina_list_data_get(items); - /* If there are no text items yet, calc ascent/descent - * according to the current format. */ - if (it && (*ascent + *descent == 0)) - _layout_format_ascent_descent_adjust(obj, ascent, descent, it->format); - *w = 0; + + if (it) + { + /* If there are no text items yet, calc ascent/descent + * according to the current format. */ + if (*ascent + *descent == 0) + _layout_format_ascent_descent_adjust(obj, ascent, descent, + it->format); + + /* Add margins. */ + if (it->format) + *w = it->format->margin.l + it->format->margin.r; + } + + /* Adjust all the item sizes according to the final line size, * and update the x positions of all the items of the line. */ EINA_LIST_FOREACH(items, i, it) diff --git a/src/tests/evas_test_textblock.c b/src/tests/evas_test_textblock.c index cf6a78b..7413f70 100644 --- a/src/tests/evas_test_textblock.c +++ b/src/tests/evas_test_textblock.c @@ -2090,6 +2090,29 @@ START_TEST(evas_textblock_size) fail_if((w != nw) || (h != nh)); fail_if(w <= 0); + /* This time with margins. */ + { + Evas_Textblock_Style *newst; + Evas_Coord oldw, oldh, oldnw, oldnh; + + evas_object_textblock_text_markup_set(tb, buf); + evas_object_textblock_size_formatted_get(tb, &oldw, &oldh); + evas_object_textblock_size_native_get(tb, &oldnw, &oldnh); + + + newst = evas_textblock_style_new(); + fail_if(!newst); + evas_textblock_style_set(newst, + "DEFAULT='left_margin=4 right_margin=4'"); + evas_object_textblock_style_user_set(tb, newst); + + evas_object_textblock_size_formatted_get(tb, &w, &h); + evas_object_textblock_size_native_get(tb, &nw, &nh); + + fail_if((w != oldw + 8) || (h != oldh) || + (nw != oldnw + 8) || (nh != oldnh)); + } + /* FIXME: There is a lot more to be done. */ END_TB_TEST(); }