cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=45d3614345dfd832a6332975960b75b51fb0afd1

commit 45d3614345dfd832a6332975960b75b51fb0afd1
Author: Daniel Hirt <[email protected]>
Date:   Sun Oct 15 00:29:36 2017 +0300

    Canvas text: fix width calculation with style effects
    
    There are multiple places in the code where both the padded item's
    width and the maximum style padding (at the edges) are accounted for.
    For the sake of making calculations for wrapping/ellipsis we should
    only use the maximum style padding.
    
    Signed-off-by: Cedric BAIL <[email protected]>
---
 src/lib/evas/canvas/evas_object_textblock.c | 14 +++++++++++---
 src/tests/evas/evas_test_textblock.c        | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index b62b5cc80b..2fcd00b857 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -4082,7 +4082,8 @@ _layout_text_cutoff_get(Ctxt *c, 
Evas_Object_Textblock_Format *fmt,
         Evas_Object_Protected_Data *obj = c->evas_o;
 
         x = w - c->o->style_pad.l - c->o->style_pad.r - c->marginl -
-           c->marginr - from_x - ti->x_adjustment;
+           c->marginr - from_x;
+
         if (x < 0)
           x = 0;
         return ENFN->font_last_up_to_pos(ENC, fmt->font.font,
@@ -5269,7 +5270,7 @@ _layout_handle_ellipsis(Ctxt *c, 
Evas_Object_Textblock_Item *it, Eina_List *i)
 
    save_cx = c->x;
    temp_w = c->w;
-   ellip_w = ellip_ti->parent.w;
+   ellip_w = ellip_ti->parent.w - ellip_ti->x_adjustment;
 #ifdef BIDI_SUPPORT
    // XXX: with RTL considerations in mind, we need to take max(adv, w) as the
    // line may be reordered in a way that the item placement will cause the
@@ -5669,6 +5670,7 @@ _layout_par(Ctxt *c)
         int adv_line = 0;
         int redo_item = 0;
         Evas_Textblock_Obstacle_Info *obs_info = NULL;
+        Evas_Coord itw;
 
         it = _ITEM(eina_list_data_get(i));
         /* Skip visually deleted items */
@@ -5714,9 +5716,15 @@ _layout_par(Ctxt *c)
           }
         /* Check if we need to wrap, i.e the text is bigger than the width,
            or we already found a wrap point. */
+        itw = it->w;
+        if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
+          {
+             itw -= _ITEM_TEXT(it)->x_adjustment;
+          }
+
         if ((c->w >= 0) &&
               (obs ||
-                 (((c->x + it->w) >
+                 (((c->x + itw) >
                    (c->w - c->o->style_pad.l - c->o->style_pad.r -
                     c->marginl - c->marginr)) || (wrap > 0))))
           {
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index 24f0d27135..e77b066a93 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -3559,6 +3559,7 @@ START_TEST(evas_textblock_style)
 {
    Evas_Coord w, h, nw, nh;
    Evas_Coord l, r, t, b;
+   Evas_Coord bw;
    START_TB_TEST();
    Evas_Textblock_Style *newst;
    const char *buf = "Test<ps/>Test2<ps/>נסיון";
@@ -3683,6 +3684,24 @@ START_TEST(evas_textblock_style)
    evas_object_textblock_size_formatted_get(tb, &nw, &nh);
    ck_assert_int_eq(w, nw);
    ck_assert_int_eq(h, nh);
+
+   // Ellipsis style padding
+   // Should be consistent if style_pad is added
+   evas_object_textblock_text_markup_set(tb, "hello");
+   evas_object_textblock_size_native_get(tb, &w, &h);
+   evas_object_resize(tb, w - 1, 200);
+   evas_object_textblock_text_markup_set(tb,
+         "<ellipsis=1.0>hello");
+   evas_object_textblock_size_formatted_get(tb, &bw, NULL);
+   evas_object_textblock_text_markup_set(tb,
+         "<ellipsis=1.0 style=glow>hello</style>");
+   evas_object_textblock_style_insets_get(tb, &l, &r, NULL, NULL);
+   // Add padding to compensate for the style
+   evas_object_resize(tb, w - 1 + l + r, 200);
+   evas_object_textblock_size_formatted_get(tb, &nw, &nh);
+   ck_assert_int_eq(nw, bw);
+
+
    END_TB_TEST();
 }
 END_TEST

-- 


Reply via email to