summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2017-10-15 00:29:36 +0300
committerCedric BAIL <cedric@osg.samsung.com>2017-11-10 10:29:49 -0800
commit45d3614345dfd832a6332975960b75b51fb0afd1 (patch)
treec9d69f85e81c5a5bef7dfdca2a8f42ec0761b243 /src
parent0725ff620b77dd004cba856fc794af868c24203f (diff)
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 <cedric@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c14
-rw-r--r--src/tests/evas/evas_test_textblock.c19
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,
4082 Evas_Object_Protected_Data *obj = c->evas_o; 4082 Evas_Object_Protected_Data *obj = c->evas_o;
4083 4083
4084 x = w - c->o->style_pad.l - c->o->style_pad.r - c->marginl - 4084 x = w - c->o->style_pad.l - c->o->style_pad.r - c->marginl -
4085 c->marginr - from_x - ti->x_adjustment; 4085 c->marginr - from_x;
4086
4086 if (x < 0) 4087 if (x < 0)
4087 x = 0; 4088 x = 0;
4088 return ENFN->font_last_up_to_pos(ENC, fmt->font.font, 4089 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)
5269 5270
5270 save_cx = c->x; 5271 save_cx = c->x;
5271 temp_w = c->w; 5272 temp_w = c->w;
5272 ellip_w = ellip_ti->parent.w; 5273 ellip_w = ellip_ti->parent.w - ellip_ti->x_adjustment;
5273#ifdef BIDI_SUPPORT 5274#ifdef BIDI_SUPPORT
5274 // XXX: with RTL considerations in mind, we need to take max(adv, w) as the 5275 // XXX: with RTL considerations in mind, we need to take max(adv, w) as the
5275 // line may be reordered in a way that the item placement will cause the 5276 // line may be reordered in a way that the item placement will cause the
@@ -5669,6 +5670,7 @@ _layout_par(Ctxt *c)
5669 int adv_line = 0; 5670 int adv_line = 0;
5670 int redo_item = 0; 5671 int redo_item = 0;
5671 Evas_Textblock_Obstacle_Info *obs_info = NULL; 5672 Evas_Textblock_Obstacle_Info *obs_info = NULL;
5673 Evas_Coord itw;
5672 5674
5673 it = _ITEM(eina_list_data_get(i)); 5675 it = _ITEM(eina_list_data_get(i));
5674 /* Skip visually deleted items */ 5676 /* Skip visually deleted items */
@@ -5714,9 +5716,15 @@ _layout_par(Ctxt *c)
5714 } 5716 }
5715 /* Check if we need to wrap, i.e the text is bigger than the width, 5717 /* Check if we need to wrap, i.e the text is bigger than the width,
5716 or we already found a wrap point. */ 5718 or we already found a wrap point. */
5719 itw = it->w;
5720 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
5721 {
5722 itw -= _ITEM_TEXT(it)->x_adjustment;
5723 }
5724
5717 if ((c->w >= 0) && 5725 if ((c->w >= 0) &&
5718 (obs || 5726 (obs ||
5719 (((c->x + it->w) > 5727 (((c->x + itw) >
5720 (c->w - c->o->style_pad.l - c->o->style_pad.r - 5728 (c->w - c->o->style_pad.l - c->o->style_pad.r -
5721 c->marginl - c->marginr)) || (wrap > 0)))) 5729 c->marginl - c->marginr)) || (wrap > 0))))
5722 { 5730 {
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)
3559{ 3559{
3560 Evas_Coord w, h, nw, nh; 3560 Evas_Coord w, h, nw, nh;
3561 Evas_Coord l, r, t, b; 3561 Evas_Coord l, r, t, b;
3562 Evas_Coord bw;
3562 START_TB_TEST(); 3563 START_TB_TEST();
3563 Evas_Textblock_Style *newst; 3564 Evas_Textblock_Style *newst;
3564 const char *buf = "Test<ps/>Test2<ps/>נסיון"; 3565 const char *buf = "Test<ps/>Test2<ps/>נסיון";
@@ -3683,6 +3684,24 @@ START_TEST(evas_textblock_style)
3683 evas_object_textblock_size_formatted_get(tb, &nw, &nh); 3684 evas_object_textblock_size_formatted_get(tb, &nw, &nh);
3684 ck_assert_int_eq(w, nw); 3685 ck_assert_int_eq(w, nw);
3685 ck_assert_int_eq(h, nh); 3686 ck_assert_int_eq(h, nh);
3687
3688 // Ellipsis style padding
3689 // Should be consistent if style_pad is added
3690 evas_object_textblock_text_markup_set(tb, "hello");
3691 evas_object_textblock_size_native_get(tb, &w, &h);
3692 evas_object_resize(tb, w - 1, 200);
3693 evas_object_textblock_text_markup_set(tb,
3694 "<ellipsis=1.0>hello");
3695 evas_object_textblock_size_formatted_get(tb, &bw, NULL);
3696 evas_object_textblock_text_markup_set(tb,
3697 "<ellipsis=1.0 style=glow>hello</style>");
3698 evas_object_textblock_style_insets_get(tb, &l, &r, NULL, NULL);
3699 // Add padding to compensate for the style
3700 evas_object_resize(tb, w - 1 + l + r, 200);
3701 evas_object_textblock_size_formatted_get(tb, &nw, &nh);
3702 ck_assert_int_eq(nw, bw);
3703
3704
3686 END_TB_TEST(); 3705 END_TB_TEST();
3687} 3706}
3688END_TEST 3707END_TEST