aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 1ae0ace28..a1ad0c58c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-21 Tom Hacohen (TAsn)
+
+ * Evas text: Fixed bug with the text object direction detection.
+
+ size_range.
2013-02-21 Carsten Haitzler (The Rasterman)
* Add ecore_x_dnd_self_begin() and ecore_x_dnd_self_drop() to
diff --git a/NEWS b/NEWS
index 67913fbfa..a9bf4ed1d 100644
--- a/NEWS
+++ b/NEWS
@@ -177,4 +177,5 @@ Fixes:
* Evas: Fix Evas_Object_Text when LTR and RTL are used in the same paragraph.
* Properly report file not found in Edje.
* Fix ecore-x edid fetch to ftech 128, not 100 bytes.
+ * Evas text: Fixed bug with the text object direction detection.
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 4e619205d..98b3ac46d 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
Evas_Object_Text_Item *ellipsis_end;
} last_computed;
+ Evas_BiDi_Direction bidi_dir : 2;
char changed : 1;
};
@@ -700,11 +701,20 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, Eina_Unicode
if (o->items) _evas_object_text_items_clean(obj, o);
+ if (text && *text)
+ o->bidi_dir = EVAS_BIDI_DIRECTION_LTR;
+ else
+ o->bidi_dir = EVAS_BIDI_DIRECTION_NEUTRAL;
+
#ifdef BIDI_SUPPORT
if (o->bidi_delimiters)
segment_idxs = evas_bidi_segment_idxs_get(text, o->bidi_delimiters);
evas_bidi_paragraph_props_unref(o->bidi_par_props);
o->bidi_par_props = evas_bidi_paragraph_props_get(text, len, segment_idxs);
+
+ if (o->bidi_par_props)
+ o->bidi_dir = EVAS_BIDI_PAR_TYPE_TO_DIRECTION(o->bidi_par_props->direction);
+
evas_bidi_props_reorder_line(NULL, 0, len, o->bidi_par_props, &v_to_l);
if (segment_idxs) free(segment_idxs);
#endif
@@ -1098,7 +1108,7 @@ _text_direction_get(Eo *eo_obj EINA_UNUSED, void *_pd, va_list *list)
{
Evas_BiDi_Direction *bidi_dir = va_arg(*list, Evas_BiDi_Direction *);
const Evas_Object_Text *o = _pd;
- *bidi_dir = o->items ? o->items->text_props.bidi_dir : EVAS_BIDI_DIRECTION_NEUTRAL;
+ *bidi_dir = o->bidi_dir;
}
EAPI 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 ff2f41a64..37a4e6596 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
#define EVAS_BIDI_PARAGRAPH_WLTR FRIBIDI_PAR_WLTR
#define EVAS_BIDI_PARAGRAPH_WRTL FRIBIDI_PAR_WRTL
-#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \
- (((x) && \
- ((x->direction == EVAS_BIDI_PARAGRAPH_RTL) || \
- (x->direction == EVAS_BIDI_PARAGRAPH_WRTL))) ? \
+#define EVAS_BIDI_DIRECTION_IS_RTL(x) \
+ ((((x) == EVAS_BIDI_PARAGRAPH_RTL) || \
+ ((x) == EVAS_BIDI_PARAGRAPH_WRTL)) ? \
EINA_TRUE : EINA_FALSE)
+#define EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(x) \
+ ((x) && EVAS_BIDI_DIRECTION_IS_RTL((x)->direction))
+
+#define EVAS_BIDI_PAR_TYPE_TO_DIRECTION(x) \
+ _evas_bidi_par_type_to_direction(x)
+
+static inline Evas_BiDi_Direction
+_evas_bidi_par_type_to_direction(EvasBiDiParType par_type)
+{
+ switch (par_type)
+ {
+ case EVAS_BIDI_PARAGRAPH_LTR:
+ case EVAS_BIDI_PARAGRAPH_WLTR:
+ return EVAS_BIDI_DIRECTION_LTR;
+ break;
+ case EVAS_BIDI_PARAGRAPH_RTL:
+ case EVAS_BIDI_PARAGRAPH_WRTL:
+ return EVAS_BIDI_DIRECTION_RTL;
+ break;
+ case EVAS_BIDI_PARAGRAPH_NEUTRAL:
+ default:
+ return EVAS_BIDI_DIRECTION_NEUTRAL;
+ break;
+ }
+}
# define evas_bidi_position_visual_to_logical(list, position) \
(list) ? list[position] : position;
diff --git a/src/tests/evas/evas_test_text.c b/src/tests/evas/evas_test_text.c
index 2d1b46bed..b94ff256e 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)
evas_object_text_text_set(to, "");
fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_NEUTRAL);
+ /* LTR paragraphs */
+ evas_object_text_text_set(to, "Test נסיון");
+ fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_LTR);
+
+ /* RTL paragraphs */
+ evas_object_text_text_set(to, "נסיון test");
+ fail_if(evas_object_text_direction_get(to) != EVAS_BIDI_DIRECTION_RTL);
+
END_TEXT_TEST();
}
END_TEST