Evas Text: Update text layout when ellipsis is changed without resize 75/59675/1
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 16 Feb 2016 15:14:38 +0000 (17:14 +0200)
committerYoungbok Shin <youngb.shin@samsung.com>
Wed, 17 Feb 2016 08:55:37 +0000 (17:55 +0900)
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

Conflicts:
src/tests/evas/evas_test_text.c

Change-Id: Id5c484152efbe0a4df723c4422127e46ad5213be

src/lib/evas/canvas/evas_object_text.c
src/tests/evas/evas_test_text.c

index 6fe711a..d92042a 100644 (file)
@@ -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();
@@ -2015,10 +2016,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))
      {
index fe5644a..d41cba8 100644 (file)
@@ -5,6 +5,8 @@
 
 #include <stdio.h>
 
+#include <Ecore_Evas.h>
+
 #include "evas_suite.h"
 #include "Evas.h"
 #include "evas_tests_helpers.h"
@@ -623,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);
@@ -636,4 +666,5 @@ void evas_test_text(TCase *tc)
 #endif
 
    tcase_add_test(tc, evas_text_unrelated);
+   tcase_add_test(tc, evas_text_render);
 }