summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiep.ha@samsung.com>2014-11-26 10:18:49 +0200
committerDaniel Hirt <daniel.hirt@samsung.com>2014-11-26 10:28:19 +0200
commit0dc58467a44333e67ffe24b5a9cacb6757c459b0 (patch)
tree8085c98f1710ce2b1ea26edfbb538acdd672946f
parentfa395a09593b4ed7ec746d9e2ab6552fbf1d7eef (diff)
textblock: correct text position for RTL text with margins
Summary: If a RTL textblock has right margin, text is wrongly placed (right margin is moved to left). This patch fixes this issue. Test cases are also added to test text position with margins. @fix Reviewers: tasn, herdsman Subscribers: woohyun, cedric Differential Revision: https://phab.enlightenment.org/D1691
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c4
-rw-r--r--src/tests/evas/evas_test_textblock.c33
2 files changed, 35 insertions, 2 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 2534f20fa4..52a5954b89 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -3397,8 +3397,8 @@ loop_advance:
3397 /* c->o->style_pad.r is already included in the line width, so it's 3397 /* c->o->style_pad.r is already included in the line width, so it's
3398 * not used in this calculation. . */ 3398 * not used in this calculation. . */
3399 c->ln->x = c->marginl + c->o->style_pad.l + 3399 c->ln->x = c->marginl + c->o->style_pad.l +
3400 ((c->w - c->ln->w - 3400 ((c->w - c->ln->w - c->o->style_pad.l -
3401 c->o->style_pad.l - c->marginl) * _layout_line_align_get(c)); 3401 c->marginl - c->marginr) * _layout_line_align_get(c));
3402 } 3402 }
3403 else 3403 else
3404 { 3404 {
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 928bbd303f..1c071bdb02 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -1954,6 +1954,39 @@ START_TEST(evas_textblock_various)
1954 evas_textblock_cursor_pos_set(cur, 0); 1954 evas_textblock_cursor_pos_set(cur, 0);
1955 evas_textblock_cursor_char_delete(cur); 1955 evas_textblock_cursor_char_delete(cur);
1956 1956
1957 /* Check margins' position */
1958 {
1959 Evas_Coord nw, nh, lx, lw;
1960
1961 evas_object_textblock_text_markup_set(tb, "This is a test");
1962 evas_object_textblock_size_native_get(tb, &nw, &nh);
1963 evas_object_resize(tb, nw, nh);
1964 evas_object_textblock_line_number_geometry_get(tb, 0, &lx, NULL, &lw, NULL);
1965 ck_assert_int_eq(lx, 0);
1966 ck_assert_int_eq(lx + lw, nw);
1967
1968 evas_object_textblock_text_markup_set(tb, "<left_margin=10 right_margin=5>This is a test</>");
1969 evas_object_textblock_size_native_get(tb, &nw, &nh);
1970 evas_object_resize(tb, nw, nh);
1971 evas_object_textblock_line_number_geometry_get(tb, 0, &lx, NULL, &lw, NULL);
1972 ck_assert_int_eq(lx, 10);
1973 ck_assert_int_eq(lx + lw + 5, nw);
1974
1975 evas_object_textblock_text_markup_set(tb, "עוד פסקה");
1976 evas_object_textblock_size_native_get(tb, &nw, &nh);
1977 evas_object_resize(tb, nw, nh);
1978 evas_object_textblock_line_number_geometry_get(tb, 0, &lx, NULL, &lw, NULL);
1979 ck_assert_int_eq(lx, 0);
1980 ck_assert_int_eq(lx + lw, nw);
1981
1982 evas_object_textblock_text_markup_set(tb, "<left_margin=10 right_margin=5>עוד פסקה</>");
1983 evas_object_textblock_size_native_get(tb, &nw, &nh);
1984 evas_object_resize(tb, nw, nh);
1985 evas_object_textblock_line_number_geometry_get(tb, 0, &lx, NULL, &lw, NULL);
1986 ck_assert_int_eq(lx, 10);
1987 ck_assert_int_eq(lx + lw + 5, nw);
1988 }
1989
1957 /* Super big one line item. */ 1990 /* Super big one line item. */
1958 { 1991 {
1959#define CNT 10000 1992#define CNT 10000