forked from enlightenment/efl
evas/font: fix handling querying char at coords (click on gap)
If query at x coord, which points to rigth half of LTR char, next position will be returned. The same for left half of RTL char. Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
This commit is contained in:
parent
be22889f7b
commit
d55c3f2bb7
|
@ -1,3 +1,9 @@
|
|||
2013-04-04 Yakov Goldberg
|
||||
|
||||
* Evas font: char position, returned by
|
||||
evas_common_font_query_char_at_coords(),
|
||||
depends on left/right half of char and its direction.
|
||||
|
||||
2013-03-04 Cedric Bail
|
||||
|
||||
* Evas: fix crash with Buffer engine with non alpha output.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -220,3 +220,4 @@ Fixes:
|
|||
* Fix evas word start/end find in textblock to be consistent with other toolkit logic on the matter
|
||||
* Fix edje entry to respect filters and if input filtered out, don't clear selections
|
||||
* Fix evas buffer engine allocation with non alpha output
|
||||
* Evas font: click on left/right half of char does matter now.
|
||||
|
|
|
@ -721,6 +721,7 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Evas_Text_Props *text
|
|||
if (found)
|
||||
{
|
||||
int item_pos;
|
||||
Evas_Coord cx_it, cw_it, cmid;
|
||||
Evas_Coord cluster_adv;
|
||||
cluster_adv = EVAS_FONT_WALK_PEN_X - cluster_start;
|
||||
|
||||
|
@ -736,12 +737,34 @@ evas_common_font_query_char_at_coords(RGBA_Font *fn, const Evas_Text_Props *text
|
|||
part = cluster_adv / items;
|
||||
item_pos = items - ((int) ((x - cluster_start) / part)) - 1;
|
||||
}
|
||||
if (cx) *cx = EVAS_FONT_WALK_PEN_X +
|
||||
((cluster_adv / items) * (item_pos - 1));
|
||||
|
||||
cx_it = EVAS_FONT_WALK_PEN_X + ((cluster_adv / items) * (item_pos - 1));
|
||||
cw_it = (cluster_adv / items);
|
||||
|
||||
if (cx) *cx = cx_it;
|
||||
if (cy) *cy = -asc;
|
||||
if (cw) *cw = (cluster_adv / items);
|
||||
if (cw) *cw = cw_it;
|
||||
if (ch) *ch = asc + desc;
|
||||
ret_val = prev_cluster + item_pos;
|
||||
|
||||
/* Check, if x coord points to RIGHT half part of LTR char
|
||||
* or to LEFT half char of RTL char. If so, increment found position */
|
||||
cmid = cx_it + (cw_it / 2);
|
||||
if (text_props->bidi_dir == EVAS_BIDI_DIRECTION_LTR)
|
||||
{
|
||||
if (x > cmid)
|
||||
{
|
||||
ret_val++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < cmid)
|
||||
{
|
||||
ret_val++;
|
||||
}
|
||||
}
|
||||
|
||||
goto end;
|
||||
}
|
||||
end:
|
||||
|
|
|
@ -117,7 +117,10 @@ START_TEST(evas_text_geometries)
|
|||
fail_if(x <= px);
|
||||
px = x;
|
||||
/* Get back the coords */
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (w / 2),
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (w / 4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
/* Get back cursor position, if click on right half of char. */
|
||||
fail_if((i + 1) != evas_object_text_char_coords_get(to, x + ((3 * w) / 4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
}
|
||||
|
||||
|
@ -427,7 +430,20 @@ START_TEST(evas_text_bidi)
|
|||
fail_if(x >= px);
|
||||
px = x;
|
||||
/* Get back the coords */
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (w / 2),
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + ((3 * w) / 4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
}
|
||||
|
||||
/* Get back cursor position, if click on left half of char. */
|
||||
evas_object_text_text_set(to, "שלום...");
|
||||
x = 0;
|
||||
px = 200;
|
||||
for (i = 0 ; i < eina_unicode_utf8_get_len("שלום...") ; i++)
|
||||
{
|
||||
fail_if(!evas_object_text_char_pos_get(to, i, &x, &y, &w, &h));
|
||||
fail_if(x >= px);
|
||||
px = x;
|
||||
fail_if((i + 1) != evas_object_text_char_coords_get(to, x + (w / 4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
}
|
||||
|
||||
|
@ -449,7 +465,7 @@ START_TEST(evas_text_bidi)
|
|||
fail_if(!evas_object_text_char_pos_get(to, i, &x, &y, &w, &h));
|
||||
fail_if(x <= px);
|
||||
px = x;
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (w / 2),
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + ((3 * w) / 4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
i++;
|
||||
for ( ; i < eina_unicode_utf8_get_len("Test - נסיון") ; i++)
|
||||
|
@ -486,7 +502,13 @@ START_TEST(evas_text_bidi)
|
|||
fail_if(x >= px);
|
||||
px = x;
|
||||
/* Get back the coords */
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (w / 2),
|
||||
if (w == 0)
|
||||
{
|
||||
int cx;
|
||||
fail_if(!evas_object_text_char_pos_get(to, i - 1, &cx, NULL, NULL, NULL));
|
||||
w = cx - x;
|
||||
}
|
||||
fail_if(i != evas_object_text_char_coords_get(to, x + (3 * w /4),
|
||||
y + (h / 2), &x, &y, &w, &h));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue