tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=43f50dc7dbb159752d7913dea35e8156d0f10c7b

commit 43f50dc7dbb159752d7913dea35e8156d0f10c7b
Author: Subodh Kumar <s7158.ku...@samsung.com>
Date:   Thu Dec 17 11:54:35 2015 +0000

    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
---
 src/lib/evas/canvas/evas_object_textblock.c | 10 +++++++++-
 src/tests/evas/evas_test_textblock.c        | 14 +++++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index 48e7b3b..54e4311 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -10786,7 +10786,15 @@ 
evas_textblock_cursor_char_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, E
                               {
                                  Evas_Object_Textblock_Format_Item *fi;
                                  fi = _ITEM_FORMAT(it);
-                                 cur->pos = fi->parent.text_pos;
+                                 /* 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->node = found_par->text_node;
                                  return EINA_TRUE;
                               }
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index 467e164..528e640 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -1693,7 +1693,7 @@ END_TEST
 /* Testing 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();
    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))
      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 We need some item tests that involve line wrapping that make the

-- 


Reply via email to