On 15/02/13 17:55, Enlightenment Git wrote: > The branch, master has been updated > > This change consists of the following commits: > 91ae899 Tom Hacohen: Edje textblock: Improved textblock fit and added support > for size_range. > > > Summary of changes: > ChangeLog | 5 ++++ > NEWS | 2 ++ > src/lib/edje/edje_calc.c | 59 > ++++++++++++++++++++++++++++++++++++++++-------- > 3 files changed, 57 insertions(+), 9 deletions(-) > > ----------------------------------------------------------------------- > http://git.enlightenment.org/core/efl.git/commit/?id=91ae899232bc9fe50554039b9631ef913c8b4a7c > > commit 91ae899232bc9fe50554039b9631ef913c8b4a7c > Author: Tom Hacohen <t...@stosb.com> > Date: Fri Feb 15 15:38:49 2013 +0000 > > Edje textblock: Improved textblock fit and added support for size_range. > > It's a bit quirky at the moment as you have to set the base font size > (text.size) although this doesn't have any effect on textblocks. > > diff --git a/ChangeLog b/ChangeLog > index 801a39d..5e062c7 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,8 @@ > +2013-02-15 Tom Hacohen (TAsn) > + > + * Edje textblock: Improved textblock fit and added support for > + size_range. > + > 2013-02-15 Jiyoun Park (jypark) > > * Add infrastructure to handle message between ecore and parent ecore > in Ecore_Evas. > diff --git a/NEWS b/NEWS > index cb86002..7a8c868 100644 > --- a/NEWS > +++ b/NEWS > @@ -64,6 +64,7 @@ Additions: > * Add eio_eet_sync symbols. > * Add infrastructure to handle buggy touchscreen in Ecore_Input_Evas. > * Add infrastructure to handle message between ecore and parent ecore > in Ecore_Evas. > + * Edje textblock: Added support for size_range. > > Deprecations: > * ecore_x: > @@ -167,3 +168,4 @@ Fixes: > * Fix memory leak in error case in ethumb. > * fix bug not to display preedit string with PREEDIT_TYPE_NONE style > * Fix bug candidate word couldn't be selected with up/down key in the > preedit status > + * Edje textblock: Improved textblock fit. > diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c > index b56d5b7..f1ea8cc 100644 > --- a/src/lib/edje/edje_calc.c > +++ b/src/lib/edje/edje_calc.c > @@ -1144,6 +1144,26 @@ > _edje_part_recalc_single_step(Edje_Part_Description_Common *desc, > } > } > > +static double > +_edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text > *chosen_desc, double base_scale, double scale) > +{ > + double size, min, max; > + > + if (chosen_desc->text.size == 0) > + return scale; > + > + min = base_scale * chosen_desc->text.size_range_min; > + max = chosen_desc->text.size_range_max * base_scale; > + size = chosen_desc->text.size * scale; > + > + if ((size > max) && (max > 0)) > + scale = max / (double) chosen_desc->text.size; > + else if (size < min) > + scale = min / (double) chosen_desc->text.size; > + > + return scale; > +} > + > static void > _edje_part_recalc_single_textblock(FLOAT_T sc, > Edje *ed, > @@ -1277,35 +1297,56 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, > if (minh && (*maxh < *minh)) *maxh = *minh; > } > } > + > if ((chosen_desc->text.fit_x) || (chosen_desc->text.fit_y)) > { > - double s = 1.0; > + double base_s = 1.0; > + double orig_s; > + double s = base_s; > > - if (ep->part->scale) s = TO_DOUBLE(sc); > + if (ep->part->scale) base_s = TO_DOUBLE(sc); > eo_do(ep->object, > - evas_obj_scale_set(s), > + evas_obj_scale_set(base_s), > evas_obj_textblock_size_formatted_get(&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 * params->w / (double) tw); > + eo_do(ep->object, > + evas_obj_scale_set(orig_s), > + evas_obj_textblock_size_formatted_get(&tw, &th)); > + } > if (chosen_desc->text.fit_x) > { > - if ((tw > 0) && (tw > params->w)) > + if (tw > 0) > { > - s = (s * params->w) / (double)tw; > + s = > _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, > orig_s * params->w / tw); > eo_do(ep->object, > evas_obj_scale_set(s), > - evas_obj_textblock_size_formatted_get(&tw, &th)); > + evas_obj_textblock_size_formatted_get(NULL, NULL)); > } > } > if (chosen_desc->text.fit_y) > { > - if ((th > 0) && (th > params->h)) > + if (th > 0) > { > - s = (s * params->h) / (double)th; > + double tmp_s = > _edje_part_recalc_single_textblock_scale_range_adjust(chosen_desc, base_s, > orig_s * params->h / (double) 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; > + } > + > eo_do(ep->object, > evas_obj_scale_set(s), > - evas_obj_textblock_size_formatted_get(&tw, &th)); > + evas_obj_textblock_size_formatted_get(NULL, NULL)); > } > } > } > + > evas_object_textblock_valign_set(ep->object, > TO_DOUBLE(chosen_desc->text.align.y)); > } > } > > ----------------------------------------------------------------------- > >
At the moment, the API is kinda quirky: Because we don't really know the current textblock font size, I had to set a value. So at the moment you actually need to set text.size: 20; text.size_range: 10 60; Which means textblock will be allowed to change font sizes to be anywhere from half to 3 times the used font sizes. There are 3 alternative solutions to this in the order I prefer them: 1. Process the style and get the font size used there and then use it instead of text.size. 2. Modify the style according to whatever we set in text.size. 3. Leave it as it is. The only problems I can come up with regarding solutions 1 and 2 is that some other things can actually affect the font sizes, like user styles and formats, so that may be just an unrelated value. On the other hand, the basic style size is actually set in the theme, so it's cool as it'll actually be used. And the second problem is that styles might be changed at any time and we'll have to hook on them in many places in order to change them which can be pretty problematic because it goes straight to textblock, not through edje. What do you guys think we should do? -- Tom. ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel