summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora.srour <a.srour@samsung.com>2019-12-30 11:12:37 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-12-30 11:12:37 -0500
commit0164162a48dc1b1febf7828193e8ea05b4865b8f (patch)
tree853a8661ecaca01cda68a3191528b6bb7e674144
parent97ffbe1f127041a1831c0692b54ff05ef4643753 (diff)
Edje: edc text_class applied without font or font_size in style
Summary: The issue with `text_class` in Edc styles has to be within a string containing `font` & `font_size` properties to effect style, if font or font_size not presented in the same string text_class will be ignored. So in the following Edc example, `text_class` will be ignored: ``` collections { text_classes { text_class { name: "tc1"; font: "Sans"; size: 20; } } styles { style { name: "style1"; base: "color=#00FF00 text_class=tc1"; tag: "br" "\n"; } } } ``` To apply text_class `tc1`, font and font_size has to be added to `styles.style.base` value, to be as follows: ``` ... base: "font=Serif font_size=15 color=#00FF00 text_class=tc1"; ... ``` NOTE: The produced font will be `Sans` and font_size equal to `20` Test Plan: `layout.edc` ``` // compile: edje_cc layout.edc // play: edje_player layout.edj collections { text_classes { text_class { name: "tc1"; font: "Sans"; size: 20; } } styles { style { name: "style1"; base: "color=#FFFFFF text_class=tc1"; } } group { name : "group1"; parts { part { name : "tb1"; type: TEXTBLOCK; scale: 1; entry_mode: NONE; description { state: "default" 0.0; rel1.relative: 0.0 0.0; rel2.relative: 0.5 0.5; text { style: "style1"; align: 0.0 0.0; text: "Hello EFL"; } } } } } } Reviewers: segfaultxavi, smohanty, ali.alzyod, cedric, zmike Reviewed By: zmike Subscribers: zmike, segfaultxavi, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8477, T8478 Differential Revision: https://phab.enlightenment.org/D10692
-rw-r--r--src/lib/edje/edje_textblock_styles.c4
-rw-r--r--src/tests/edje/data/test_textblock.edc41
-rw-r--r--src/tests/edje/edje_test_text.c47
3 files changed, 86 insertions, 6 deletions
diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c
index d2b8aaa4ba..3618d201c4 100644
--- a/src/lib/edje/edje_textblock_styles.c
+++ b/src/lib/edje/edje_textblock_styles.c
@@ -193,7 +193,7 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl)
193 eina_strbuf_append(txt, fontsource); 193 eina_strbuf_append(txt, fontsource);
194 } 194 }
195 } 195 }
196 if (tc && tc->size && !EINA_DBL_EQ(tag->font_size, 0)) 196 if (tc && tc->size)
197 { 197 {
198 double new_size = _edje_text_size_calc(tag->font_size, tc); 198 double new_size = _edje_text_size_calc(tag->font_size, tc);
199 if (!EINA_DBL_EQ(tag->font_size, new_size)) 199 if (!EINA_DBL_EQ(tag->font_size, new_size))
@@ -206,7 +206,7 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl)
206 } 206 }
207 } 207 }
208 /* Add font name last to save evas from multiple loads */ 208 /* Add font name last to save evas from multiple loads */
209 if (tc && tc->font && tag->font) 209 if (tc && tc->font)
210 { 210 {
211 const char *f; 211 const char *f;
212 char *sfont = NULL; 212 char *sfont = NULL;
diff --git a/src/tests/edje/data/test_textblock.edc b/src/tests/edje/data/test_textblock.edc
index e8223e75be..f7cc0070a9 100644
--- a/src/tests/edje/data/test_textblock.edc
+++ b/src/tests/edje/data/test_textblock.edc
@@ -1,8 +1,21 @@
1collections { 1collections {
2 text_classes {
3 text_class {
4 name: "tc1";
5 font: "Serif";
6 size: 18;
7 }
8 }
2 styles { 9 styles {
3 style { name: "tb_style"; 10 style { name: "tb_style";
4 base: "font=Sans font_size=20 color=#fff"; 11 base: "font=Sans font_size=20 color=#fff";
5 } 12 }
13 style { name: "tb_tc_style";
14 base: "color=#ff0 text_class=tc1";
15 }
16 style { name: "tb_tc2_style";
17 base: "color=#0ff text_class=tc2";
18 }
6 } 19 }
7 group { name: "test_textblock"; 20 group { name: "test_textblock";
8 parts { 21 parts {
@@ -18,4 +31,32 @@ collections {
18 } 31 }
19 } 32 }
20 } 33 }
34 group { name: "test_tc_textblock";
35 parts {
36 part { name: "tb";
37 type: TEXTBLOCK;
38 description { state: "default" 0.0;
39 min: 300 300;
40 text {
41 text: "Hello World";
42 style: "tb_tc_style";
43 }
44 }
45 }
46 }
47 }
48 group { name: "test_tc_textblock2";
49 parts {
50 part { name: "tb2";
51 type: TEXTBLOCK;
52 description { state: "default" 0.0;
53 min: 300 300;
54 text {
55 text: "Hello World";
56 style: "tb_tc2_style";
57 }
58 }
59 }
60 }
61 }
21} 62}
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
index a66132c1d8..0939f8bbbf 100644
--- a/src/tests/edje/edje_test_text.c
+++ b/src/tests/edje/edje_test_text.c
@@ -102,13 +102,52 @@ EFL_START_TEST(edje_test_textblock)
102 evas = _setup_evas(); 102 evas = _setup_evas();
103 103
104 obj = edje_object_add(evas); 104 obj = edje_object_add(evas);
105 fail_unless(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), "test_textblock")); 105 ck_assert(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), "test_textblock"));
106 txt = edje_object_part_text_get(obj, "text"); 106 txt = edje_object_part_text_get(obj, "text");
107 fail_if(!txt || strcmp(txt, "Bye")); 107 ck_assert(txt || !strcmp(txt, "Bye"));
108 edje_object_part_text_set(obj, "text", buf); 108 edje_object_part_text_set(obj, "text", buf);
109 txt = edje_object_part_text_get(obj, "text"); 109 txt = edje_object_part_text_get(obj, "text");
110 fail_if(!txt || strcmp(txt, buf)); 110 ck_assert(txt || !strcmp(txt, buf));
111 111
112 Evas_Object *obj2 = edje_object_add(evas);
113 ck_assert(edje_object_file_set(obj2, test_layout_get("test_textblock.edj"), "test_tc_textblock"));
114 Evas_Object *tb = (Evas_Object*)edje_object_part_object_get(obj2, "tb");
115 ck_assert_ptr_ne(tb, NULL);
116 int w = 0, h = 0;
117 evas_object_textblock_size_formatted_get(tb, &w, &h);
118 Evas_Textblock_Style *st = evas_object_textblock_style_get(tb);
119 txt = evas_textblock_style_get(st);
120 ck_assert_str_eq(txt, "DEFAULT='color=#ff0 font_size=18.0 font=Serif'");
121 ck_assert_int_ne(w, 0);
122 ck_assert_int_ne(h, 0);
123
124 edje_object_text_class_set(obj2, "tc1", "Sans", 15);
125 edje_object_calc_force(obj2);
126 int w2 = 0, h2 = 0;
127 evas_object_textblock_size_formatted_get(tb, &w2, &h2);
128 ck_assert_int_ne(w2, 0);
129 ck_assert_int_ne(h2, 0);
130 ck_assert_int_ne(w, w2);
131 ck_assert_int_ne(h, h2);
132
133 ck_assert(edje_object_file_set(obj2, test_layout_get("test_textblock.edj"), "test_tc_textblock2"));
134 tb = (Evas_Object*)edje_object_part_object_get(obj2, "tb2");
135 ck_assert_ptr_ne(tb, NULL);
136 st = evas_object_textblock_style_get(tb);
137 txt = evas_textblock_style_get(st);
138 ck_assert_str_eq(txt, "DEFAULT='color=#0ff'");
139 evas_object_textblock_size_formatted_get(tb, &w, &h);
140 ck_assert_int_eq(w, 0);
141 ck_assert_int_eq(h, 0);
142
143 edje_object_text_class_set(obj2, "tc2", "Sans", 15);
144 edje_object_calc_force(obj2);
145 evas_object_textblock_size_formatted_get(tb, &w, &h);
146 ck_assert_int_ne(w, 0);
147 ck_assert_int_ne(h, 0);
148 st = evas_object_textblock_style_get(tb);
149 txt = evas_textblock_style_get(st);
150 ck_assert_str_eq(txt, "DEFAULT='color=#0ff font_size=15.0 font=Sans'");
112} 151}
113EFL_END_TEST 152EFL_END_TEST
114 153