Evas bidi: Fixed the BiDi functions to accept paragraph props and not bidi props.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:35:04 +0000 (10:35 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 30 Jan 2011 10:35:04 +0000 (10:35 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@56441 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_text.c
src/lib/canvas/evas_object_textblock.c
src/lib/engines/common/evas_bidi_utils.c
src/lib/engines/common/evas_bidi_utils.h
src/lib/engines/common/evas_font_private.h
src/lib/engines/common/evas_font_query.c

index 8605cfe..8c8b2c3 100644 (file)
@@ -355,7 +355,7 @@ evas_object_text_text_set(Evas_Object *obj, const char *_text)
 #ifdef BIDI_SUPPORT
    evas_bidi_paragraph_props_unref(o->cur.intl_props.props);
    o->cur.intl_props.props = evas_bidi_paragraph_props_get(text);
-   evas_bidi_shape_string(text, &o->cur.intl_props, len);
+   evas_bidi_shape_string(text, o->cur.intl_props.props, 0, len);
 #endif
    if (o->cur.text) eina_ustringshare_del(o->cur.text);
    if (o->cur.utf8_text) eina_stringshare_del(o->cur.utf8_text);
index eaca526..e31d1eb 100644 (file)
@@ -2477,7 +2477,8 @@ _layout_text_add_and_split_item(Ctxt *c, Evas_Object_Textblock_Format *fmt,
    do
      {
         Evas_Object_Textblock_Text_Item *new_ti;
-        cutoff = evas_bidi_end_of_run_get(&ti->parent.bidi_props, len);
+        cutoff = evas_bidi_end_of_run_get(ti->parent.text_node->bidi_props,
+              ti->parent.text_pos, len);
         if (cutoff > 0)
           {
              new_ti = _layout_text_item_new(c, fmt, ti->text + cutoff);
@@ -2592,7 +2593,6 @@ _layout_text_append(Ctxt *c, Evas_Object_Textblock_Format *fmt, Evas_Object_Text
         /* Use the string, just cut the relevant parts */
         else
           {
-             Evas_BiDi_Props props;
              str = eina_ustrbuf_string_get(n->unicode);
              alloc_str = eina_unicode_strdup(str + start);
 
@@ -2603,10 +2603,8 @@ _layout_text_append(Ctxt *c, Evas_Object_Textblock_Format *fmt, Evas_Object_Text
              str = alloc_str;
 
              /* Shape the string */
-             props.start = start;
-             props.props = n->bidi_props;
 # ifdef BIDI_SUPPORT
-             evas_bidi_shape_string(alloc_str, &props, off);
+             evas_bidi_shape_string(alloc_str, n->bidi_props, start, off);
 # endif
           }
      }
@@ -6735,14 +6733,12 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
              /* Adjust if the char is an rtl char */
              if (ret >= 0)
                {
-                  Evas_BiDi_Props props;
-                  props.props = dir_cur->node->bidi_props;
-                  props.start = 0;
-
                   if ((!before_char &&
-                           evas_bidi_is_rtl_char(&props, dir_cur->pos)) ||
+                           evas_bidi_is_rtl_char(dir_cur->node->bidi_props, 0,
+                              dir_cur->pos)) ||
                         (before_char &&
-                         !evas_bidi_is_rtl_char(&props, dir_cur->pos)))
+                         !evas_bidi_is_rtl_char(dir_cur->node->bidi_props, 0,
+                            dir_cur->pos)))
 
                     {
                        /* Just don't advance the width */
@@ -6768,11 +6764,8 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
    if (dir && dir_cur && dir_cur->node)
      {
 #ifdef BIDI_SUPPORT
-        Evas_BiDi_Props props;
-        props.props = dir_cur->node->bidi_props;
-        props.start = 0;
-
-        *dir = (evas_bidi_is_rtl_char(&props, dir_cur->pos)) ?
+        *dir = (evas_bidi_is_rtl_char(dir_cur->node->bidi_props, dir_cur->pos,
+                 0)) ?
            EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
 #else
         *dir = EVAS_BIDI_DIRECTION_LTR;
@@ -7119,7 +7112,7 @@ _evas_textblock_range_calc_x_w(const Evas_Object_Textblock_Item *it,
    if ((start && !switch_items) || (!start && switch_items))
      {
 #ifdef BIDI_SUPPORT
-        if (evas_bidi_is_rtl_char(&it->bidi_props, 0))
+        if (evas_bidi_is_rtl_char(it->text_node->bidi_props, 0, 0))
           {
              *w = *x + *w;
              *x = 0;
@@ -7133,7 +7126,7 @@ _evas_textblock_range_calc_x_w(const Evas_Object_Textblock_Item *it,
    else
      {
 #ifdef BIDI_SUPPORT
-        if (evas_bidi_is_rtl_char(&it->bidi_props, 0))
+        if (evas_bidi_is_rtl_char(it->text_node->bidi_props, 0, 0))
           {
              *x = *x + *w;
              *w = it->adv - *x;
@@ -7259,7 +7252,7 @@ _evas_textblock_cursor_range_in_line_geometry_get(
           }
 
 #ifdef BIDI_SUPPORT
-        if (evas_bidi_is_rtl_char(&ti->parent.bidi_props, 0))
+        if (evas_bidi_is_rtl_char(ti->parent.text_node->bidi_props, 0, 0))
           {
              x = x1 + w1;
              w = x2 + w2 - x;
index b814201..2f678e9 100644 (file)
@@ -92,15 +92,16 @@ evas_bidi_is_rtl_str(const Eina_Unicode *str)
  *
  * @param str The string to shape
  * @param bidi_props the bidi props to shaped according.
+ * @param start the start of the string to shape (offset in bidi_props)
  * @param len the length of th string.
  * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
  */
 Eina_Bool
-evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *bidi_props, size_t len)
+evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, size_t len)
 {
    FriBidiChar *ustr, *base_ustr = NULL;
 
-   if (!bidi_props->props)
+   if (!bidi_props)
      return EINA_FALSE;
 
    /* The size of fribidichar is different than eina_unicode, convert */
@@ -126,12 +127,13 @@ evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Props *bidi_prop
      }
    fribidi_get_joining_types(ustr, len, join_types);
 
-   fribidi_join_arabic(bidi_props->props->char_types + bidi_props->start, len, bidi_props->props->embedding_levels + bidi_props->start, join_types);
+   fribidi_join_arabic(bidi_props->char_types + start, len,
+         bidi_props->embedding_levels + start, join_types);
 
 
    /* Actually modify the string */
    fribidi_shape(FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC,
-               bidi_props->props->embedding_levels + bidi_props->start, len, join_types, ustr);
+               bidi_props->embedding_levels + start, len, join_types, ustr);
 
    if (join_types) free(join_types);
 
@@ -333,21 +335,23 @@ error:
  * @internal
  * Returns the end of the current run of text
  *
- * @param bidi_props the properties
+ * @param bidi_props the paragraph properties
+ * @param start where to start looking from
  * @param len the length of the string
  * @return the position of the end of the run (offset from
  * bidi_props->props->start), 0 when there is no end (i.e all the text)
  */
 int
-evas_bidi_end_of_run_get(const Evas_BiDi_Props *bidi_props, int len)
+evas_bidi_end_of_run_get(const Evas_BiDi_Paragraph_Props *bidi_props,
+      size_t start, int len)
 {
    EvasBiDiLevel *i;
    EvasBiDiLevel base;
 
-   if (!bidi_props || !bidi_props->props || (len <= 0))
+   if (!bidi_props || (len <= 0))
      return 0;
 
-   i = bidi_props->props->embedding_levels + bidi_props->start;
+   i = bidi_props->embedding_levels + start;
    base = *i;
    for ( ; (len > 0) && (base == *i) ; len--, i++)
      ;
@@ -356,7 +360,7 @@ evas_bidi_end_of_run_get(const Evas_BiDi_Props *bidi_props, int len)
      {
         return 0;
      }
-   return i - (bidi_props->props->embedding_levels + bidi_props->start);
+   return i - (bidi_props->embedding_levels + start);
 }
 
 /**
@@ -391,17 +395,18 @@ evas_bidi_position_logical_to_visual(EvasBiDiStrIndex *v_to_l, int len, EvasBiDi
  * Checks if the char is rtl oriented. I.e even a neutral char can become rtl
  * if surrounded by rtl chars.
  *
- * @param bidi_props The bidi properties
- * @param index the index of the string.
+ * @param bidi_props The bidi paragraph properties
+ * @param start the base position
+ * @param index the offset from the base position.
  * @return #EINA_TRUE if true, #EINA_FALSE otherwise.
  */
 Eina_Bool
-evas_bidi_is_rtl_char(const Evas_BiDi_Props *bidi_props, EvasBiDiStrIndex index)
+evas_bidi_is_rtl_char(const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, EvasBiDiStrIndex index)
 {
-   if(!bidi_props || !bidi_props->props || index < 0)
+   if(!bidi_props || index < 0)
       return EINA_FALSE;
    return (FRIBIDI_IS_RTL(
-            bidi_props->props->embedding_levels[index + bidi_props->start]))
+            bidi_props->embedding_levels[index + start]))
       ? EINA_TRUE : EINA_FALSE;
 }
 
index 4587c18..06c21e9 100644 (file)
@@ -108,10 +108,10 @@ Eina_Bool
 evas_bidi_is_rtl_str(const Eina_Unicode *str);
 
 Eina_Bool
-evas_bidi_is_rtl_char(const Evas_BiDi_Props *bidi_props, EvasBiDiStrIndex index);
+evas_bidi_is_rtl_char(const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, EvasBiDiStrIndex index);
 
 int
-evas_bidi_end_of_run_get(const Evas_BiDi_Props *bidi_props, int len);
+evas_bidi_end_of_run_get(const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, int len);
 
 Eina_Bool
 evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len, const Evas_BiDi_Paragraph_Props *props, EvasBiDiStrIndex **_v_to_l);
@@ -123,7 +123,7 @@ void
 evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst);
 
 Eina_Bool
-evas_bidi_shape_string(Eina_Unicode *ustr, const Evas_BiDi_Props *intl_props, size_t len);
+evas_bidi_shape_string(Eina_Unicode *eina_ustr, const Evas_BiDi_Paragraph_Props *bidi_props, size_t start, size_t len);
 
 void
 evas_bidi_props_clean(Evas_BiDi_Props *intl_props) EINA_ARG_NONNULL(1);
index 1b782f5..dbaa5dd 100644 (file)
@@ -52,7 +52,7 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
          /* around. There is a slight exception when there are */ \
          /* compositing chars involved.*/ \
          if (intl_props && \
-               evas_bidi_is_rtl_char(intl_props, char_index) && \
+               evas_bidi_is_rtl_char(intl_props->props, intl_props->start, char_index) && \
                adv > 0) \
            { \
               if (evas_common_font_query_kerning(fi, index, prev_index, &kern)) \
index 45d1561..4446df6 100644 (file)
@@ -243,7 +243,7 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *in_text, c
         /* if it's rtl then the location is the left of the string,
          * otherwise, the right. */
 #ifdef BIDI_SUPPORT
-        if (evas_bidi_is_rtl_char(intl_props, 0))
+        if (evas_bidi_is_rtl_char(intl_props->props, intl_props->start, 0))
           {
              if (cx) *cx = 0;
              if (ch) *ch = asc + desc;
@@ -349,7 +349,7 @@ evas_common_font_query_pen_coords(RGBA_Font *fn, const Eina_Unicode *in_text, co
         /* if it's rtl then the location is the left of the string,
          * otherwise, the right. */
 #ifdef BIDI_SUPPORT
-        if (evas_bidi_is_rtl_char(intl_props, 0))
+        if (evas_bidi_is_rtl_char(intl_props->props, 0, 0))
           {
              if (cpen_x) *cpen_x = 0;
              if (ch) *ch = asc + desc;