From 0e658b62d7c78d075c491b6cad58eb06b7930948 Mon Sep 17 00:00:00 2001 From: Youngbok Shin Date: Fri, 26 Aug 2016 16:20:14 +0900 Subject: [PATCH] Revert "Edje calc: Fix Evas Text width calculation with ellipsis" This reverts commit 187f4535be5766b35d33c737cc58d7e60314d592. Change-Id: I9cfe2cbe79eb1ff0c38a773be8485a90b0ab7c2b --- src/bin/edje/edje_cc_handlers.c | 27 +++++++++++++++++++++++++++ src/lib/edje/edje_calc.c | 10 ++-------- src/lib/edje/edje_text.c | 29 +++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index d1c1937..ade4c08 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -14103,6 +14103,19 @@ edje_cc_handlers_hierarchy_free(void) part_hierarchy = NULL; } +static Eina_Bool +_part_text_ellipsis_check(Edje_Part *ep, Edje_Part_Description_Common *desc) +{ + Edje_Part_Description_Text *ed; + + if ((ep->type != EDJE_PART_TYPE_TEXT) && (ep->type != EDJE_PART_TYPE_TEXTBLOCK)) + return EINA_FALSE; + + ed = (Edje_Part_Description_Text*)desc; + + return ((ed->text.ellipsis != -1) && ed->text.min_x); +} + static void edje_cc_handlers_hierarchy_pop(void) { /* Remove part from hierarchy stack when finished parsing it */ @@ -14120,11 +14133,25 @@ edje_cc_handlers_hierarchy_pop(void) file_in, line - 1, current_de->entry, current_part->name); exit(-1); } + if (_part_text_ellipsis_check(current_part, current_part->other.desc[i])) + { + WRN("Part '%s' in group '%s' contains description '%s:%g' which has text.min: 1 X; but not text.ellipsis: -1;", + current_part->name, current_de->entry, + current_part->other.desc[i]->state.name, current_part->other.desc[i]->state.value); + WRN("This is almost certainly not what you want."); + } } /* auto-add default desc if it was omitted */ if (!current_part->default_desc) ob_collections_group_parts_part_description(); + else if (_part_text_ellipsis_check(current_part, current_part->default_desc)) + { + WRN("Part '%s' in group '%s' contains description '%s:%g' which has text.min: 1 X; but not text.ellipsis: -1;", + current_part->name, current_de->entry, + current_part->default_desc->state.name, current_part->default_desc->state.value); + WRN("This is almost certainly not what you want."); + } } if (info) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 393689e..3f60e49 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -1722,26 +1722,20 @@ _edje_part_recalc_single_text(FLOAT_T sc EINA_UNUSED, if (chosen_desc->text.max_x) { - if ((*maxw < 0) || (mw > *maxw)) *maxw = mw; + if ((*maxw < 0) || (mw < *maxw)) *maxw = mw; } if (chosen_desc->text.max_y) { - if ((*maxh < 0) || (mh > *maxh)) *maxh = mh; + if ((*maxh < 0) || (mh < *maxh)) *maxh = mh; } if (chosen_desc->text.min_x) { if (mw > *minw) *minw = mw; - if ((*maxw > -1) && (*minw > *maxw)) *minw = *maxw; } if (chosen_desc->text.min_y) { if (mh > *minh) *minh = mh; - if ((*maxh > -1) && (*minh > *maxh)) *minh = *maxh; } - if ((*maxw > -1) && (mw > *maxw)) mw = *maxw; - if ((*maxh > -1) && (mh > *maxh)) mh = *maxh; - - evas_object_resize(ep->object, mw, mh); } #else diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c index 74e9e64..1b5d705 100644 --- a/src/lib/edje/edje_text.c +++ b/src/lib/edje/edje_text.c @@ -132,7 +132,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep, if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); eo_do(ep->object, - evas_obj_text_ellipsis_set(params->type.text.ellipsis), + evas_obj_text_ellipsis_set(chosen_desc->text.min_x ? -1 : params->type.text.ellipsis), efl_text_properties_font_set(font, size), efl_text_set(text), efl_gfx_size_set(sw, sh)); @@ -478,11 +478,28 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, text, font, size, sw, sh, &free_text); } - else if ((ed->file->version >= 3) && (ed->file->minor >= 6)) - { - evas_object_text_ellipsis_set(ep->object, - params->type.text.ellipsis); - } + /* when evas ellipsis support was added in efl 1.8 and used to replace + * previous support, SOMEONE, who I shall call "cedric", borked ellipsis + * defaults. as a result, edje_cc continued using 0.0 (left-most) as its default value + * for ellipsis while evas used -1.0 (no ellipsizing). + * this was moderately okay for a time because nobody was using it or GROUP parts + * with text in them very frequently, and so nobody noticed that the mismatch was breaking + * sizing in some cases when the edje ellipsis value failed to be applied, + * which occurred any time text.min_x was set; in this case, ellipsis would NEVER be + * correctly applied, and instead the text object would only ever get the first + * ellipsis_set(0), permanently breaking the part. + * the only way to fix this while preserving previous behavior was to bump + * the edje file minor version and then check it here to ignore "unset" ellipsis + * values from old file versions. + * the downside is that this will break old files which have text.min_x set to 0...maybe. + * + * -zmike + * 22 April 2014 + */ + else if (((ed->file->version >= 3) && (ed->file->minor >= 6)) || + params->type.text.ellipsis) + evas_object_text_ellipsis_set(ep->object, + chosen_desc->text.min_x ? -1 : params->type.text.ellipsis); eina_stringshare_replace(&ep->typedata.text->cache.out_str, text); ep->typedata.text->cache.in_w = sw; -- 2.7.4