From: Youngbok Shin Date: Tue, 16 Feb 2016 15:14:38 +0000 (+0200) Subject: Evas Text: Update text layout when ellipsis is changed without resize X-Git-Tag: upstream/1.20.0~7440 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=471c7635eed67509a24fc6dcc04de65622568f4c;p=platform%2Fupstream%2Fefl.git Evas Text: Update text layout when ellipsis is changed without resize Summary: When only ellipsis is changed from 0.0~1.0 to -1.0 without resize, the text is never updated. Because, previous state for ellipsis is never kept and used properly to check when Evas Text needs to be updated. It does not have any effect when ellipsis is changed from -1.0 to 0.0~1.0. Because, Evas text always resize itself according to its text size. So, necessarily, Evas text object has to be resized to the smaller size. Commonly, Edje will handle its size if Evas text needs to be ellipsized. @fix Test Plan: Test case is included. Reviewers: tasn, woohyun, herdsman Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3448 --- diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 91fcfa1..d6d3ee5 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -995,6 +995,7 @@ _evas_text_ellipsis_set(Eo *eo_obj, Evas_Text_Data *o, double ellipsis) if (o->cur.ellipsis == ellipsis) return; evas_object_async_block(obj); + o->prev.ellipsis = o->cur.ellipsis; o->cur.ellipsis = ellipsis; o->changed = 1; if (o->has_filter) @@ -1596,7 +1597,7 @@ evas_object_text_init(Evas_Object *eo_obj) Evas_Text_Data *o = obj->private_data; /* alloc obj private data */ - o->cur.ellipsis = -1.0; + o->prev.ellipsis = o->cur.ellipsis = -1.0; o->prev = o->cur; #ifdef BIDI_SUPPORT o->bidi_par_props = evas_bidi_paragraph_props_new(); @@ -2019,10 +2020,10 @@ evas_object_text_render_pre(Evas_Object *eo_obj, #endif /* If object size changed and ellipsis is set */ - if (((o->cur.ellipsis >= 0.0 || - o->cur.ellipsis != o->prev.ellipsis) && + if (((o->cur.ellipsis >= 0.0) && ((obj->cur->geometry.w != o->last_computed.w) || (obj->cur->geometry.h != o->last_computed.h))) || + (o->cur.ellipsis != o->prev.ellipsis) || (obj->cur->scale != obj->prev->scale) || (o->changed_paragraph_direction)) { diff --git a/src/tests/evas/evas_test_text.c b/src/tests/evas/evas_test_text.c index 746fbee..a7c3242 100644 --- a/src/tests/evas/evas_test_text.c +++ b/src/tests/evas/evas_test_text.c @@ -6,6 +6,7 @@ #include #include +#include #include "evas_suite.h" #include "evas_tests_helpers.h" @@ -624,6 +625,34 @@ START_TEST(evas_text_bidi) END_TEST #endif +START_TEST(evas_text_render) +{ + Ecore_Evas *ee = ecore_evas_buffer_new(500, 500); + Evas *evas = ecore_evas_get(ee); + Evas_Object *to; + const char *font = TEST_FONT_NAME; + Evas_Font_Size size = 14; + int w; + + evas_font_hinting_set(evas, EVAS_FONT_HINTING_AUTO); + to = evas_object_text_add(evas); + evas_object_text_font_source_set(to, TEST_FONT_SOURCE); + evas_object_show(to); + + /* Check the changing ellipsis is updated properly. */ + evas_object_text_font_set(to, font, size); + evas_object_text_text_set(to, "Dynamically changing ellipsis!"); + evas_object_text_ellipsis_set(to, 0.0); + evas_object_resize(to, 50, 100); + w = evas_object_text_horiz_advance_get(to); + evas_object_text_ellipsis_set(to, -1.0); + evas_render(evas); + ck_assert_int_gt(evas_object_text_horiz_advance_get(to), w); + + ecore_evas_free(ee); +} +END_TEST + void evas_test_text(TCase *tc) { tcase_add_test(tc, evas_text_simple); @@ -637,4 +666,5 @@ void evas_test_text(TCase *tc) #endif tcase_add_test(tc, evas_text_unrelated); + tcase_add_test(tc, evas_text_render); }