edje: Remove hack code
Summary: special calculation for textblock is for fit calculation. This is obvious from code that fit is being calculated before text is actually been set to textblock. I am not sure whether this is intentional or mistake but it make sense to calculate fit after text is being set so that formatted and native calculation can be proper. @fix Test Plan: NA Reviewers: cedric, zmike, herdsman, devilhorns Subscribers: stefan_schmidt, #reviewers, #committers, shilpasingh Tags: #efl Differential Revision: https://phab.enlightenment.org/D6045
This commit is contained in:
parent
70d0fd0d52
commit
f107ea2432
|
@ -4972,14 +4972,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
|||
_edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table *)chosen_desc);
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_TEXTBLOCK:
|
||||
_edje_textblock_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text *)chosen_desc);
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_VECTOR:
|
||||
_edje_svg_recalc_apply(ed, ep, pf, (Edje_Part_Description_Vector *)chosen_desc, pos);
|
||||
break;
|
||||
|
||||
case EDJE_PART_TYPE_TEXTBLOCK:
|
||||
case EDJE_PART_TYPE_EXTERNAL:
|
||||
case EDJE_PART_TYPE_RECTANGLE:
|
||||
case EDJE_PART_TYPE_SWALLOW:
|
||||
|
|
|
@ -2575,11 +2575,6 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
|
|||
Edje_Calc_Params *params,
|
||||
int *minw, int *minh,
|
||||
int *maxw, int *maxh);
|
||||
void
|
||||
_edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||
Edje_Calc_Params *params,
|
||||
Edje_Part_Description_Text *chosen_desc);
|
||||
|
||||
|
||||
Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part);
|
||||
Edje_Real_Part *_edje_real_part_recursive_get(Edje **ed, const char *part);
|
||||
|
|
|
@ -460,80 +460,6 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
|
|||
if (ep->part->scale)
|
||||
evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
||||
|
||||
if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
|
||||
{
|
||||
double base_s = 1.0;
|
||||
double orig_s;
|
||||
double s = base_s;
|
||||
|
||||
if (ep->part->scale) base_s = TO_DOUBLE(sc);
|
||||
efl_gfx_entity_scale_set(ep->object, base_s);
|
||||
efl_canvas_text_size_native_get(ep->object, &tw, &th);
|
||||
|
||||
orig_s = base_s;
|
||||
/* Now make it bigger so calculations will be more accurate
|
||||
* and less influenced by hinting... */
|
||||
{
|
||||
orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.w) / tw);
|
||||
efl_gfx_entity_scale_set(ep->object, orig_s);
|
||||
efl_canvas_text_size_native_get(ep->object, &tw, &th);
|
||||
}
|
||||
if (chosen_desc->text.fit_x)
|
||||
{
|
||||
if (tw > 0)
|
||||
{
|
||||
s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.w) / tw);
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, NULL, NULL);
|
||||
}
|
||||
}
|
||||
if (chosen_desc->text.fit_y)
|
||||
{
|
||||
if (th > 0)
|
||||
{
|
||||
double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.h) / th);
|
||||
/* If we already have X fit, restrict Y to be no bigger
|
||||
* than what we got with X. */
|
||||
if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
|
||||
{
|
||||
s = tmp_s;
|
||||
}
|
||||
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Final tuning, try going down 90% at a time, hoping it'll
|
||||
* actually end up being correct. */
|
||||
{
|
||||
int i = 5; /* Tries before we give up. */
|
||||
Evas_Coord fw, fh;
|
||||
efl_canvas_text_size_native_get(ep->object, &fw, &fh);
|
||||
|
||||
/* If we are still too big, try reducing the size to
|
||||
* 95% each try. */
|
||||
while ((i > 0) &&
|
||||
((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
|
||||
(chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
|
||||
{
|
||||
double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
|
||||
|
||||
/* Break if we are not making any progress. */
|
||||
if (EQ(tmp_s, s))
|
||||
break;
|
||||
s = tmp_s;
|
||||
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, &fw, &fh);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stl)
|
||||
{
|
||||
if (evas_object_textblock_style_get(ep->object) != stl->style)
|
||||
|
@ -548,6 +474,80 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
|
|||
evas_object_textblock_text_markup_set(ep->object, text);
|
||||
}
|
||||
|
||||
if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y))
|
||||
{
|
||||
double base_s = 1.0;
|
||||
double orig_s;
|
||||
double s = base_s;
|
||||
|
||||
if (ep->part->scale) base_s = TO_DOUBLE(sc);
|
||||
efl_gfx_entity_scale_set(ep->object, base_s);
|
||||
efl_canvas_text_size_native_get(ep->object, &tw, &th);
|
||||
|
||||
orig_s = base_s;
|
||||
/* Now make it bigger so calculations will be more accurate
|
||||
* and less influenced by hinting... */
|
||||
{
|
||||
orig_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.w) / tw);
|
||||
efl_gfx_entity_scale_set(ep->object, orig_s);
|
||||
efl_canvas_text_size_native_get(ep->object, &tw, &th);
|
||||
}
|
||||
if (chosen_desc->text.fit_x)
|
||||
{
|
||||
if (tw > 0)
|
||||
{
|
||||
s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.w) / tw);
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, NULL, NULL);
|
||||
}
|
||||
}
|
||||
if (chosen_desc->text.fit_y)
|
||||
{
|
||||
if (th > 0)
|
||||
{
|
||||
double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s,
|
||||
orig_s * TO_INT(params->eval.h) / th);
|
||||
/* If we already have X fit, restrict Y to be no bigger
|
||||
* than what we got with X. */
|
||||
if (!((chosen_desc->text.fit_x) && (tmp_s > s)))
|
||||
{
|
||||
s = tmp_s;
|
||||
}
|
||||
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Final tuning, try going down 90% at a time, hoping it'll
|
||||
* actually end up being correct. */
|
||||
{
|
||||
int i = 5; /* Tries before we give up. */
|
||||
Evas_Coord fw, fh;
|
||||
efl_canvas_text_size_native_get(ep->object, &fw, &fh);
|
||||
|
||||
/* If we are still too big, try reducing the size to
|
||||
* 95% each try. */
|
||||
while ((i > 0) &&
|
||||
((chosen_desc->text.fit_x && (fw > TO_INT(params->eval.w))) ||
|
||||
(chosen_desc->text.fit_y && (fh > TO_INT(params->eval.h)))))
|
||||
{
|
||||
double tmp_s = _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, s * 0.95);
|
||||
|
||||
/* Break if we are not making any progress. */
|
||||
if (EQ(tmp_s, s))
|
||||
break;
|
||||
s = tmp_s;
|
||||
|
||||
efl_gfx_entity_scale_set(ep->object, s);
|
||||
efl_canvas_text_size_native_get(ep->object, &fw, &fh);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ed->file->efl_version.major >= 1) && (ed->file->efl_version.minor >= 19))
|
||||
{
|
||||
_edje_part_recalc_single_textblock_min_max_calc(ep,
|
||||
|
@ -569,24 +569,3 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
|
|||
evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
||||
Edje_Calc_Params *params,
|
||||
Edje_Part_Description_Text *chosen_desc)
|
||||
{
|
||||
/* FIXME: this is just an hack. */
|
||||
FLOAT_T sc;
|
||||
|
||||
#if 0
|
||||
_get_text(ep);
|
||||
#endif
|
||||
|
||||
sc = DIV(ed->scale, ed->file->base_scale);
|
||||
if (EQ(sc, ZERO)) sc = DIV(_edje_scale, ed->file->base_scale);
|
||||
if (chosen_desc->text.fit_x || chosen_desc->text.fit_y)
|
||||
{
|
||||
_edje_part_recalc_single_textblock(sc, ed, ep, chosen_desc, params,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue