Evas textblock: Only use paragraph bidi props in the layout code.

Next commits will clear them outside of it. I.e paragraph bidi props are only
valid in the layout code.

SVN revision: 59861
This commit is contained in:
Tom Hacohen 2011-06-01 08:35:25 +00:00
parent 2b23129955
commit bebbe2253a
1 changed files with 56 additions and 22 deletions

View File

@ -265,7 +265,8 @@ struct _Evas_Object_Textblock_Paragraph
Evas_Object_Textblock_Line *lines; Evas_Object_Textblock_Line *lines;
Evas_Object_Textblock_Node_Text *text_node; Evas_Object_Textblock_Node_Text *text_node;
Eina_List *logical_items; Eina_List *logical_items;
Evas_BiDi_Paragraph_Props *bidi_props; Evas_BiDi_Paragraph_Props *bidi_props; /* Only valid during layout */
Evas_BiDi_Direction direction;
Evas_Coord y, w, h; Evas_Coord y, w, h;
int line_no; int line_no;
Eina_Bool visible : 1; Eina_Bool visible : 1;
@ -1749,6 +1750,7 @@ struct _Ctxt
Evas_Object_Textblock_Paragraph *par; Evas_Object_Textblock_Paragraph *par;
Evas_Object_Textblock_Line *ln; Evas_Object_Textblock_Line *ln;
Eina_List *format_stack; Eina_List *format_stack;
Evas_Object_Textblock_Format *fmt; Evas_Object_Textblock_Format *fmt;
@ -1947,9 +1949,6 @@ _layout_paragraph_new(Ctxt *c, Evas_Object_Textblock_Node_Text *n,
n->par = c->par; n->par = c->par;
c->par->line_no = -1; c->par->line_no = -1;
c->par->visible = 1; c->par->visible = 1;
#ifdef BIDI_SUPPORT
c->par->bidi_props = evas_bidi_paragraph_props_new();
#endif
} }
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
@ -1976,6 +1975,8 @@ _layout_update_bidi_props(const Evas_Object_Textblock *o,
par->bidi_props = evas_bidi_paragraph_props_get(text, par->bidi_props = evas_bidi_paragraph_props_get(text,
eina_ustrbuf_length_get(par->text_node->unicode), eina_ustrbuf_length_get(par->text_node->unicode),
segment_idxs); segment_idxs);
par->direction = EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL(par->bidi_props) ?
EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
if (segment_idxs) free(segment_idxs); if (segment_idxs) free(segment_idxs);
} }
} }
@ -2181,8 +2182,7 @@ _layout_line_align_get(Ctxt *c)
if (c->align_auto && c->ln) if (c->align_auto && c->ln)
{ {
if (c->ln->items && c->ln->items->text_node && if (c->ln->items && c->ln->items->text_node &&
EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL( (c->ln->par->direction == EVAS_BIDI_DIRECTION_RTL))
c->ln->par->bidi_props))
{ {
/* Align right*/ /* Align right*/
return 1.0; return 1.0;
@ -7239,15 +7239,23 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
/* Adjust if the char is an rtl char */ /* Adjust if the char is an rtl char */
if (ret >= 0) if (ret >= 0)
{ {
if ((!before_char && /* FIXME: Can be avoided if we keep info about if information
evas_bidi_is_rtl_char( * is bidi or not. */
dir_cur->node->par->bidi_props, 0, Evas_Object_Textblock_Line *ln;
dir_cur->pos)) || Evas_Object_Textblock_Item *it;
(before_char && Eina_Bool is_rtl = EINA_FALSE;
!evas_bidi_is_rtl_char( _find_layout_item_match(dir_cur, &ln, &it);
dir_cur->node->par->bidi_props, 0, if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
dir_cur->pos))) (_ITEM_TEXT(it)->text_props.bidi.dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
(_ITEM_FORMAT(it)->bidi_dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
if ((!before_char && is_rtl) ||
(before_char && !is_rtl))
{ {
/* Just don't advance the width */ /* Just don't advance the width */
w = 0; w = 0;
@ -7260,9 +7268,23 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
ret = evas_textblock_cursor_pen_geometry_get( ret = evas_textblock_cursor_pen_geometry_get(
dir_cur, &x, &y, &w, &h); dir_cur, &x, &y, &w, &h);
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* FIXME: Can be avoided if we keep info about if information
* is bidi or not. */
Evas_Object_Textblock_Line *ln;
Evas_Object_Textblock_Item *it;
Eina_Bool is_rtl = EINA_FALSE;
_find_layout_item_match(dir_cur, &ln, &it);
if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
(_ITEM_TEXT(it)->text_props.bidi.dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
(_ITEM_FORMAT(it)->bidi_dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
/* Adjust if the char is an rtl char */ /* Adjust if the char is an rtl char */
if ((ret >= 0) && (!evas_bidi_is_rtl_char( if ((ret >= 0) && (!is_rtl))
dir_cur->node->par->bidi_props, 0, dir_cur->pos)))
{ {
/* Just don't advance the width */ /* Just don't advance the width */
w = 0; w = 0;
@ -7286,16 +7308,29 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
if (dir && dir_cur && dir_cur->node) if (dir && dir_cur && dir_cur->node)
{ {
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
/* FIXME: Can be avoided if we keep info about if information
* is bidi or not. */
Evas_Object_Textblock_Line *ln;
Evas_Object_Textblock_Item *it;
Eina_Bool is_rtl = EINA_FALSE;
_find_layout_item_match(dir_cur, &ln, &it);
if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
(_ITEM_TEXT(it)->text_props.bidi.dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
(_ITEM_FORMAT(it)->bidi_dir ==
EVAS_BIDI_DIRECTION_RTL))
is_rtl = EINA_TRUE;
if (_evas_textblock_cursor_is_at_the_end(dir_cur) && (dir_cur->pos > 0)) if (_evas_textblock_cursor_is_at_the_end(dir_cur) && (dir_cur->pos > 0))
{ {
*dir = (evas_bidi_is_rtl_char(dir_cur->node->par->bidi_props, 0, *dir = (is_rtl) ?
dir_cur->pos - 1)) ?
EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR; EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
} }
else if (dir_cur->pos > 0) else if (dir_cur->pos > 0)
{ {
*dir = (evas_bidi_is_rtl_char(dir_cur->node->par->bidi_props, 0, *dir = (is_rtl) ?
dir_cur->pos)) ?
EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR; EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
} }
else else
@ -7403,8 +7438,7 @@ _evas_textblock_cursor_char_pen_geometry_common_get(int (*query_func) (void *dat
else else
{ {
#ifdef BIDI_SUPPORT #ifdef BIDI_SUPPORT
if (EVAS_BIDI_PARAGRAPH_DIRECTION_IS_RTL( if (ln->par->direction == EVAS_BIDI_DIRECTION_RTL)
ln->par->bidi_props))
{ {
x = ln->x; x = ln->x;
} }