summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-02-21 13:39:37 +0000
committerTom Hacohen <tom@stosb.com>2013-02-21 13:39:37 +0000
commitd6dababe7815c2abdc62e5cfcb498c9da045dc97 (patch)
tree8dab8aeffac3ba58c44583df706b35f1e6f8f318
parent8a818ad79d8d728764946f6088beecdb5295366b (diff)
Evas text: Fixed bug with the text object direction detection.
-rw-r--r--ChangeLog5
-rw-r--r--NEWS1
-rw-r--r--src/lib/evas/canvas/evas_object_text.c12
-rw-r--r--src/lib/evas/common/language/evas_bidi_utils.h32
-rw-r--r--src/tests/evas/evas_test_text.c8
5 files changed, 53 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1ae0ace285..a1ad0c58c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
12013-02-21 Tom Hacohen (TAsn)
2
3 * Evas text: Fixed bug with the text object direction detection.
4
5 size_range.
12013-02-21 Carsten Haitzler (The Rasterman) 62013-02-21 Carsten Haitzler (The Rasterman)
2 7
3 * Add ecore_x_dnd_self_begin() and ecore_x_dnd_self_drop() to 8 * Add ecore_x_dnd_self_begin() and ecore_x_dnd_self_drop() to
diff --git a/NEWS b/NEWS
index 67913fbfa1..a9bf4ed1d4 100644
--- a/NEWS
+++ b/NEWS
@@ -177,4 +177,5 @@ Fixes:
177 * Evas: Fix Evas_Object_Text when LTR and RTL are used in the same paragraph. 177 * Evas: Fix Evas_Object_Text when LTR and RTL are used in the same paragraph.
178 * Properly report file not found in Edje. 178 * Properly report file not found in Edje.
179 * Fix ecore-x edid fetch to ftech 128, not 100 bytes. 179 * Fix ecore-x edid fetch to ftech 128, not 100 bytes.
180 * Evas text: Fixed bug with the text object direction detection.
180 181
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 4e619205d5..98b3ac46d6 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -53,6 +53,7 @@ struct _Evas_Object_Text
53 Evas_Object_Text_Item *ellipsis_end; 53 Evas_Object_Text_Item *ellipsis_end;
54 } last_computed; 54 } last_computed;
55 55
56 Evas_BiDi_Direction bidi_dir : 2;
56 char changed : 1; 57 char changed : 1;
57}; 58};
58 59
@@ -700,11 +701,20 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, Eina_Unicode
700 701
701 if (o->items) _evas_object_text_items_clean(obj, o); 702 if (o->items) _evas_object_text_items_clean(obj, o);
702 703
704 if (text && *text)
705 o->bidi_dir = EVAS_BIDI_DIRECTION_LTR;
706 else
707 o->bidi_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
708
703#ifdef BIDI_SUPPORT 709#ifdef BIDI_SUPPORT
704 if (o->bidi_delimiters) 710 if (o->bidi_delimiters)
705 segment_idxs = evas_bidi_segment_idxs_get(text, o->bidi_delimiters); 711 segment_idxs = evas_bidi_segment_idxs_get(text, o->bidi_delimiters);
706 evas_bidi_paragraph_props_unref(o->bidi_par_props); 712 evas_bidi_paragraph_props_unref(o->bidi_par_props);
707 o->bidi_par_props = evas_bidi_paragraph_props_get(text, len, segment_idxs); 713 o->bidi_par_props = evas_bidi_paragraph_props_get(text, len, segment_idxs);
714
715 if (o->bidi_par_props)
716 o->bidi_dir = EVAS_BIDI_PAR_TYPE_TO_DIRECTION(o->bidi_par_props->direction);
717
708 evas_bidi_props_reorder_line(NULL, 0, len, o->bidi_par_props, &v_to_l); 718 evas_bidi_props_reorder_line(NULL, 0, len, o->bidi_par_props, &v_to_l);
709 if (segment_idxs) free(segment_idxs); 719 if (segment_idxs) free(segment_idxs);
710#endif 720#endif
@@ -1098,7 +1108,7 @@ _text_direction_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
1098{ 1108{
1099 Evas_BiDi_Direction *bidi_dir = va_arg(*list, Evas_BiDi_Direction *); 1109 Evas_BiDi_Direction *bidi_dir = va_arg(*list, Evas_BiDi_Direction *);
1100 const Evas_Object_Text *o = _pd; 1110 const Evas_Object_Text *o = _pd;
1101 *bidi_dir = o->items ? o->items->text_props.bidi_dir : EVAS_BIDI_DIRECTION_NEUTRAL; 1111 *bidi_dir = o->bidi_dir;
1102} 1112}
1103 1113
1104EAPI Evas_Coord 1114EAPI Evas_Coord
diff --git a/src/lib/evas/common/language/evas_bidi_utils.h b/src/lib/evas/common/language/evas_bidi_utils.h
index ff2f41a641..37a4e65964 100644
--- a/src/lib/evas/common/language/evas_bidi_utils.h
+++ b/src/lib/evas/common/language/evas_bidi_utils.h
@@ -90,12 +90,36 @@ struct _Evas_BiDi_Props
90#define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR 90#define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR
91#define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL 91#define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL
92 92
93#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \ 93#define EVAS_BIDI_DIRECTION_IS_RTL(x) \
94 (((x) && \ 94 ((((x) == EVAS_BIDI_PARAGRAPH_RTL) || \
95 ((x->direction == EVAS_BIDI_PARAGRAPH_RTL) || \ 95 ((x) == EVAS_BIDI_PARAGRAPH_WRTL)) ? \
96 (x->direction == EVAS_BIDI_PARAGRAPH_WRTL))) ? \
97 EINA_TRUE : EINA_FALSE) 96 EINA_TRUE : EINA_FALSE)
98 97
98#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \
99 ((x) && EVAS_BIDI_DIRECTION_IS_RTL((x)->direction))
100
101#define EVAS_BIDI_PAR_TYPE_TO_DIRECTION(x) \
102 _evas_bidi_par_type_to_direction(x)
103
104static inline Evas_BiDi_Direction
105_evas_bidi_par_type_to_direction(EvasBiDiParType par_type)
106{
107 switch (par_type)
108 {
109 case EVAS_BIDI_PARAGRAPH_LTR:
110 case EVAS_BIDI_PARAGRAPH_WLTR:
111 return EVAS_BIDI_DIRECTION_LTR;
112 break;
113 case EVAS_BIDI_PARAGRAPH_RTL:
114 case EVAS_BIDI_PARAGRAPH_WRTL:
115 return EVAS_BIDI_DIRECTION_RTL;
116 break;
117 case EVAS_BIDI_PARAGRAPH_NEUTRAL:
118 default:
119 return EVAS_BIDI_DIRECTION_NEUTRAL;
120 break;
121 }
122}
99 123
100# define evas_bidi_position_visual_to_logical(list, position) \ 124# define evas_bidi_position_visual_to_logical(list, position) \
101 (list) ? list[position] : position; 125 (list) ? list[position] : position;
diff --git a/src/tests/evas/evas_test_text.c b/src/tests/evas/evas_test_text.c
index 2d1b46bedc..b94ff256e7 100644
--- a/src/tests/evas/evas_test_text.c
+++ b/src/tests/evas/evas_test_text.c
@@ -280,6 +280,14 @@ START_TEST(evas_text_set_get)
280 evas_object_text_text_set(to, ""); 280 evas_object_text_text_set(to, "");
281 fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_NEUTRAL); 281 fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_NEUTRAL);
282 282
283 /* LTR paragraphs */
284 evas_object_text_text_set(to, "Test נסיון");
285 fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_LTR);
286
287 /* RTL paragraphs */
288 evas_object_text_text_set(to, "נסיון test");
289 fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_RTL);
290
283 END_TEXT_TEST(); 291 END_TEXT_TEST();
284} 292}
285END_TEST 293END_TEST