aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
parent8a818ad79d8d728764946f6088beecdb5295366b (diff)
downloadefl-d6dababe7815c2abdc62e5cfcb498c9da045dc97.tar.gz
efl-d6dababe7815c2abdc62e5cfcb498c9da045dc97.tar.xz
efl-d6dababe7815c2abdc62e5cfcb498c9da045dc97.zip
Evas text: Fixed bug with the text object direction detection.
Diffstat (limited to 'src')
-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
3 files changed, 47 insertions, 5 deletions
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