summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-01-15 10:57:34 +0000
committerTom Hacohen <tom@stosb.com>2013-01-15 10:57:34 +0000
commitd925820fa90481b6ded2fe7240fb3e489909e9a8 (patch)
treeb40f9279ac6b413163f501c654580ad8ab787130
parentf98369144b57f6189d8b1d65a9ba322b2db79bf5 (diff)
Evas textblock: simplified and fixed bugs in _cursor_geometry_get
SVN revision: 82798
-rw-r--r--ChangeLog4
-rw-r--r--NEWS1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c144
3 files changed, 20 insertions, 129 deletions
diff --git a/ChangeLog b/ChangeLog
index c30ea5f3a5..bf20184112 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-01-15 Tom Hacohen (TAsn)
2
3 * Evas textblock: Fixed issue and simplified cursor_geometry_get.
4
12013-01-14 Daniel Willmann 52013-01-14 Daniel Willmann
2 6
3 * edje: Fix off-by-one errors when using alloca in various functions 7 * edje: Fix off-by-one errors when using alloca in various functions
diff --git a/NEWS b/NEWS
index 25ad7fe659..ef11b2160b 100644
--- a/NEWS
+++ b/NEWS
@@ -113,3 +113,4 @@ Fixes:
113 * Fix bug in eio_file_map_new container set. 113 * Fix bug in eio_file_map_new container set.
114 * Evas textblock: Fixed issue with line height when breaking on a format. 114 * Evas textblock: Fixed issue with line height when breaking on a format.
115 * Fix SIGFPE in evas map update if image is 0. 115 * Fix SIGFPE in evas map update if image is 0.
116 * Evas textblock: Fixed issue and simplified cursor_geometry_get.
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 8f14453dee..7bd633b9a8 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -8908,13 +8908,10 @@ EAPI int
8908evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_BiDi_Direction *dir, Evas_Textblock_Cursor_Type ctype) 8908evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_BiDi_Direction *dir, Evas_Textblock_Cursor_Type ctype)
8909{ 8909{
8910 int ret = -1; 8910 int ret = -1;
8911 const Evas_Textblock_Cursor *dir_cur;
8912 Evas_Textblock_Cursor cur2;
8913 if (!cur) return -1; 8911 if (!cur) return -1;
8914 Evas_Object_Textblock *o = eo_data_get(cur->obj, MY_CLASS); 8912 Evas_Object_Textblock *o = eo_data_get(cur->obj, MY_CLASS);
8915 if (!o->formatted.valid) _relayout(cur->obj); 8913 if (!o->formatted.valid) _relayout(cur->obj);
8916 8914
8917 dir_cur = cur;
8918 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER) 8915 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER)
8919 { 8916 {
8920 ret = evas_textblock_cursor_pen_geometry_get(cur, cx, cy, cw, ch); 8917 ret = evas_textblock_cursor_pen_geometry_get(cur, cx, cy, cw, ch);
@@ -8924,142 +8921,31 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
8924 /* In the case of a "before cursor", we should get the coordinates 8921 /* In the case of a "before cursor", we should get the coordinates
8925 * of just after the previous char (which in bidi text may not be 8922 * of just after the previous char (which in bidi text may not be
8926 * just before the current char). */ 8923 * just before the current char). */
8927 Evas_Coord x, y, h, w; 8924 Evas_Coord x, y, w, h;
8928 Evas_Object_Textblock_Node_Format *fmt;
8929
8930 /* If it's at the end of the line, we want to get the position, not
8931 * the position of the previous */
8932 if ((cur->pos > 0) && !_evas_textblock_cursor_is_at_the_end(cur))
8933 {
8934#ifdef BIDI_SUPPORT
8935 Eina_Bool before_char = EINA_FALSE;
8936#endif
8937 cur2.obj = cur->obj;
8938 evas_textblock_cursor_copy(cur, &cur2);
8939 evas_textblock_cursor_char_prev(&cur2);
8940 8925
8941 fmt = _evas_textblock_cursor_node_format_at_pos_get(&cur2); 8926 Evas_Object_Textblock_Line *ln;
8942 8927 Evas_Object_Textblock_Item *it;
8943 if (!fmt || !_IS_LINE_SEPARATOR(fmt->format))
8944 {
8945 dir_cur = &cur2;
8946#ifdef BIDI_SUPPORT
8947 before_char = EINA_FALSE;
8948#endif
8949 }
8950#ifdef BIDI_SUPPORT
8951 else
8952 {
8953 before_char = EINA_TRUE;
8954 }
8955#endif
8956 ret = evas_textblock_cursor_pen_geometry_get(
8957 dir_cur, &x, &y, &w, &h);
8958#ifdef BIDI_SUPPORT
8959 /* Adjust if the char is an rtl char */
8960 if (ret >= 0)
8961 {
8962 Eina_Bool is_rtl = EINA_FALSE;
8963 if (dir_cur->node->par->is_bidi)
8964 {
8965 Evas_Object_Textblock_Line *ln;
8966 Evas_Object_Textblock_Item *it;
8967 _find_layout_item_match(dir_cur, &ln, &it);
8968 if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
8969 (_ITEM_TEXT(it)->text_props.bidi_dir ==
8970 EVAS_BIDI_DIRECTION_RTL))
8971 is_rtl = EINA_TRUE;
8972 else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
8973 (_ITEM_FORMAT(it)->bidi_dir ==
8974 EVAS_BIDI_DIRECTION_RTL))
8975 is_rtl = EINA_TRUE;
8976 }
8977 8928
8978 if ((!before_char && is_rtl) || 8929 ret = evas_textblock_cursor_pen_geometry_get(cur, &x, &y, &w, &h);
8979 (before_char && !is_rtl)) 8930 _find_layout_item_match(cur, &ln, &it);
8980 { 8931 if (ret >= 0)
8981 /* Just don't advance the width */
8982 w = 0;
8983 }
8984 }
8985#endif
8986 }
8987 else if (cur->pos == 0)
8988 { 8932 {
8989 ret = evas_textblock_cursor_pen_geometry_get( 8933 Evas_BiDi_Direction itdir =
8990 dir_cur, &x, &y, &w, &h); 8934 (it->type == EVAS_TEXTBLOCK_ITEM_TEXT) ?
8991#ifdef BIDI_SUPPORT 8935 _ITEM_TEXT(it)->text_props.bidi_dir :
8992 Eina_Bool is_rtl = EINA_FALSE; 8936 _ITEM_FORMAT(it)->bidi_dir;
8993 if (dir_cur->node && dir_cur->node->par->is_bidi) 8937 if (itdir == EVAS_BIDI_DIRECTION_RTL)
8994 { 8938 {
8995 Evas_Object_Textblock_Line *ln; 8939 if (cx) *cx = x + w;
8996 Evas_Object_Textblock_Item *it;
8997 _find_layout_item_match(dir_cur, &ln, &it);
8998 if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
8999 (_ITEM_TEXT(it)->text_props.bidi_dir ==
9000 EVAS_BIDI_DIRECTION_RTL))
9001 is_rtl = EINA_TRUE;
9002 else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
9003 (_ITEM_FORMAT(it)->bidi_dir ==
9004 EVAS_BIDI_DIRECTION_RTL))
9005 is_rtl = EINA_TRUE;
9006 } 8940 }
9007 8941 else
9008 /* Adjust if the char is an rtl char */
9009 if ((ret >= 0) && (!is_rtl))
9010 { 8942 {
9011 /* Just don't advance the width */ 8943 if (cx) *cx = x;
9012 w = 0;
9013 } 8944 }
9014#endif
9015 }
9016 else
9017 {
9018 ret = evas_textblock_cursor_pen_geometry_get(
9019 dir_cur, &x, &y, &w, &h);
9020 }
9021 if (ret >= 0)
9022 {
9023 if (cx) *cx = x + w;
9024 if (cy) *cy = y; 8945 if (cy) *cy = y;
9025 if (cw) *cw = 0; 8946 if (cw) *cw = 0;
9026 if (ch) *ch = h; 8947 if (ch) *ch = h;
9027 } 8948 if (dir) *dir = itdir;
9028 }
9029
9030 if (dir && dir_cur && dir_cur->node)
9031 {
9032#ifdef BIDI_SUPPORT
9033 Eina_Bool is_rtl = EINA_FALSE;
9034 if (dir_cur->node->par->is_bidi)
9035 {
9036 Evas_Object_Textblock_Line *ln;
9037 Evas_Object_Textblock_Item *it;
9038 _find_layout_item_match(dir_cur, &ln, &it);
9039 if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
9040 (_ITEM_TEXT(it)->text_props.bidi_dir ==
9041 EVAS_BIDI_DIRECTION_RTL))
9042 is_rtl = EINA_TRUE;
9043 else if ((it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) &&
9044 (_ITEM_FORMAT(it)->bidi_dir ==
9045 EVAS_BIDI_DIRECTION_RTL))
9046 is_rtl = EINA_TRUE;
9047 }
9048
9049 if (_evas_textblock_cursor_is_at_the_end(dir_cur) && (dir_cur->pos > 0))
9050 {
9051 *dir = (is_rtl) ?
9052 EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
9053 }
9054 else if (dir_cur->pos > 0)
9055 {
9056 *dir = (is_rtl) ?
9057 EVAS_BIDI_DIRECTION_RTL : EVAS_BIDI_DIRECTION_LTR;
9058 }
9059 else
9060#endif
9061 {
9062 *dir = EVAS_BIDI_DIRECTION_LTR;
9063 } 8949 }
9064 } 8950 }
9065 return ret; 8951 return ret;