From 84032f17e7f74b0f126c3b1f9f26c8b91e41859f Mon Sep 17 00:00:00 2001 From: Youngbok Shin Date: Tue, 22 Nov 2016 20:12:36 +0900 Subject: [PATCH] edje: fix to get minimum width even if given width is 0 The patch also fix to calculate maximum width properly in some cases. It adds missing comment for Tizen only patches. @tizen_fix Change-Id: Iec1f6b76be3652031790de0bc24a135e8084c5fe --- src/lib/edje/edje_calc.c | 335 +++++++++++++++++++++++++++-------------------- src/lib/edje/edje_util.c | 62 +++++++++ 2 files changed, 256 insertions(+), 141 deletions(-) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 0d24a0c..cd7b2eb 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -1670,6 +1670,64 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, ((ptxt) && (!text))) evas_object_textblock_text_markup_set(ep->object, text); } + /* TIZEN_ONLY(20160901): Edje calc: Fix textblock size calculation logic + if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) + { + int mw = 0, mh = 0; + + tw = th = 0; + if (!chosen_desc->text.min_x) + { + eo_do(ep->object, + efl_gfx_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), + evas_obj_textblock_size_formatted_get(&tw, &th)); + } + else + evas_object_textblock_size_native_get(ep->object, &tw, &th); + evas_object_textblock_style_insets_get(ep->object, &ins_l, + &ins_r, &ins_t, &ins_b); + mw = ins_l + tw + ins_r; + mh = ins_t + th + ins_b; + if (minw && chosen_desc->text.min_x) + { + if (mw > *minw) *minw = mw; + } + if (minh && chosen_desc->text.min_y) + { + if (mh > *minh) *minh = mh; + } + } + } + + if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) + { + int mw = 0, mh = 0; + + tw = th = 0; + if (!chosen_desc->text.max_x) + { + eo_do(ep->object, + efl_gfx_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), + evas_obj_textblock_size_formatted_get(&tw, &th)); + } + else + evas_object_textblock_size_native_get(ep->object, &tw, &th); + evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, + &ins_t, &ins_b); + mw = ins_l + tw + ins_r; + mh = ins_t + th + ins_b; + if (maxw && chosen_desc->text.max_x) + { + if (mw > *maxw) *maxw = mw; + if (minw && (*maxw < *minw)) *maxw = *minw; + } + if (maxh && chosen_desc->text.max_y) + { + if (mh > *maxh) *maxh = mh; + if (minh && (*maxh < *minh)) *maxh = *minh; + } + } + */ if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) { evas_object_textblock_style_insets_get(ep->object, &ins_l, @@ -1703,20 +1761,19 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, temp_h = *maxh; } + eo_do(ep->object, + efl_gfx_size_set(temp_w, temp_h), + evas_obj_textblock_size_formatted_get(&tw, &th)); + + tw += ins_l + ins_r; + th += ins_t + ins_b; + /* If base width for calculation is 0, * don't get meaningless height for multiline */ - if (temp_w > 0) + if (temp_w <= 0) { eo_do(ep->object, - efl_gfx_size_set(temp_w, temp_h), - evas_obj_textblock_size_formatted_get(&tw, &th)); - - tw += ins_l + ins_r; - th += ins_t + ins_b; - } - else - { - eo_do(ep->object, evas_obj_textblock_size_native_get(NULL, &th)); + evas_obj_textblock_size_native_get(NULL, &th)); th += ins_t + ins_b; } @@ -1746,20 +1803,19 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, temp_h = *maxh; } + eo_do(ep->object, + efl_gfx_size_set(temp_w, temp_h), + evas_obj_textblock_size_formatted_get(&tw, &th)); + + tw += ins_l + ins_r; + th += ins_t + ins_b; + /* If base width for calculation is 0, * don't get meaningless height for multiline */ - if (temp_w > 0) + if (temp_w <= 0) { eo_do(ep->object, - efl_gfx_size_set(temp_w, temp_h), - evas_obj_textblock_size_formatted_get(&tw, &th)); - - tw += ins_l + ins_r; - th += ins_t + ins_b; - } - else - { - eo_do(ep->object, evas_obj_textblock_size_native_get(NULL, &th)); + evas_obj_textblock_size_native_get(NULL, &th)); th += ins_t + ins_b; } @@ -1787,153 +1843,139 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, } } - if (chosen_desc->text.min_x) - { - if (tw > min_calc_w) min_calc_w = tw; - } - if (chosen_desc->text.min_y) - { - if (th > min_calc_h) min_calc_h = th; - } - - if (minw) *minw = min_calc_w; - if (minh) *minh = min_calc_h; + if (tw > min_calc_w) min_calc_w = tw; + if (th > min_calc_h) min_calc_h = th; + if (chosen_desc->text.min_x && minw) *minw = min_calc_w; + if (chosen_desc->text.min_y && minh) *minh = min_calc_h; } - } - - if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) - { - evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, - &ins_t, &ins_b); - tw = th = 0; - if (!chosen_desc->text.max_x) + if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) { - /* text.min: X X - * text.max: 0 1 */ - int temp_w, temp_h; + evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, + &ins_t, &ins_b); - if (chosen_desc->text.min_y) - { - /* text.min: X 1 - * text.max: 0 1 - * Already calculated in text for height. */ - tw = TO_INT(params->eval.w); - if (min_calc_w > tw) - tw = min_calc_w; - - th = min_calc_h; - } - else + tw = th = 0; + if (!chosen_desc->text.max_x) { - /* text.min: X 0 + /* text.min: X X * text.max: 0 1 */ - temp_w = TO_INT(params->eval.w); - temp_h = TO_INT(params->eval.h); - - if (min_calc_w > temp_w) - temp_w = min_calc_w; - if (maxw && (*maxw > -1) && (*maxw < temp_w)) - temp_w = *maxw; - if (min_calc_h > temp_h) - temp_h = min_calc_h; + int temp_w, temp_h; - /* If base width for calculation is 0, - * don't get meaningless height for multiline */ - if (temp_w > 0) + if (chosen_desc->text.min_y) { - eo_do(ep->object, - efl_gfx_size_set(temp_w, temp_h), - evas_obj_textblock_size_formatted_get(&tw, &th)); - - tw += ins_l + ins_r; - th += ins_t + ins_b; + /* text.min: X 1 + * text.max: 0 1 + * Already calculated in text for height. */ + tw = TO_INT(params->eval.w); + if (min_calc_w > tw) + tw = min_calc_w; + + th = min_calc_h; } else { - eo_do(ep->object, evas_obj_textblock_size_native_get(NULL, &th)); - - th += ins_t + ins_b; - } - } - } - else - { - /* text.max: 1 X */ - if (chosen_desc->text.min_x) - { - /* text.min: 1 X - * text.max: 1 X - * Singleline. */ - eo_do(ep->object, evas_obj_textblock_size_native_get(&tw, &th)); - - tw += ins_l + ins_r; - th += ins_t + ins_b; - } - else - { - /* text.min: 0 X - * text.max: 1 X */ - if (chosen_desc->text.max_y) - { - /* text.min: 0 X - * text.max: 1 1 */ - int temp_w, temp_h; - + /* text.min: X 0 + * text.max: 0 1 */ temp_w = TO_INT(params->eval.w); temp_h = TO_INT(params->eval.h); if (min_calc_w > temp_w) temp_w = min_calc_w; + if (maxw && (*maxw > -1) && (*maxw < temp_w)) + temp_w = *maxw; if (min_calc_h > temp_h) temp_h = min_calc_h; - if (chosen_desc->text.min_y) + eo_do(ep->object, + efl_gfx_size_set(temp_w, temp_h), + evas_obj_textblock_size_formatted_get(&tw, &th)); + + tw += ins_l + ins_r; + th += ins_t + ins_b; + + /* If base width for calculation is 0, + * don't get meaningless height for multiline */ + if (temp_w <= 0) { - /* text.min: 0 1 - * text.max: 1 1 - * There is no need to calculate it again. */ - tw = temp_w; - th = min_calc_h; + eo_do(ep->object, + evas_obj_textblock_size_native_get(NULL, &th)); + + th += ins_t + ins_b; } - else + } + } + else + { + /* text.max: 1 X */ + if (chosen_desc->text.min_x) + { + /* text.min: 1 X + * text.max: 1 X + * Singleline. */ + eo_do(ep->object, evas_obj_textblock_size_native_get(&tw, &th)); + + tw += ins_l + ins_r; + th += ins_t + ins_b; + } + else + { + /* text.min: 0 X + * text.max: 1 X */ + if (chosen_desc->text.max_y) { - /* text.min: 0 0 + /* text.min: 0 X * text.max: 1 1 */ + int temp_w, temp_h; - /* If base width for calculation is 0, - * don't get meaningless height for multiline */ - if (temp_w > 0) + temp_w = TO_INT(params->eval.w); + temp_h = TO_INT(params->eval.h); + + if (min_calc_w > temp_w) + temp_w = min_calc_w; + if (min_calc_h > temp_h) + temp_h = min_calc_h; + + if (chosen_desc->text.min_y) + { + /* text.min: 0 1 + * text.max: 1 1 + * There is no need to calculate it again. */ + tw = min_calc_w; + th = min_calc_h; + } + else { + /* text.min: 0 0 + * text.max: 1 1 */ + eo_do(ep->object, efl_gfx_size_set(temp_w, temp_h), evas_obj_textblock_size_formatted_get(&tw, &th)); tw += ins_l + ins_r; th += ins_t + ins_b; - } - else - { - eo_do(ep->object, evas_obj_textblock_size_native_get(&tw, &th)); - th += ins_t + ins_b; + /* If base width for calculation is 0, + * don't get meaningless height for multiline */ + if (temp_w <= 0) + { + eo_do(ep->object, + evas_obj_textblock_size_native_get(NULL, &th)); + + th += ins_t + ins_b; + } } } - } - else - { - /* text.min: 0 X - * text.max: 1 0 */ - int temp_w, temp_h; + else + { + /* text.min: 0 X + * text.max: 1 0 */ + int temp_w, temp_h; - temp_w = TO_INT(params->eval.w); - if (min_calc_w > temp_w) - temp_w = min_calc_w; + temp_w = TO_INT(params->eval.w); + if (min_calc_w > temp_w) + temp_w = min_calc_w; - /* If base width for calculation is 0, - * don't get meaningless height for multiline */ - if (temp_w > 0) - { eo_do(ep->object, efl_gfx_size_get(NULL, &temp_h), efl_gfx_size_set(temp_w, temp_h), @@ -1941,21 +1983,32 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, tw += ins_l + ins_r; th += ins_t + ins_b; + + /* If base width for calculation is 0, + * don't get meaningless height for multiline */ + if (temp_w <= 0) + { + eo_do(ep->object, + evas_obj_textblock_size_native_get(NULL, &th)); + + th += ins_t + ins_b; + } } } } - } - if (maxw && chosen_desc->text.max_x) - { - if (tw > *maxw) *maxw = tw; - if (minw && (*maxw < *minw)) *maxw = *minw; - } - if (maxh && chosen_desc->text.max_y) - { - if (th > *maxh) *maxh = th; - if (minh && (*maxh < *minh)) *maxh = *minh; + if (maxw && chosen_desc->text.max_x) + { + if (tw > *maxw) *maxw = tw; + if (minw && (*maxw < *minw)) *maxw = *minw; + } + if (maxh && chosen_desc->text.max_y) + { + if (th > *maxh) *maxh = th; + if (minh && (*maxh < *minh)) *maxh = *minh; + } } } + /* END */ evas_object_textblock_valign_set(ep->object, TO_DOUBLE(chosen_desc->text.align.y)); } diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 430847a..68782f7 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -4073,6 +4073,52 @@ again: int over_w = (ep->w - ep->req.w); int over_h = (ep->h - ep->req.h); + /* TIZEN_ONLY(20160901): Edje calc: Fix textblock size calculation logic + Eina_Bool skip_h = EINA_FALSE; + + //width + if (!ep->chosen_description->fixed.w) + { + //We care textblock width size specially. + if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Evas_Coord tb_mw; + evas_object_textblock_size_formatted_get(ep->object, + &tb_mw, NULL); + evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, NULL, NULL); + tb_mw = ins_l + tb_mw + ins_r; + tb_mw -= ep->req.w; + if (tb_mw > over_w) over_w = tb_mw; + has_fixed_tb = EINA_FALSE; + } + + if (over_w > max_over_w) + { + max_over_w = over_w; + repeat_w = EINA_TRUE; + pep = ep; + skip_h = EINA_TRUE; + } + } + //height + if (!ep->chosen_description->fixed.h) + { + if ((ep->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + ((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x || + !skip_h) + { + if (over_h > max_over_h) + { + max_over_h = over_h; + repeat_h = EINA_TRUE; + pep = ep; + } + } + + if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) + has_fixed_tb = EINA_FALSE; + } + */ //width if ((!ep->chosen_description->fixed.w) && (over_w > max_over_w)) @@ -4089,6 +4135,7 @@ again: repeat_h = EINA_TRUE; pep = ep; } + /* END */ } if (repeat_w) { @@ -4112,6 +4159,20 @@ again: ((ed->w > MIN_LIMIT) || (ed->h > MIN_LIMIT))) /* END */ { + /* Only print it if we have a non-fixed textblock. + * We should possibly avoid all of this if in this case, but in + * the meanwhile, just doing this. */ + /* TIZEN_ONLY(20160901): Edje calc: Fix textblock size calculation logic + if (!has_fixed_tb) + { + if (pep) + ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.", + ed->path, ed->group, pep->part->name); + else + ERR("file %s, group %s runs infinite minimum calculation loops.Continuing discarding faulty parts.", + ed->path, ed->group); + } + */ /* We should possibly avoid all of this if in this case, but in * the meanwhile, just doing this. */ if (pep) @@ -4121,6 +4182,7 @@ again: ERR("file %s, group %s overflowed %dx%d with minimum size of %dx%d. Continuing discarding faulty parts.", ed->path, ed->group, MIN_LIMIT, MIN_LIMIT, ed->w, ed->h); + /* END */ reset_max = EINA_FALSE; goto again; -- 2.7.4