summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-09-20 16:09:21 +0100
committerTom Hacohen <tom@stosb.com>2013-09-23 14:37:18 +0100
commitcbde2bef69bebbdce496303365a8c5cd0fa49b79 (patch)
tree075bb8d11aa1bf390725c9c2ad5c07021991a8ad
parent72167b9cc3db0a28a6be53de676662d93cd820b5 (diff)
Evas textblock: Fixed max descent adjustment and a related bug.
The bug caused wrong line sizing in some situations (appending new paragraphs to a textblock).
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 086cc152fc..99a1ad36de 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -2566,6 +2566,9 @@ _layout_item_max_ascent_descent_calc(const Evas_Object *eo_obj,
2566 void *fi = NULL; 2566 void *fi = NULL;
2567 *maxascent = *maxdescent = 0; 2567 *maxascent = *maxdescent = 0;
2568 2568
2569 if (!it || !it->format || !it->format->font.font)
2570 return;
2571
2569 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT) 2572 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
2570 { 2573 {
2571 fi = _ITEM_TEXT(it)->text_props.font_instance; 2574 fi = _ITEM_TEXT(it)->text_props.font_instance;
@@ -3289,6 +3292,42 @@ _layout_calculate_format_item_size(const Evas_Object *eo_obj,
3289 *_h = h; 3292 *_h = h;
3290} 3293}
3291 3294
3295static Evas_Coord
3296_layout_last_line_max_descent_adjust_calc(Ctxt *c, const Evas_Object_Textblock_Paragraph *last_vis_par)
3297{
3298 if (last_vis_par->lines)
3299 {
3300 Evas_Object_Textblock_Line *ln = (Evas_Object_Textblock_Line *)
3301 EINA_INLIST_GET(last_vis_par->lines)->last;
3302 Evas_Object_Textblock_Item *it;
3303
3304 EINA_INLIST_FOREACH(ln->items, it)
3305 {
3306 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
3307 {
3308 Evas_Coord asc = 0, desc = 0;
3309 Evas_Coord maxasc = 0, maxdesc = 0;
3310 _layout_item_ascent_descent_adjust(c->obj, &asc, &desc,
3311 it, c->position);
3312 _layout_item_max_ascent_descent_calc(c->obj, &maxasc, &maxdesc,
3313 it, c->position);
3314
3315 if (desc > c->descent)
3316 c->descent = desc;
3317 if (maxdesc > c->maxdescent)
3318 c->maxdescent = maxdesc;
3319 }
3320 }
3321
3322 if (c->maxdescent > c->descent)
3323 {
3324 return c->maxdescent - c->descent;
3325 }
3326 }
3327
3328 return 0;
3329}
3330
3292/** 3331/**
3293 * @internal 3332 * @internal
3294 * Order the items in the line, update it's properties and update it's 3333 * Order the items in the line, update it's properties and update it's
@@ -3364,18 +3403,6 @@ loop_advance:
3364 c->ln->y += ascdiff; 3403 c->ln->y += ascdiff;
3365 c->y += ascdiff; 3404 c->y += ascdiff;
3366 } 3405 }
3367
3368 /* If it's the end, add the adjustment to the line height. */
3369 if (((c->position == TEXTBLOCK_POSITION_END) ||
3370 (c->position == TEXTBLOCK_POSITION_SINGLE))
3371 && (c->maxdescent > c->descent))
3372 {
3373 Evas_Coord descdiff;
3374
3375 descdiff = c->maxdescent - c->descent;
3376 c->ln->h += descdiff;
3377 c->y += descdiff;
3378 }
3379 } 3406 }
3380 3407
3381 c->ln->baseline = c->ascent; 3408 c->ln->baseline = c->ascent;
@@ -5153,7 +5180,10 @@ _layout(const Evas_Object *eo_obj, int w, int h, int *w_ret, int *h_ret)
5153 EINA_INLIST_GET(c->paragraphs)->last; 5180 EINA_INLIST_GET(c->paragraphs)->last;
5154 5181
5155 if (last_vis_par) 5182 if (last_vis_par)
5156 c->hmax = last_vis_par->y + last_vis_par->h; 5183 {
5184 c->hmax = last_vis_par->y + last_vis_par->h +
5185 _layout_last_line_max_descent_adjust_calc(c, last_vis_par);
5186 }
5157 } 5187 }
5158 5188
5159 /* Clean the rest of the format stack */ 5189 /* Clean the rest of the format stack */