forked from enlightenment/efl
Edje calc: Fix Evas Text width calculation with ellipsis
Summary: To keep consistency with Evas Textblock part in edje, text.min has to work logically even if ellipsis is enabled. If a Text part has minimum width, maximum width and "text.min: 1 X;", Text part should be expanded until its width reaches to the maximum width. Then, ellipsis will work. Singleline Textblock is also working like this. @fix Reviewers: cedric, herdsman, raster, tasn Subscribers: Blackmole, z-wony, jpeg Differential Revision: https://phab.enlightenment.org/D3587
This commit is contained in:
parent
f796f04aae
commit
982ef0b9d0
|
@ -15057,19 +15057,6 @@ 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 */
|
||||
|
@ -15093,25 +15080,11 @@ 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)
|
||||
|
|
|
@ -1700,20 +1700,26 @@ _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
|
||||
|
|
|
@ -135,7 +135,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
|
|||
|
||||
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
||||
|
||||
evas_obj_text_ellipsis_set(ep->object, (chosen_desc->text.min_x || chosen_desc->text.fit_x) ? -1 : params->type.text.ellipsis);
|
||||
evas_obj_text_ellipsis_set(ep->object, params->type.text.ellipsis);
|
||||
efl_text_properties_font_set(ep->object, font, size);
|
||||
efl_text_set(ep->object, text);
|
||||
efl_gfx_size_set(ep->object, sw, sh);
|
||||
|
@ -462,28 +462,11 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
|||
text, font, size,
|
||||
sw, sh, &free_text);
|
||||
}
|
||||
/* 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);
|
||||
else if ((ed->file->version >= 3) && (ed->file->minor >= 6))
|
||||
{
|
||||
evas_object_text_ellipsis_set(ep->object,
|
||||
params->type.text.ellipsis);
|
||||
}
|
||||
|
||||
eina_stringshare_replace(&ep->typedata.text->cache.out_str, text);
|
||||
ep->typedata.text->cache.in_w = sw;
|
||||
|
|
Loading…
Reference in New Issue