summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-12-13 06:50:08 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-12-13 06:50:08 +0000
commit5828c041236cd0e8f4d40d8dd08f4e76edb8fd3c (patch)
tree4b45584a70598c189f8048d9613d99bcb66f3fa0
parent6e7e05a008fffdb927bf73a81c14512b10aca10d (diff)
evas: preserve ellipsis.
SVN revision: 80797
-rw-r--r--src/lib/evas/canvas/evas_object_text.c75
1 files changed, 72 insertions, 3 deletions
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index c311dc2f31..5fbf9ee8ad 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -46,6 +46,8 @@ struct _Evas_Object_Text
46 46
47 struct { 47 struct {
48 Evas_Coord w, h; 48 Evas_Coord w, h;
49 Evas_Object_Text_Item *ellipsis_start;
50 Evas_Object_Text_Item *ellipsis_end;
49 } last_computed; 51 } last_computed;
50 52
51 char changed : 1; 53 char changed : 1;
@@ -147,8 +149,55 @@ _evas_object_text_item_del(Evas_Object_Text *o, Evas_Object_Text_Item *it)
147} 149}
148 150
149static void 151static void
152_evas_object_text_items_clean(Evas_Object_Text *o)
153{
154 /* FIXME: also preserve item */
155 if (o->cur.font == o->prev.font &&
156 o->cur.fdesc == o->prev.fdesc &&
157 o->cur.size == o->prev.size &&
158 !memcmp(&o->cur.outline, &o->prev.outline, sizeof (o->cur.outline)) &&
159 !memcmp(&o->cur.shadow, &o->prev.shadow, sizeof (o->cur.shadow)) &&
160 !memcmp(&o->cur.glow, &o->prev.glow, sizeof (o->cur.glow)) &&
161 !memcmp(&o->cur.glow2, &o->prev.glow2, sizeof (o->cur.glow2)) &&
162 o->cur.style == o->prev.style)
163 {
164 if (o->last_computed.ellipsis_start &&
165 o->last_computed.ellipsis_start == o->items)
166 o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items),
167 EINA_INLIST_GET(o->items));
168 if (o->last_computed.ellipsis_end &&
169 EINA_INLIST_GET(o->last_computed.ellipsis_end) == EINA_INLIST_GET(o->items)->last)
170 o->items = (Evas_Object_Text_Item *) eina_inlist_remove(EINA_INLIST_GET(o->items),
171 EINA_INLIST_GET(o->items)->last);
172 }
173 else
174 {
175 o->last_computed.ellipsis_start = NULL;
176 o->last_computed.ellipsis_end = NULL;
177 }
178 while (o->items)
179 {
180 _evas_object_text_item_del(o, o->items);
181 }
182}
183
184static void
150_evas_object_text_items_clear(Evas_Object_Text *o) 185_evas_object_text_items_clear(Evas_Object_Text *o)
151{ 186{
187 if (o->last_computed.ellipsis_start &&
188 o->last_computed.ellipsis_start != o->items)
189 {
190 _evas_object_text_item_clean(o->last_computed.ellipsis_start);
191 free(o->last_computed.ellipsis_start);
192 }
193 o->last_computed.ellipsis_start = NULL;
194 if (o->last_computed.ellipsis_end &&
195 EINA_INLIST_GET(o->last_computed.ellipsis_end) != EINA_INLIST_GET(o->items)->last)
196 {
197 _evas_object_text_item_clean(o->last_computed.ellipsis_end);
198 free(o->last_computed.ellipsis_end);
199 }
200 o->last_computed.ellipsis_end = NULL;
152 while (o->items) 201 while (o->items)
153 { 202 {
154 _evas_object_text_item_del(o, o->items); 203 _evas_object_text_item_del(o, o->items);
@@ -693,13 +742,33 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, const Eina_Un
693 * we have a left ellipsis. And the same with 1 and right. */ 742 * we have a left ellipsis. And the same with 1 and right. */
694 if (o->cur.ellipsis != 0) 743 if (o->cur.ellipsis != 0)
695 { 744 {
696 start_ellip_it = _layout_ellipsis_item_new(obj, o, o->items); 745 if (o->last_computed.ellipsis_start)
746 {
747 start_ellip_it = o->last_computed.ellipsis_start;
748 o->items = (Evas_Object_Text_Item *)
749 eina_inlist_append(EINA_INLIST_GET(o->items), EINA_INLIST_GET(start_ellip_it));
750 }
751 else
752 {
753 start_ellip_it = _layout_ellipsis_item_new(obj, o, o->items);
754 }
755 o->last_computed.ellipsis_start = start_ellip_it;
697 ellip_frame -= start_ellip_it->adv; 756 ellip_frame -= start_ellip_it->adv;
698 } 757 }
699 if (o->cur.ellipsis != 1) 758 if (o->cur.ellipsis != 1)
700 { 759 {
701 /* FIXME: Should take the last item's font and style and etc. *//* weird it's a text, should always have the same style/font */ 760 /* FIXME: Should take the last item's font and style and etc. *//* weird it's a text, should always have the same style/font */
702 end_ellip_it = _layout_ellipsis_item_new(obj, o, o->items); 761 if (o->last_computed.ellipsis_end)
762 {
763 end_ellip_it = o->last_computed.ellipsis_end;
764 o->items = (Evas_Object_Text_Item *)
765 eina_inlist_append(EINA_INLIST_GET(o->items), EINA_INLIST_GET(end_ellip_it));
766 }
767 else
768 {
769 end_ellip_it = _layout_ellipsis_item_new(obj, o, o->items);
770 }
771 o->last_computed.ellipsis_end = end_ellip_it;
703 ellip_frame -= end_ellip_it->adv; 772 ellip_frame -= end_ellip_it->adv;
704 } 773 }
705 774
@@ -2297,7 +2366,7 @@ _evas_object_text_recalc(Evas_Object *eo_obj)
2297 Evas_Object_Text *o = eo_data_get(eo_obj, MY_CLASS); 2366 Evas_Object_Text *o = eo_data_get(eo_obj, MY_CLASS);
2298 Eina_Unicode *text = NULL; 2367 Eina_Unicode *text = NULL;
2299 2368
2300 if (o->items) _evas_object_text_items_clear(o); 2369 if (o->items) _evas_object_text_items_clean(o);
2301 if (o->cur.utf8_text) 2370 if (o->cur.utf8_text)
2302 text = eina_unicode_utf8_to_unicode(o->cur.utf8_text, 2371 text = eina_unicode_utf8_to_unicode(o->cur.utf8_text,
2303 NULL); 2372 NULL);