forked from enlightenment/efl
Evas textblock: Use width of item format to position cursor.
Summary: Use width of item format to position cursor. Sometimes it becomes very difficult to position cursor over item and selection becomes very difficult as we position the cursor once the input X coord reached end of the item, like one attached in the test plan. So this patch decides over 50% of item width for X coord reaches to position it at start or end. @ix Test Plan: Attached setup shows how difficult to position cursor at the end when clicked over item and selection is also very difficult. Consider such case in mobile device, its becomes impossible to position cursor at the end and selection is too much difficult. {F27036} Also added test cases in evas test suite Reviewers: herdsman, tasn Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3390
This commit is contained in:
parent
8c891ed049
commit
43f50dc7db
|
@ -10786,7 +10786,15 @@ evas_textblock_cursor_char_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, E
|
||||||
{
|
{
|
||||||
Evas_Object_Textblock_Format_Item *fi;
|
Evas_Object_Textblock_Format_Item *fi;
|
||||||
fi = _ITEM_FORMAT(it);
|
fi = _ITEM_FORMAT(it);
|
||||||
|
/* Lets keep cur position half way for easy positioning */
|
||||||
|
if (x > (ln->x + it->x + (it->adv / 2)))
|
||||||
|
{
|
||||||
|
cur->pos = fi->parent.text_pos + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
cur->pos = fi->parent.text_pos;
|
cur->pos = fi->parent.text_pos;
|
||||||
|
}
|
||||||
cur->node = found_par->text_node;
|
cur->node = found_par->text_node;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1693,7 +1693,7 @@ END_TEST
|
||||||
/* Testing items */
|
/* Testing items */
|
||||||
START_TEST(evas_textblock_items)
|
START_TEST(evas_textblock_items)
|
||||||
{
|
{
|
||||||
Evas_Coord w, h, w2, h2, nw, nh, ih;
|
Evas_Coord x, y, w, h, w2, h2, nw, nh, ih;
|
||||||
START_TB_TEST();
|
START_TB_TEST();
|
||||||
const char *buf = "This is an <item absize=93x152></>.";
|
const char *buf = "This is an <item absize=93x152></>.";
|
||||||
|
|
||||||
|
@ -1798,6 +1798,18 @@ START_TEST(evas_textblock_items)
|
||||||
if (evas_textblock_cursor_format_item_geometry_get(cur, NULL, NULL, &w, &h))
|
if (evas_textblock_cursor_format_item_geometry_get(cur, NULL, NULL, &w, &h))
|
||||||
fail_if((w != 64) || (h != 64));
|
fail_if((w != 64) || (h != 64));
|
||||||
|
|
||||||
|
/* Test char coordinate for item at middle position of the item to decide cursor position,
|
||||||
|
* it means when char coordinate exceeds the half width of the item then only
|
||||||
|
* cursor position is changed. */
|
||||||
|
buf = "<item size=100x100 vsize=full></>.";
|
||||||
|
evas_object_textblock_text_markup_set(tb, buf);
|
||||||
|
evas_textblock_cursor_format_item_geometry_get(cur, &x, &y, &w, NULL);
|
||||||
|
evas_textblock_cursor_char_coord_set(cur, x + (w / 2) + 1, y);
|
||||||
|
fail_if(evas_textblock_cursor_pos_get(cur) != 1);
|
||||||
|
/* Test small increment in x and cursor position will be same */
|
||||||
|
evas_textblock_cursor_char_coord_set(cur, x + 10, y);
|
||||||
|
fail_if(evas_textblock_cursor_pos_get(cur) != 0);
|
||||||
|
|
||||||
/* FIXME: Also verify x,y positions of the item. */
|
/* FIXME: Also verify x,y positions of the item. */
|
||||||
|
|
||||||
/* FIXME We need some item tests that involve line wrapping that make the
|
/* FIXME We need some item tests that involve line wrapping that make the
|
||||||
|
|
Loading…
Reference in New Issue