forked from enlightenment/efl
Evas textblock: Since we now track text pos for format items as well as text items, we can (and did) merge _find_layout_item_line_match and _find_layout_format_item_line_match and obsolete the latter.
SVN revision: 56412
This commit is contained in:
parent
aa6849b76e
commit
664478cc55
|
@ -3306,7 +3306,7 @@ _relayout(const Evas_Object *obj)
|
||||||
* @see _find_layout_format_item_line_match()
|
* @see _find_layout_format_item_line_match()
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_find_layout_item_line_match(Evas_Object *obj, Evas_Object_Textblock_Node_Text *n, int pos, Evas_Object_Textblock_Line **lnr, Evas_Object_Textblock_Text_Item **tir)
|
_find_layout_item_line_match(Evas_Object *obj, Evas_Object_Textblock_Node_Text *n, int pos, Evas_Object_Textblock_Line **lnr, Evas_Object_Textblock_Item **itr)
|
||||||
{
|
{
|
||||||
Evas_Object_Textblock_Line *ln;
|
Evas_Object_Textblock_Line *ln;
|
||||||
Evas_Object_Textblock *o;
|
Evas_Object_Textblock *o;
|
||||||
|
@ -3319,62 +3319,34 @@ _find_layout_item_line_match(Evas_Object *obj, Evas_Object_Textblock_Node_Text *
|
||||||
|
|
||||||
EINA_INLIST_FOREACH(ln->items, it)
|
EINA_INLIST_FOREACH(ln->items, it)
|
||||||
{
|
{
|
||||||
if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
|
if (it->text_node == n)
|
||||||
{
|
{
|
||||||
if (it->text_node == n)
|
/* FIXME: p should be size_t, same goes for pos */
|
||||||
|
int p = (int) it->text_pos;
|
||||||
|
|
||||||
|
if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
|
||||||
{
|
{
|
||||||
Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it);
|
Evas_Object_Textblock_Text_Item *ti =
|
||||||
int p;
|
_ITEM_TEXT(it);
|
||||||
|
|
||||||
p = (int)(ti->parent.text_pos +
|
p += (int) eina_unicode_strlen(ti->text);
|
||||||
eina_unicode_strlen(ti->text));
|
}
|
||||||
if (((pos >= (int) ti->parent.text_pos) && (pos < p)))
|
else
|
||||||
{
|
{
|
||||||
*lnr = ln;
|
p++;
|
||||||
*tir = ti;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (p == pos)
|
|
||||||
{
|
|
||||||
*lnr = ln;
|
|
||||||
*tir = ti;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (((pos >= (int) it->text_pos) && (pos < p)))
|
||||||
* @internal
|
{
|
||||||
* Find the layout format item and line that match the format node passed.
|
*lnr = ln;
|
||||||
*
|
*itr = it;
|
||||||
* @param obj the evas object - NOT NULL.
|
return;
|
||||||
* @param n the text node - Not null.
|
}
|
||||||
* @param[out] lnr the line found - not null.
|
else if (p == pos)
|
||||||
* @param[out] fir the item found - not null.
|
{
|
||||||
* @see _find_layout_item_line_match()
|
*lnr = ln;
|
||||||
*/
|
*itr = it;
|
||||||
static void
|
}
|
||||||
_find_layout_format_item_line_match(Evas_Object *obj, Evas_Object_Textblock_Node_Format *n, Evas_Object_Textblock_Line **lnr, Evas_Object_Textblock_Format_Item **fir)
|
|
||||||
{
|
|
||||||
Evas_Object_Textblock_Line *ln;
|
|
||||||
Evas_Object_Textblock *o;
|
|
||||||
|
|
||||||
o = (Evas_Object_Textblock *)(obj->object_data);
|
|
||||||
if (!o->formatted.valid) _relayout(obj);
|
|
||||||
EINA_INLIST_FOREACH(o->paragraphs->lines, ln)
|
|
||||||
{
|
|
||||||
Evas_Object_Textblock_Item *it;
|
|
||||||
|
|
||||||
EINA_INLIST_FOREACH(ln->items, it)
|
|
||||||
{
|
|
||||||
if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
|
|
||||||
(_ITEM_FORMAT(it)->source_node == n))
|
|
||||||
{
|
|
||||||
*lnr = ln;
|
|
||||||
*fir = _ITEM_FORMAT(it);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4495,26 +4467,15 @@ _find_layout_item_match(const Evas_Textblock_Cursor *cur, Evas_Object_Textblock_
|
||||||
cur2.pos--;
|
cur2.pos--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evas_textblock_cursor_format_is_visible_get(cur))
|
if (_evas_textblock_cursor_is_at_the_end(cur) &&
|
||||||
{
|
|
||||||
_find_layout_format_item_line_match(cur->obj,
|
|
||||||
_evas_textblock_node_visible_at_pos_get(
|
|
||||||
_evas_textblock_cursor_node_format_at_pos_get(cur)),
|
|
||||||
lnr, (Evas_Object_Textblock_Format_Item **) itr);
|
|
||||||
}
|
|
||||||
else if (_evas_textblock_cursor_is_at_the_end(cur) &&
|
|
||||||
evas_textblock_cursor_format_is_visible_get(&cur2))
|
evas_textblock_cursor_format_is_visible_get(&cur2))
|
||||||
{
|
{
|
||||||
_find_layout_format_item_line_match(cur->obj,
|
_find_layout_item_line_match(cur2.obj, cur2.node, cur2.pos, lnr, itr);
|
||||||
_evas_textblock_node_visible_at_pos_get(
|
|
||||||
_evas_textblock_cursor_node_format_at_pos_get(&cur2)),
|
|
||||||
lnr, (Evas_Object_Textblock_Format_Item **) itr);
|
|
||||||
previous_format = EINA_TRUE;
|
previous_format = EINA_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_find_layout_item_line_match(cur->obj, cur->node, cur->pos, lnr,
|
_find_layout_item_line_match(cur->obj, cur->node, cur->pos, lnr, itr);
|
||||||
(Evas_Object_Textblock_Text_Item **) itr);
|
|
||||||
}
|
}
|
||||||
return previous_format;
|
return previous_format;
|
||||||
}
|
}
|
||||||
|
@ -7232,14 +7193,13 @@ evas_textblock_cursor_format_item_geometry_get(const Evas_Textblock_Cursor *cur,
|
||||||
Evas_Object_Textblock_Format_Item *fi = NULL;
|
Evas_Object_Textblock_Format_Item *fi = NULL;
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
if (!cur || !evas_textblock_cursor_format_is_visible_get(cur)) return 0;
|
if (!cur || !evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE;
|
||||||
o = (Evas_Object_Textblock *)(cur->obj->object_data);
|
o = (Evas_Object_Textblock *)(cur->obj->object_data);
|
||||||
if (!o->formatted.valid) _relayout(cur->obj);
|
if (!o->formatted.valid) _relayout(cur->obj);
|
||||||
_find_layout_format_item_line_match(cur->obj,
|
if (!evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE;
|
||||||
_evas_textblock_node_visible_at_pos_get(
|
_find_layout_item_line_match(cur->obj, cur->node, cur->pos, &ln,
|
||||||
_evas_textblock_cursor_node_format_at_pos_get(cur)),
|
(Evas_Object_Textblock_Item **) &fi);
|
||||||
&ln, &fi);
|
if ((!ln) || (!fi)) return EINA_FALSE;
|
||||||
if ((!ln) || (!fi)) return 0;
|
|
||||||
x = ln->x + fi->parent.x;
|
x = ln->x + fi->parent.x;
|
||||||
y = ln->y + ln->baseline + fi->y;
|
y = ln->y + ln->baseline + fi->y;
|
||||||
w = fi->parent.w;
|
w = fi->parent.w;
|
||||||
|
@ -7248,7 +7208,7 @@ evas_textblock_cursor_format_item_geometry_get(const Evas_Textblock_Cursor *cur,
|
||||||
if (cy) *cy = y;
|
if (cy) *cy = y;
|
||||||
if (cw) *cw = w;
|
if (cw) *cw = w;
|
||||||
if (ch) *ch = h;
|
if (ch) *ch = h;
|
||||||
return 1;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue