Evas textblock: Fixed native size calculation - margins were not used.

SVN revision: 67631
This commit is contained in:
Tom Hacohen 2012-01-31 11:32:48 +00:00
parent 64e2d7fee5
commit f91a385b62
2 changed files with 38 additions and 5 deletions

View File

@ -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)

View File

@ -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();
}