From 6da2b4af5ba4d2accf55d665f3cc6137635155b9 Mon Sep 17 00:00:00 2001 From: barbieri Date: Sun, 21 Aug 2011 01:38:17 +0000 Subject: [PATCH] change text's single recalc to use apply version. Original _edje_part_recalc_single_text() was not working as expected since it was not doing size fit, range, ellipsis and so on. The purpose of this function compared with _edje_text_recalc_apply() is to be faster, not calling Evas update functions. However for text this is quite difficult given that to fit we need to set the font, size, style, etc. If it was done correctly, we'd save some calls to move and some color sets, however those shouldn't matter much in the overall picture. I've changed this to force applying the value, it should be more correct and not so slow. The previous code is kept below for reference but should be removed before next release! git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@62640 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/edje_calc.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 12b7671..efc1a1c 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -989,6 +989,69 @@ _edje_part_recalc_single_text(FLOAT_T sc, Edje_Calc_Params *params, int *minw, int *minh, int *maxw, int *maxh) +#define RECALC_SINGLE_TEXT_USING_APPLY 1 +#if RECALC_SINGLE_TEXT_USING_APPLY +/* + * XXX TODO NOTE: + * + * Original _edje_part_recalc_single_text() was not working as + * expected since it was not doing size fit, range, ellipsis and so + * on. + * + * The purpose of this function compared with + * _edje_text_recalc_apply() is to be faster, not calling Evas update + * functions. However for text this is quite difficult given that to + * fit we need to set the font, size, style, etc. If it was done + * correctly, we'd save some calls to move and some color sets, + * however those shouldn't matter much in the overall picture. + * + * I've changed this to force applying the value, it should be more + * correct and not so slow. The previous code is kept below for + * reference but should be removed before next release! + * + * -- Gustavo Barbieri at 20-Aug-2011 + */ +{ + int tw, th, mw, mh, l, r, t, b, size; + char *sfont = NULL; + + _edje_text_class_font_get(ed, desc, &size, &sfont); + free(sfont); + params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */ + + _edje_text_recalc_apply(ed, ep, params, chosen_desc); + + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + + if ((!chosen_desc) || + ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) && + (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y))) + return; + + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b); + + mw = tw + l + r; + mh = th + t + b; + + if (chosen_desc->text.max_x) + { + if ((*maxw < 0) || (mw < *maxw)) *maxw = mw; + } + if (chosen_desc->text.max_y) + { + if ((*maxh < 0) || (mh < *maxh)) *maxh = mh; + } + if (chosen_desc->text.min_x) + { + if (mw > *minw) *minw = mw; + } + if (chosen_desc->text.min_y) + { + if (mh > *minh) *minh = mh; + } +} +#else { char *sfont = NULL; int size; @@ -1166,6 +1229,7 @@ _edje_part_recalc_single_text(FLOAT_T sc, free(sfont); params->type.text.size = size; } +#endif static void _edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min) -- 2.7.4