summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-06-05 21:02:43 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-06-20 15:18:00 +0300
commit88e16b338823dcfbc21cbe88056dc31895036bd1 (patch)
tree653cb584dc730655832858f52387d5513c291913
parent151b7616f671edc25f2a88fa1d728ea4ac71964b (diff)
Canvas layout: support more Efl.Text.* with efl_partdevs/herdsman/edje_part_next
This adds many Efl.Text.* that are useful for manipulating the underlying TEXTBLOCK object's propeties using efl_part. This has been implemented as part of the "user-defined" properties of the layout part, so that the changes on the part persist across load of different groups. Note that text styles have precedence over the TEXTBLOCK (Canvas.Text) object's properties. if an edc provides a style, the properties it manipulates as part of the "base:" string would not be affected by this API. In general, this helps reducing the amount of styles for objects (or modes of the same objects) that share the same setup, but are different in some properties (e.g. ellipsis, wrap etc). @feature Canvas layout: add text part "expand" property This adds "expansion modes", which are essentially the same as min/max hints in the edje part's 'description.text' fields. The user can then customize his widget to different modes without being forced to create a new edje group in the theme. Note that there is an added check in case one of the min/max text flags are provided from the theme. In such case, all flags from this new API will be ignored. This fortifies misuse where the flags are set both in theme and the API. @feature
-rw-r--r--src/Makefile_Edje.am3
-rw-r--r--src/examples/elementary/Makefile.am6
-rw-r--r--src/examples/elementary/efl_canvas_layout_text.c156
-rw-r--r--src/examples/elementary/efl_canvas_layout_text.edc48
-rw-r--r--src/lib/edje/edje_load.c24
-rw-r--r--src/lib/edje/edje_part_text.c528
-rw-r--r--src/lib/edje/edje_private.h70
-rw-r--r--src/lib/edje/edje_textblock.c83
-rw-r--r--src/lib/edje/edje_util.c75
-rw-r--r--src/lib/edje/efl_canvas_layout_part_text.eo50
-rw-r--r--src/lib/efl/interfaces/efl_text_style.eo9
-rw-r--r--src/lib/evas/canvas/efl_canvas_text.eo1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c30
-rw-r--r--src/tests/edje/data/test_text.edc41
-rw-r--r--src/tests/edje/edje_suite.c1
-rw-r--r--src/tests/edje/edje_suite.h1
-rw-r--r--src/tests/edje/edje_test_text.c239
17 files changed, 1312 insertions, 53 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index 87d67b5e89..051aeca202 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -300,6 +300,7 @@ tests/edje/data/test_messages.edc \
300tests/edje/data/test_signals.edc \ 300tests/edje/data/test_signals.edc \
301tests/edje/data/test_signal_callback_del_full.edc \ 301tests/edje/data/test_signal_callback_del_full.edc \
302tests/edje/data/test_text_cursor.edc \ 302tests/edje/data/test_text_cursor.edc \
303tests/edje/data/test_text.edc \
303tests/edje/data/filter.lua 304tests/edje/data/filter.lua
304 305
305 306
@@ -318,6 +319,7 @@ TESTS += tests/edje/edje_suite
318tests_edje_edje_suite_SOURCES = \ 319tests_edje_edje_suite_SOURCES = \
319tests/edje/edje_suite.c \ 320tests/edje/edje_suite.c \
320tests/edje/edje_test_edje.c \ 321tests/edje/edje_test_edje.c \
322tests/edje/edje_test_text.c \
321tests/edje/edje_suite.h 323tests/edje/edje_suite.h
322 324
323tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT} 325tests/edje/data/%.edj: tests/edje/data/%.edc bin/edje/edje_cc${EXEEXT}
@@ -344,6 +346,7 @@ EDJE_TEST_FILES = tests/edje/data/test_layout.edj \
344 tests/edje/data/test_signals.edj \ 346 tests/edje/data/test_signals.edj \
345 tests/edje/data/test_signal_callback_del_full.edj \ 347 tests/edje/data/test_signal_callback_del_full.edj \
346 tests/edje/data/test_text_cursor.edj \ 348 tests/edje/data/test_text_cursor.edj \
349 tests/edje/data/test_text.edj \
347 $(NULL) 350 $(NULL)
348 351
349CLEANFILES += $(EDJE_TEST_FILES) 352CLEANFILES += $(EDJE_TEST_FILES)
diff --git a/src/examples/elementary/Makefile.am b/src/examples/elementary/Makefile.am
index 546c270a50..85d9e01aff 100644
--- a/src/examples/elementary/Makefile.am
+++ b/src/examples/elementary/Makefile.am
@@ -181,7 +181,8 @@ efl_thread_6.c \
181efl_ui_list_example_1.c \ 181efl_ui_list_example_1.c \
182efl_ui_view_list_example_1.c \ 182efl_ui_view_list_example_1.c \
183efl_ui_view_list_example_2.c \ 183efl_ui_view_list_example_2.c \
184efl_ui_view_list_example_3.c 184efl_ui_view_list_example_3.c \
185efl_canvas_layout_text.c
185 186
186SRCS += \ 187SRCS += \
187bg_cxx_example_01.cc \ 188bg_cxx_example_01.cc \
@@ -398,7 +399,8 @@ efl_thread_6 \
398efl_ui_list_example_1 \ 399efl_ui_list_example_1 \
399efl_ui_view_list_example_1 \ 400efl_ui_view_list_example_1 \
400efl_ui_view_list_example_2 \ 401efl_ui_view_list_example_2 \
401efl_ui_view_list_example_3 402efl_ui_view_list_example_3 \
403efl_canvas_layout_text
402#benchmark3d 404#benchmark3d
403#sphere-hunter 405#sphere-hunter
404 406
diff --git a/src/examples/elementary/efl_canvas_layout_text.c b/src/examples/elementary/efl_canvas_layout_text.c
new file mode 100644
index 0000000000..8dea0f8b87
--- /dev/null
+++ b/src/examples/elementary/efl_canvas_layout_text.c
@@ -0,0 +1,156 @@
1// gcc -o efl_canvas_layout_text efl_canvas_layout_text.c `pkg-config --cflags --libs elementary`
2// edje_cc efl_canvas_layout.edc
3// ./efl_canvas_layout_text
4
5#ifdef HAVE_CONFIG_H
6# include "elementary_config.h"
7#else
8# define EFL_BETA_API_SUPPORT 1
9# define EFL_EO_API_SUPPORT 1
10#endif
11
12#include <Efl.h>
13#include <Elementary.h>
14#include <string.h>
15
16static void
17_on_win_delete(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
18{
19 efl_exit(0);
20}
21
22static const char* groups[] = { "test", "test2" };
23static size_t group_itr = 0;
24
25static double ellipsis[] = { -1.0, 1.0 };
26static size_t ellipsis_itr = 0;
27
28static struct
29{
30 Efl_Text_Format_Wrap wrap;
31 const char *desc;
32} wraps[] =
33{
34 { EFL_TEXT_FORMAT_WRAP_NONE, "none" },
35 { EFL_TEXT_FORMAT_WRAP_WORD, "word" },
36 { EFL_TEXT_FORMAT_WRAP_CHAR, "char" },
37 { EFL_TEXT_FORMAT_WRAP_MIXED, "mixed" }
38};
39
40static struct
41{
42 Efl_Text_Format_Wrap wrap;
43 const char *desc;
44} group[] =
45{
46 { EFL_TEXT_FORMAT_WRAP_NONE, "none" },
47 { EFL_TEXT_FORMAT_WRAP_WORD, "word" },
48 { EFL_TEXT_FORMAT_WRAP_CHAR, "char" },
49 { EFL_TEXT_FORMAT_WRAP_MIXED, "mixed" }
50};
51static struct
52{
53 Efl_Canvas_Layout_Part_Text_Expand expand;
54 const char *desc;
55} expands[] =
56{
57 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_NONE, "none" },
58 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X, "min_x" },
59 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y, "min_y" },
60 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X, "max_x" },
61 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y, "max_y" },
62 { EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X | EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y , "min_x AND min_y"}
63};
64
65static size_t wrap_itr = 0;
66static size_t expand_itr = 0;
67
68static void
69_help(void)
70{
71 printf("Press 'w' to cycle wrap modes.\n"
72 "Press 's' to cycle expand hints and print min_size result.\n"
73 "Press 'h' to display this help.\n");
74}
75
76static const char *edjefile = "efl_canvas_layout_text.edj";
77
78static void
79_on_key_down(void *data, const Efl_Event *event)
80{
81 Efl_Input_Key *ev = event->info;
82 Eo *layout = data;
83 const char *key = efl_input_key_name_get(ev);
84
85 if (!strcmp(key, "g"))
86 {
87 // edje group
88 group_itr = (group_itr + 1) % 2;
89 efl_file_set(layout, edjefile, groups[group_itr]);
90 printf("Changed layout group to: %s\n", groups[group_itr]);
91 }
92 else if (!strcmp(key, "w"))
93 {
94 // wrap mode
95 wrap_itr = (wrap_itr + 1) % 4;
96 efl_text_wrap_set(efl_part(layout, "text"), wraps[wrap_itr].wrap);
97 printf("Changed wrap to %s\n", wraps[wrap_itr].desc);
98 }
99 else if (!strcmp(key, "e"))
100 {
101 // ellipsis value
102 ellipsis_itr = (ellipsis_itr + 1) % 2;
103 efl_text_ellipsis_set(efl_part(layout, "text"), ellipsis[ellipsis_itr]);
104 printf("Changed ellipsis to %f\n", ellipsis[ellipsis_itr]);
105 }
106 else if (!strcmp(key, "s"))
107 {
108 Eina_Size2D sz;
109 // expand mode
110 expand_itr = (expand_itr + 1) % 6;
111 efl_canvas_layout_part_text_expand_set(efl_part(layout, "text"),
112 expands[expand_itr].expand);
113 printf("Changed expand mode to: %s\n", expands[expand_itr].desc);
114
115 sz = efl_layout_calc_size_min(layout, EINA_SIZE2D(10, 10));
116 printf("new expand_min: %dx%d\n", sz.w, sz.h);
117 }
118 else if (!strcmp(key, "h"))
119 {
120 _help();
121 }
122}
123
124EAPI_MAIN void
125efl_main(void *data EINA_UNUSED,
126 const Efl_Event *ev)
127{
128
129 Eo *layout;
130 Eo *win;
131
132 win = efl_add(EFL_UI_WIN_CLASS, NULL,
133 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
134 efl_text_set(efl_added, "Efl Canvas_Layout"),
135 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
136 efl_event_callback_add(efl_added, EFL_UI_WIN_EVENT_DELETE_REQUEST, _on_win_delete, NULL));
137
138
139 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, win);
140 efl_file_set(layout, edjefile, groups[group_itr]);
141
142 efl_content_set(win, layout);
143 efl_gfx_entity_size_set(win, EINA_SIZE2D(110, 100));
144
145 efl_text_markup_set(efl_part(layout, "text"), "This is an example text. This is a layout text part.");
146 efl_text_wrap_set(efl_part(layout, "text"), wraps[wrap_itr].wrap);
147 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 0, 255);
148 efl_text_font_set(efl_part(layout, "text"), "Serif", 12);
149
150 efl_canvas_layout_part_text_expand_set(efl_part(layout, "text"),
151 expands[expand_itr].expand);
152
153 efl_event_callback_add(win, EFL_EVENT_KEY_DOWN, _on_key_down, layout);
154
155}
156EFL_MAIN()
diff --git a/src/examples/elementary/efl_canvas_layout_text.edc b/src/examples/elementary/efl_canvas_layout_text.edc
new file mode 100644
index 0000000000..401ad0c255
--- /dev/null
+++ b/src/examples/elementary/efl_canvas_layout_text.edc
@@ -0,0 +1,48 @@
1efl_version: 1 21;
2collections {
3 styles {
4 style { name: "tbstyle";
5 base: "";
6 }
7 }
8 group { name: "test";
9 parts {
10 textblock { "text"; nomouse;
11 desc { "default";
12 rel1.relative: 0.0 0.0;
13 rel2.relative: 1.0 1.0;
14 text {
15 style: "tbstyle";
16 font: FN; size: 10;
17 align: 0.5 0.5;
18 }
19 visible: 1;
20 }
21 }
22 }
23 }
24 group { name: "test2";
25 parts {
26 rect { "rect"; nomouse; repeat; precise;
27 desc { "default";
28 color: 255 0 0 255;
29 rel1.relative: 0.0 0.0;
30 rel2.relative: 0.5 1;
31 }
32 }
33 textblock { "text"; nomouse;
34 desc { "default";
35 rel1.relative: 0.5 0.0;
36 rel2.relative: 1.0 1.0;
37 //fixed: 1 1;
38 text {
39 style: "tbstyle";
40 font: FN; size: 10;
41 align: 0.5 0.5;
42 }
43 visible: 1;
44 }
45 }
46 }
47 }
48}
diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index c0d0ac25a3..94f7c2a67b 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1644,6 +1644,25 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
1644 } 1644 }
1645 eina_stringshare_del(eud->u.string.text); 1645 eina_stringshare_del(eud->u.string.text);
1646 break; 1646 break;
1647
1648 case EDJE_USER_TEXT_STYLE:
1649 {
1650 Edje_Part_Text_Prop *prop;
1651 EINA_LIST_FREE(eud->u.text_style.props, prop)
1652 {
1653 _canvas_layout_user_text_apply(eud, obj,
1654 prop);
1655 free(prop);
1656 }
1657 }
1658 break;
1659 case EDJE_USER_TEXT_EXPAND:
1660 {
1661 efl_canvas_layout_part_text_expand_set(
1662 efl_part(obj, eud->part),
1663 eud->u.text_expand.expand);
1664 }
1665 break;
1647 } 1666 }
1648 if (eud) _edje_user_definition_remove(eud, child); 1667 if (eud) _edje_user_definition_remove(eud, child);
1649 } 1668 }
@@ -1839,10 +1858,15 @@ _edje_object_collect(Edje *ed)
1839 edje_object_part_unswallow(NULL, eud->u.swallow.child); 1858 edje_object_part_unswallow(NULL, eud->u.swallow.child);
1840 break; 1859 break;
1841 1860
1861 case EDJE_USER_TEXT_STYLE:
1862 _canvas_layout_user_text_collect(ed, eud);
1863 break;
1864
1842 case EDJE_USER_DRAG_STEP: 1865 case EDJE_USER_DRAG_STEP:
1843 case EDJE_USER_DRAG_PAGE: 1866 case EDJE_USER_DRAG_PAGE:
1844 case EDJE_USER_DRAG_VALUE: 1867 case EDJE_USER_DRAG_VALUE:
1845 case EDJE_USER_DRAG_SIZE: 1868 case EDJE_USER_DRAG_SIZE:
1869 case EDJE_USER_TEXT_EXPAND:
1846 break; 1870 break;
1847 } 1871 }
1848 } 1872 }
diff --git a/src/lib/edje/edje_part_text.c b/src/lib/edje/edje_part_text.c
index 6e8e231ae2..31678a3697 100644
--- a/src/lib/edje/edje_part_text.c
+++ b/src/lib/edje/edje_part_text.c
@@ -197,5 +197,533 @@ _efl_canvas_layout_part_text_efl_text_markup_cursor_markup_insert(Eo *obj,
197 // FIXME: entry should report the length of inserted text (after filtering) 197 // FIXME: entry should report the length of inserted text (after filtering)
198} 198}
199 199
200/* More Efl.Text.* API (@since 1.22) */
201
202EOLIAN static void
203_efl_canvas_layout_part_text_efl_text_style_backing_type_set(Eo *obj,
204 void *_pd EINA_UNUSED,
205 Efl_Text_Style_Backing_Type type)
206{
207 Edje_User_Defined *eud;
208
209 PROXY_DATA_GET(obj, pd);
210 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
211
212 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
213
214 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_NONE;
215 efl_text_backing_type_set(pd->rp->object, type);
216}
217
218EOLIAN static Efl_Text_Style_Backing_Type
219_efl_canvas_layout_part_text_efl_text_style_backing_type_get(const Eo *obj,
220 void *_pd EINA_UNUSED)
221{
222
223 PROXY_DATA_GET(obj, pd);
224 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT)
225 return EFL_TEXT_STYLE_BACKING_TYPE_DISABLED;
226
227 return efl_text_backing_type_get(pd->rp->object);
228}
229
230#define TEXT_COLOR_IMPL(x, X) \
231EOLIAN static void \
232_efl_canvas_layout_part_text_efl_text_style_ ##x ##_color_set(Eo *obj, \
233 void *_pd EINA_UNUSED, \
234 unsigned char r, unsigned char g, unsigned char b, unsigned char a) \
235{ \
236 Edje_User_Defined *eud; \
237 \
238 PROXY_DATA_GET(obj, pd); \
239 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return; \
240 \
241 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part); \
242 \
243 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_COLOR_ ##X; \
244 efl_text_ ##x ##_color_set(pd->rp->object, r, g, b, a); \
245} \
246\
247EOLIAN static void \
248_efl_canvas_layout_part_text_efl_text_style_ ##x ##_color_get(const Eo *obj, \
249 void *_pd EINA_UNUSED, \
250 unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) \
251{ \
252 PROXY_DATA_GET(obj, pd); \
253 *r = *g = *b = *a = 0; \
254 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return; \
255 efl_text_ ##x ##_color_get(pd->rp->object, r, g, b, a); \
256}
257
258TEXT_COLOR_IMPL(backing, BACKING)
259TEXT_COLOR_IMPL(glow, GLOW)
260TEXT_COLOR_IMPL(glow2, GLOW2)
261TEXT_COLOR_IMPL(normal, NORMAL)
262TEXT_COLOR_IMPL(outline, OUTLINE)
263TEXT_COLOR_IMPL(shadow, SHADOW)
264TEXT_COLOR_IMPL(strikethrough, STRIKETHROUGH)
265TEXT_COLOR_IMPL(underline, UNDERLINE)
266TEXT_COLOR_IMPL(underline2, UNDERLINE2)
267TEXT_COLOR_IMPL(underline_dashed, UNDERLINE_DASHED)
268
269EOLIAN static void
270_efl_canvas_layout_part_text_efl_text_style_effect_type_set(Eo *obj,
271 void *_pd EINA_UNUSED,
272 Efl_Text_Style_Effect_Type type)
273{
274 Edje_User_Defined *eud;
275
276 PROXY_DATA_GET(obj, pd);
277 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
278
279 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
280
281 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_EFFECT_TYPE;
282 efl_text_effect_type_set(pd->rp->object, type);
283}
284
285EOLIAN static void
286_efl_canvas_layout_part_text_efl_text_format_ellipsis_set(Eo *obj,
287 void *_pd EINA_UNUSED, double value)
288{
289 Edje_User_Defined *eud;
290
291 PROXY_DATA_GET(obj, pd);
292 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
293
294 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
295
296 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_ELLIPSIS;
297 efl_text_ellipsis_set(pd->rp->object, value);
298}
299
300EOLIAN static double
301_efl_canvas_layout_part_text_efl_text_format_ellipsis_get(const Eo *obj,
302 void *_pd EINA_UNUSED)
303{
304 PROXY_DATA_GET(obj, pd);
305 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return 0.0;
306
307 return efl_text_ellipsis_get(pd->rp->object);
308}
309
310EOLIAN static void
311_efl_canvas_layout_part_text_efl_text_font_font_set(Eo *obj,
312 void *_pd EINA_UNUSED, const char *font, Efl_Font_Size size)
313{
314 Edje_User_Defined *eud;
315
316 PROXY_DATA_GET(obj, pd);
317 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
318
319
320 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
321
322 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_FONT;
323 efl_text_font_set(pd->rp->object, font, size);
324}
325
326EOLIAN static void
327_efl_canvas_layout_part_text_efl_text_font_font_get(const Eo *obj,
328 void *_pd EINA_UNUSED, const char **font, Efl_Font_Size *size)
329{
330 PROXY_DATA_GET(obj, pd);
331 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
332
333 efl_text_font_get(pd->rp->object, font, size);
334}
335
336EOLIAN static void
337_efl_canvas_layout_part_text_efl_text_style_shadow_direction_set(Eo *obj,
338 void *_pd EINA_UNUSED,
339 Efl_Text_Style_Shadow_Direction type)
340{
341 Edje_User_Defined *eud;
342
343 PROXY_DATA_GET(obj, pd);
344 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
345
346 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
347
348 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_SHADOW_DIRECTION;
349 efl_text_shadow_direction_set(pd->rp->object, type);
350}
351
352EOLIAN static void
353_efl_canvas_layout_part_text_efl_text_style_strikethrough_type_set(Eo *obj,
354 void *_pd EINA_UNUSED,
355 Efl_Text_Style_Strikethrough_Type type)
356{
357 Edje_User_Defined *eud;
358
359 PROXY_DATA_GET(obj, pd);
360 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
361
362 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
363
364 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE;
365 efl_text_strikethrough_type_set(pd->rp->object, type);
366}
367
368EOLIAN static void
369_efl_canvas_layout_part_text_efl_text_style_underline_type_set(Eo *obj,
370 void *_pd EINA_UNUSED,
371 Efl_Text_Style_Underline_Type type)
372{
373 Edje_User_Defined *eud;
374
375 PROXY_DATA_GET(obj, pd);
376 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
377
378
379 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
380
381 eud->u.text_style.types = EDJE_PART_TEXT_PROP_UNDERLINE_TYPE;
382 efl_text_underline_type_set(pd->rp->object, type);
383}
384
385EOLIAN static void
386_efl_canvas_layout_part_text_efl_text_style_underline_height_set(Eo *obj,
387 void *_pd EINA_UNUSED,
388 double value)
389{
390 Edje_User_Defined *eud;
391
392 PROXY_DATA_GET(obj, pd);
393 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
394
395 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
396
397 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT;
398 efl_text_underline_height_set(pd->rp->object, value);
399}
400
401EOLIAN static void
402_efl_canvas_layout_part_text_efl_text_style_underline_dashed_width_set(Eo *obj,
403 void *_pd EINA_UNUSED,
404 int value)
405{
406 Edje_User_Defined *eud;
407
408 PROXY_DATA_GET(obj, pd);
409 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
410
411 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
412
413 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH;
414 efl_text_underline_dashed_width_set(pd->rp->object, value);
415}
416
417EOLIAN static void
418_efl_canvas_layout_part_text_efl_text_style_underline_dashed_gap_set(Eo *obj,
419 void *_pd EINA_UNUSED,
420 int value)
421{
422 Edje_User_Defined *eud;
423
424 PROXY_DATA_GET(obj, pd);
425 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
426
427 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
428
429 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP;
430 efl_text_underline_dashed_gap_set(pd->rp->object, value);
431}
432
433EOLIAN static void
434_efl_canvas_layout_part_text_efl_text_format_wrap_set(Eo *obj,
435 void *_pd EINA_UNUSED, Efl_Text_Format_Wrap wrap)
436{
437 Edje_User_Defined *eud;
438
439 PROXY_DATA_GET(obj, pd);
440 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
441
442 eud = _edje_user_text_style_definition_fetch(pd->ed, pd->part);
443
444 eud->u.text_style.types |= EDJE_PART_TEXT_PROP_WRAP;
445 efl_text_wrap_set(pd->rp->object, wrap);
446}
447
448EOLIAN static Efl_Text_Format_Wrap
449_efl_canvas_layout_part_text_efl_text_format_wrap_get(const Eo *obj,
450 void *_pd EINA_UNUSED)
451{
452 PROXY_DATA_GET(obj, pd);
453
454 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT)
455 return EFL_TEXT_FORMAT_WRAP_NONE;
456
457 return efl_text_wrap_get(pd->rp->object);
458}
459
460static Edje_Part_Text_Prop *
461_prop_new(Eina_List **props, Edje_Part_Text_Prop_Type type)
462{
463 Edje_Part_Text_Prop *prop;
464
465 prop = malloc(sizeof(*prop));
466 prop->type = type;
467
468 *props = eina_list_append(*props, prop);
469
470 return prop;
471}
472
473void
474_canvas_layout_user_text_collect(Edje *ed, Edje_User_Defined *eud)
475{
476 Edje_Real_Part *rp;
477 Eina_List **props = &eud->u.text_style.props;
478
479 rp = _edje_real_part_recursive_get(&ed, eud->part);
480 if (eud->u.text_style.types == EDJE_PART_TEXT_PROP_NONE) return;
481
482 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_BACKING_TYPE)
483 {
484 Edje_Part_Text_Prop *prop;
485
486 prop = _prop_new(props, EDJE_PART_TEXT_PROP_BACKING_TYPE);
487 prop->val.backing = efl_text_backing_type_get(rp->object);
488 }
489#define STYLE_COLOR_COLLECT(x, X) \
490 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_COLOR_ ##X) \
491 { \
492 Edje_Part_Text_Prop *prop; \
493 prop = _prop_new(props, EDJE_PART_TEXT_PROP_COLOR_ ##X); \
494 efl_text_ ##x ##_color_get(rp->object, \
495 &prop->val.color.r, &prop->val.color.g, \
496 &prop->val.color.b, &prop->val.color.a); \
497 } \
498
499 STYLE_COLOR_COLLECT(backing, BACKING)
500 STYLE_COLOR_COLLECT(glow, GLOW)
501 STYLE_COLOR_COLLECT(glow2, GLOW2)
502 STYLE_COLOR_COLLECT(normal, NORMAL)
503 STYLE_COLOR_COLLECT(outline, OUTLINE)
504 STYLE_COLOR_COLLECT(shadow, SHADOW)
505 STYLE_COLOR_COLLECT(strikethrough, STRIKETHROUGH)
506 STYLE_COLOR_COLLECT(underline, UNDERLINE)
507 STYLE_COLOR_COLLECT(underline2, UNDERLINE2)
508 STYLE_COLOR_COLLECT(underline_dashed, UNDERLINE_DASHED)
509#undef STYLE_COLOR_COLLECT
510
511 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_EFFECT_TYPE)
512 {
513 Edje_Part_Text_Prop *prop;
514
515 prop = _prop_new(props, EDJE_PART_TEXT_PROP_EFFECT_TYPE);
516 prop->val.effect = efl_text_effect_type_get(rp->object);
517 }
518
519 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_ELLIPSIS)
520 {
521 Edje_Part_Text_Prop *prop;
522
523 prop = _prop_new(props, EDJE_PART_TEXT_PROP_ELLIPSIS);
524 prop->val.nd = efl_text_ellipsis_get(rp->object);
525 }
526
527 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_FONT)
528 {
529 Edje_Part_Text_Prop *prop;
530
531 prop = _prop_new(props, EDJE_PART_TEXT_PROP_FONT);
532 efl_text_font_get(rp->object, &prop->val.font.font,
533 &prop->val.font.size);
534 }
535
536 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_SHADOW_DIRECTION)
537 {
538 Edje_Part_Text_Prop *prop;
539
540 prop = _prop_new(props, EDJE_PART_TEXT_PROP_SHADOW_DIRECTION);
541 prop->val.shadow = efl_text_shadow_direction_get(rp->object);
542 }
543
544 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE)
545 {
546 Edje_Part_Text_Prop *prop;
547
548 prop = _prop_new(props, EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE);
549 prop->val.strikethrough_type = efl_text_strikethrough_type_get(rp->object);
550 }
551
552 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP)
553 {
554 Edje_Part_Text_Prop *prop;
555
556 prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP);
557 prop->val.ni = efl_text_underline_dashed_gap_get(rp->object);
558 }
559
560 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH)
561 {
562 Edje_Part_Text_Prop *prop;
563
564 prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH);
565 prop->val.ni = efl_text_underline_dashed_width_get(rp->object);
566 }
567
568 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_TYPE)
569 {
570 Edje_Part_Text_Prop *prop;
571
572 prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_TYPE);
573 prop->val.ni = efl_text_underline_type_get(rp->object);
574 }
575
576 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT)
577 {
578 Edje_Part_Text_Prop *prop;
579
580 prop = _prop_new(props, EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT);
581 prop->val.ni = efl_text_underline_height_get(rp->object);
582 }
583
584 if (eud->u.text_style.types & EDJE_PART_TEXT_PROP_WRAP)
585 {
586 Edje_Part_Text_Prop *prop;
587
588 prop = _prop_new(props, EDJE_PART_TEXT_PROP_WRAP);
589 prop->val.wrap = efl_text_wrap_get(rp->object);
590
591 }
592}
593
594void
595_canvas_layout_user_text_apply(Edje_User_Defined *eud, Eo *obj,
596 Edje_Part_Text_Prop *prop)
597{
598 switch (prop->type)
599 {
600
601 case EDJE_PART_TEXT_PROP_BACKING_TYPE:
602 efl_text_backing_type_set(
603 efl_part(obj,
604 eud->part),
605 prop->val.backing);
606 break;
607
608#define STYLE_COLOR_CASE(x, X) \
609 case EDJE_PART_TEXT_PROP_COLOR_##X : \
610 efl_text_##x ##_color_set(efl_part(obj, \
611 eud->part), \
612 prop->val.color.r, \
613 prop->val.color.g, \
614 prop->val.color.b, \
615 prop->val.color.a); \
616 break;
617
618 STYLE_COLOR_CASE(backing, BACKING)
619 STYLE_COLOR_CASE(glow, GLOW)
620 STYLE_COLOR_CASE(glow2, GLOW2)
621 STYLE_COLOR_CASE(normal, NORMAL)
622 STYLE_COLOR_CASE(outline, OUTLINE)
623 STYLE_COLOR_CASE(shadow, SHADOW)
624 STYLE_COLOR_CASE(strikethrough, STRIKETHROUGH)
625 STYLE_COLOR_CASE(underline, UNDERLINE)
626 STYLE_COLOR_CASE(underline2, UNDERLINE2)
627 STYLE_COLOR_CASE(underline_dashed, UNDERLINE_DASHED)
628#undef STYLE_COLOR_CASE
629
630 case EDJE_PART_TEXT_PROP_EFFECT_TYPE:
631 efl_text_effect_type_set(
632 efl_part(obj,
633 eud->part),
634 prop->val.effect);
635 break;
636
637 case EDJE_PART_TEXT_PROP_ELLIPSIS:
638 efl_text_ellipsis_set(efl_part(obj,
639 eud->part),
640 prop->val.nd);
641 break;
642
643 case EDJE_PART_TEXT_PROP_FONT:
644 efl_text_font_set(efl_part(obj,
645 eud->part),
646 prop->val.font.font,
647 prop->val.font.size);
648 break;
649
650 case EDJE_PART_TEXT_PROP_SHADOW_DIRECTION:
651 efl_text_shadow_direction_set(
652 efl_part(obj,
653 eud->part),
654 prop->val.shadow);
655 break;
656
657 case EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE:
658 efl_text_strikethrough_type_set(
659 efl_part(obj,
660 eud->part),
661 prop->val.strikethrough_type);
662 break;
663
664 case EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH:
665 efl_text_underline_dashed_width_set(
666 efl_part(obj,
667 eud->part),
668 prop->val.ni);
669 break;
670
671 case EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP:
672 efl_text_underline_dashed_gap_set(
673 efl_part(obj,
674 eud->part),
675 prop->val.ni);
676 break;
677
678 case EDJE_PART_TEXT_PROP_UNDERLINE_TYPE:
679 efl_text_underline_type_set(
680 efl_part(obj,
681 eud->part),
682 prop->val.underline_type);
683 break;
684
685 case EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT:
686 efl_text_underline_height_set(
687 efl_part(obj,
688 eud->part),
689 prop->val.nd);
690 break;
691
692 case EDJE_PART_TEXT_PROP_WRAP:
693 efl_text_wrap_set(efl_part(obj,
694 eud->part),
695 prop->val.wrap);
696 break;
697
698 default:
699 break;
700 }
701}
702
703
704EOLIAN static void
705_efl_canvas_layout_part_text_text_expand_set(Eo *obj,
706 void *_pd EINA_UNUSED,
707 Efl_Canvas_Layout_Part_Text_Expand type)
708{
709 Edje_User_Defined *eud;
710
711 PROXY_DATA_GET(obj, pd);
712 if (pd->rp->part->type == EDJE_PART_TYPE_TEXT) return;
713
714 eud = _edje_user_text_expand_definition_fetch(pd->ed, pd->part);
715 eud->u.text_expand.expand = type;
716 pd->rp->typedata.text->expand = type;
717
718}
719
720EOLIAN static Efl_Canvas_Layout_Part_Text_Expand
721_efl_canvas_layout_part_text_text_expand_get(const Eo *obj,
722 void *_pd EINA_UNUSED)
723{
724 PROXY_DATA_GET(obj, pd);
725 return pd->rp->typedata.text->expand;
726}
727
200#include "efl_canvas_layout_part_text.eo.c" 728#include "efl_canvas_layout_part_text.eo.c"
201 729
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 2c12ea6a51..2b0d538ebb 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -1974,6 +1974,7 @@ struct _Edje_Real_Part_Text
1974 const char *style; // 4 1974 const char *style; // 4
1975 Edje_Position offset; // 8 1975 Edje_Position offset; // 8
1976 short size; // 2 1976 short size; // 2
1977 Efl_Canvas_Layout_Part_Text_Expand expand;
1977 struct { 1978 struct {
1978 unsigned char fit_x, fit_y; // 2 1979 unsigned char fit_x, fit_y; // 2
1979 short in_size; // 2 1980 short in_size; // 2
@@ -2252,6 +2253,58 @@ struct _Edje_Patterns
2252 unsigned int finals[]; 2253 unsigned int finals[];
2253}; 2254};
2254 2255
2256typedef enum
2257{
2258 EDJE_PART_TEXT_PROP_NONE = 0, // never used
2259 EDJE_PART_TEXT_PROP_BACKING_TYPE = 1,
2260 EDJE_PART_TEXT_PROP_COLOR_BACKING = 1 << 2,
2261 EDJE_PART_TEXT_PROP_COLOR_GLOW = 1 << 3,
2262 EDJE_PART_TEXT_PROP_COLOR_GLOW2 = 1 << 4,
2263 EDJE_PART_TEXT_PROP_COLOR_NORMAL = 1 << 5,
2264 EDJE_PART_TEXT_PROP_COLOR_OUTLINE = 1 << 6,
2265 EDJE_PART_TEXT_PROP_COLOR_SHADOW = 1 << 7,
2266 EDJE_PART_TEXT_PROP_COLOR_STRIKETHROUGH = 1 << 8,
2267 EDJE_PART_TEXT_PROP_COLOR_UNDERLINE = 1 << 9,
2268 EDJE_PART_TEXT_PROP_COLOR_UNDERLINE2 = 1 << 10,
2269 EDJE_PART_TEXT_PROP_COLOR_UNDERLINE_DASHED = 1 << 11,
2270 EDJE_PART_TEXT_PROP_EFFECT_TYPE = 1 << 12,
2271 EDJE_PART_TEXT_PROP_ELLIPSIS = 1 << 13,
2272 EDJE_PART_TEXT_PROP_FONT = 1 << 14,
2273 EDJE_PART_TEXT_PROP_SHADOW_DIRECTION = 1 << 15,
2274 EDJE_PART_TEXT_PROP_STRIKETHROUGH_TYPE = 1 << 16,
2275 EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_GAP = 1 << 17,
2276 EDJE_PART_TEXT_PROP_UNDERLINE_DASHED_WIDTH = 1 << 18,
2277 EDJE_PART_TEXT_PROP_UNDERLINE_TYPE = 1 << 19,
2278 EDJE_PART_TEXT_PROP_UNDERLINE_HEIGHT = 1 << 20,
2279 EDJE_PART_TEXT_PROP_WRAP = 1 << 21
2280} Edje_Part_Text_Prop_Type;
2281
2282typedef struct
2283{
2284 Edje_Part_Text_Prop_Type type;
2285 union
2286 {
2287 int ni; // number integer
2288 int nd; // number double
2289 Efl_Text_Format_Wrap wrap;
2290 Efl_Text_Style_Backing_Type backing;
2291 Efl_Text_Style_Underline_Type underline;
2292 struct
2293 {
2294 unsigned char r, g, b, a;
2295 } color;
2296 struct
2297 {
2298 const char *font;
2299 Efl_Font_Size size;
2300 } font;
2301 Efl_Text_Style_Effect_Type effect;
2302 Efl_Text_Style_Shadow_Direction shadow;
2303 Efl_Text_Style_Strikethrough_Type strikethrough_type;
2304 Efl_Text_Style_Underline_Type underline_type;
2305 } val;
2306} Edje_Part_Text_Prop;
2307
2255typedef enum _Edje_User_Defined_Type 2308typedef enum _Edje_User_Defined_Type
2256{ 2309{
2257 EDJE_USER_SWALLOW, 2310 EDJE_USER_SWALLOW,
@@ -2261,7 +2314,9 @@ typedef enum _Edje_User_Defined_Type
2261 EDJE_USER_DRAG_STEP, 2314 EDJE_USER_DRAG_STEP,
2262 EDJE_USER_DRAG_PAGE, 2315 EDJE_USER_DRAG_PAGE,
2263 EDJE_USER_DRAG_VALUE, 2316 EDJE_USER_DRAG_VALUE,
2264 EDJE_USER_DRAG_SIZE 2317 EDJE_USER_DRAG_SIZE,
2318 EDJE_USER_TEXT_STYLE,
2319 EDJE_USER_TEXT_EXPAND,
2265} Edje_User_Defined_Type; 2320} Edje_User_Defined_Type;
2266 2321
2267typedef struct _Edje_User_Defined Edje_User_Defined; 2322typedef struct _Edje_User_Defined Edje_User_Defined;
@@ -2296,6 +2351,13 @@ struct _Edje_User_Defined
2296 struct { 2351 struct {
2297 double w, h; 2352 double w, h;
2298 } drag_size; 2353 } drag_size;
2354 struct {
2355 Eina_List *props;
2356 Edje_Part_Text_Prop_Type types;
2357 } text_style;
2358 struct {
2359 Efl_Canvas_Layout_Part_Text_Expand expand;
2360 } text_expand;
2299 } u; 2361 } u;
2300}; 2362};
2301 2363
@@ -2973,9 +3035,15 @@ Eina_Bool _edje_multisense_internal_vibration_sample_play(Edje *ed, const char *
2973 3035
2974void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state); 3036void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);
2975 3037
3038Edje_User_Defined * _edje_user_definition_fetch(Edje *ed, const char *part, Edje_User_Defined_Type type);
3039Edje_User_Defined * _edje_user_text_style_definition_fetch(Edje *ed, const char *part);
3040Edje_User_Defined * _edje_user_text_expand_definition_fetch(Edje *ed, const char *part);
2976void _edje_user_definition_remove(Edje_User_Defined *eud, Evas_Object *child); 3041void _edje_user_definition_remove(Edje_User_Defined *eud, Evas_Object *child);
2977void _edje_user_definition_free(Edje_User_Defined *eud); 3042void _edje_user_definition_free(Edje_User_Defined *eud);
2978 3043
3044void _canvas_layout_user_text_apply(Edje_User_Defined *eud, Eo *obj, Edje_Part_Text_Prop *prop);
3045void _canvas_layout_user_text_collect(Edje *ed, Edje_User_Defined *eud);
3046
2979extern Efl_Observable *_edje_color_class_member; 3047extern Efl_Observable *_edje_color_class_member;
2980extern Efl_Observable *_edje_text_class_member; 3048extern Efl_Observable *_edje_text_class_member;
2981extern Efl_Observable *_edje_size_class_member; 3049extern Efl_Observable *_edje_size_class_member;
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index 9b9f17cc25..800a86636f 100644
--- a/src/lib/edje/edje_textblock.c
+++ b/src/lib/edje/edje_textblock.c
@@ -35,14 +35,30 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
35 int *maxw, int *maxh) 35 int *maxw, int *maxh)
36{ 36{
37 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 37 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
38 unsigned char minx2 = 0, miny2 = 0, maxx2 = 0, maxy2 = 0;
39
40 minx2 = chosen_desc->text.min_x;
41 miny2 = chosen_desc->text.min_y;
42 maxx2 = chosen_desc->text.max_x;
43 maxy2 = chosen_desc->text.max_y;
44
45 // Do not use size from new api if min/max are non-zero in the theme
46 if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
47 !chosen_desc->text.max_x && !chosen_desc->text.max_y)
48 {
49 minx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
50 miny2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
51 maxx2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
52 maxy2 = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
53 }
38 54
39 /* Legacy code for Textblock min/max calculation */ 55 /* Legacy code for Textblock min/max calculation */
40 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 56 if (minx2 || miny2)
41 { 57 {
42 int mw = 0, mh = 0; 58 int mw = 0, mh = 0;
43 59
44 tw = th = 0; 60 tw = th = 0;
45 if (!chosen_desc->text.min_x) 61 if (!minx2)
46 { 62 {
47 efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h))); 63 efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
48 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 64 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
@@ -53,22 +69,22 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
53 &ins_r, &ins_t, &ins_b); 69 &ins_r, &ins_t, &ins_b);
54 mw = ins_l + tw + ins_r; 70 mw = ins_l + tw + ins_r;
55 mh = ins_t + th + ins_b; 71 mh = ins_t + th + ins_b;
56 if (minw && chosen_desc->text.min_x) 72 if (minw && minx2)
57 { 73 {
58 if (mw > *minw) *minw = mw; 74 if (mw > *minw) *minw = mw;
59 } 75 }
60 if (minh && chosen_desc->text.min_y) 76 if (minh && miny2)
61 { 77 {
62 if (mh > *minh) *minh = mh; 78 if (mh > *minh) *minh = mh;
63 } 79 }
64 } 80 }
65 81
66 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) 82 if ((maxx2) || (maxy2))
67 { 83 {
68 int mw = 0, mh = 0; 84 int mw = 0, mh = 0;
69 85
70 tw = th = 0; 86 tw = th = 0;
71 if (!chosen_desc->text.max_x) 87 if (!maxx2)
72 { 88 {
73 efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h))); 89 efl_gfx_entity_size_set(ep->object, EINA_SIZE2D(TO_INT(params->eval.w), TO_INT(params->eval.h)));
74 efl_canvas_text_size_formatted_get(ep->object, &tw, &th); 90 efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
@@ -79,12 +95,12 @@ _edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
79 &ins_t, &ins_b); 95 &ins_t, &ins_b);
80 mw = ins_l + tw + ins_r; 96 mw = ins_l + tw + ins_r;
81 mh = ins_t + th + ins_b; 97 mh = ins_t + th + ins_b;
82 if (maxw && chosen_desc->text.max_x) 98 if (maxw && maxx2)
83 { 99 {
84 if (mw > *maxw) *maxw = mw; 100 if (mw > *maxw) *maxw = mw;
85 if (minw && (*maxw < *minw)) *maxw = *minw; 101 if (minw && (*maxw < *minw)) *maxw = *minw;
86 } 102 }
87 if (maxh && chosen_desc->text.max_y) 103 if (maxh && maxy2)
88 { 104 {
89 if (mh > *maxh) *maxh = mh; 105 if (mh > *maxh) *maxh = mh;
90 if (minh && (*maxh < *minh)) *maxh = *minh; 106 if (minh && (*maxh < *minh)) *maxh = *minh;
@@ -102,18 +118,35 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
102 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; 118 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
103 Evas_Coord min_calc_w = 0, min_calc_h = 0; 119 Evas_Coord min_calc_w = 0, min_calc_h = 0;
104 120
121 unsigned char dminx, dminy, dmaxx, dmaxy;
122
123 dminx = chosen_desc->text.min_x;
124 dminy = chosen_desc->text.min_y;
125 dmaxx = chosen_desc->text.max_x;
126 dmaxy = chosen_desc->text.max_y;
127
128 // Do not use size from new api if min/max are non-zero in the theme
129 if (!chosen_desc->text.min_x && !chosen_desc->text.min_y &&
130 !chosen_desc->text.max_x && !chosen_desc->text.max_y)
131 {
132 dminx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_X;
133 dminy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MIN_Y;
134 dmaxx = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_X;
135 dmaxy = ep->typedata.text->expand & EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_MAX_Y;
136 }
137
105 /* min_calc_* values need to save calculated minumum size 138 /* min_calc_* values need to save calculated minumum size
106 * for maximum size calculation */ 139 * for maximum size calculation */
107 if (minw) min_calc_w = *minw; 140 if (minw) min_calc_w = *minw;
108 if (minh) min_calc_h = *minh; 141 if (minh) min_calc_h = *minh;
109 142
110 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) 143 if (dminx || dminy)
111 { 144 {
112 evas_object_textblock_style_insets_get(ep->object, &ins_l, 145 evas_object_textblock_style_insets_get(ep->object, &ins_l,
113 &ins_r, &ins_t, &ins_b); 146 &ins_r, &ins_t, &ins_b);
114 147
115 tw = th = 0; 148 tw = th = 0;
116 if (!chosen_desc->text.min_x) 149 if (!dminx)
117 { 150 {
118 /* text.min: 0 1 151 /* text.min: 0 1
119 * text.max: X X */ 152 * text.max: X X */
@@ -122,11 +155,11 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
122 155
123 if (min_calc_w > temp_w) 156 if (min_calc_w > temp_w)
124 temp_w = min_calc_w; 157 temp_w = min_calc_w;
125 if ((!chosen_desc->text.max_x) && 158 if ((!dmaxx) &&
126 maxw && (*maxw > -1) && (*maxw < temp_w)) 159 maxw && (*maxw > -1) && (*maxw < temp_w))
127 temp_w = *maxw; 160 temp_w = *maxw;
128 161
129 if (chosen_desc->text.max_y) 162 if (dmaxy)
130 { 163 {
131 /* text.min: 0 1 164 /* text.min: 0 1
132 * text.max: X 1 */ 165 * text.max: X 1 */
@@ -161,7 +194,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
161 { 194 {
162 /* text.min: 1 X 195 /* text.min: 1 X
163 * text.max: X X */ 196 * text.max: X X */
164 if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) && 197 if (dminy && (!dmaxx) &&
165 maxw && (*maxw > -1)) 198 maxw && (*maxw > -1))
166 { 199 {
167 /* text.min: 1 1 200 /* text.min: 1 1
@@ -174,7 +207,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
174 if (min_calc_w > temp_w) 207 if (min_calc_w > temp_w)
175 temp_w = min_calc_w; 208 temp_w = min_calc_w;
176 209
177 if ((!chosen_desc->text.max_y) && maxh && (*maxh > -1)) 210 if ((!dmaxy) && maxh && (*maxh > -1))
178 { 211 {
179 /* text.min: 1 1 212 /* text.min: 1 1
180 * text.max: 0 0 213 * text.max: 0 0
@@ -210,7 +243,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
210 tw += ins_l + ins_r; 243 tw += ins_l + ins_r;
211 th += ins_t + ins_b; 244 th += ins_t + ins_b;
212 245
213 if (!chosen_desc->text.max_x && 246 if (!dmaxx &&
214 (maxw && (*maxw > -1) && (*maxw < tw))) 247 (maxw && (*maxw > -1) && (*maxw < tw)))
215 { 248 {
216 /* text.min: 1 0 249 /* text.min: 1 0
@@ -222,23 +255,23 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
222 255
223 if (tw > min_calc_w) min_calc_w = tw; 256 if (tw > min_calc_w) min_calc_w = tw;
224 if (th > min_calc_h) min_calc_h = th; 257 if (th > min_calc_h) min_calc_h = th;
225 if (chosen_desc->text.min_x && minw) *minw = min_calc_w; 258 if (dminx && minw) *minw = min_calc_w;
226 if (chosen_desc->text.min_y && minh) *minh = min_calc_h; 259 if (dminy && minh) *minh = min_calc_h;
227 } 260 }
228 261
229 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) 262 if ((dmaxx) || (dmaxy))
230 { 263 {
231 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, 264 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
232 &ins_t, &ins_b); 265 &ins_t, &ins_b);
233 266
234 tw = th = 0; 267 tw = th = 0;
235 if (!chosen_desc->text.max_x) 268 if (!dmaxx)
236 { 269 {
237 /* text.min: X X 270 /* text.min: X X
238 * text.max: 0 1 */ 271 * text.max: 0 1 */
239 int temp_w, temp_h; 272 int temp_w, temp_h;
240 273
241 if (chosen_desc->text.min_y) 274 if (dminy)
242 { 275 {
243 /* text.min: X 1 276 /* text.min: X 1
244 * text.max: 0 1 277 * text.max: 0 1
@@ -284,7 +317,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
284 else 317 else
285 { 318 {
286 /* text.max: 1 X */ 319 /* text.max: 1 X */
287 if (chosen_desc->text.min_x) 320 if (dminx)
288 { 321 {
289 /* text.min: 1 X 322 /* text.min: 1 X
290 * text.max: 1 X 323 * text.max: 1 X
@@ -298,7 +331,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
298 { 331 {
299 /* text.min: 0 X 332 /* text.min: 0 X
300 * text.max: 1 X */ 333 * text.max: 1 X */
301 if (chosen_desc->text.max_y) 334 if (dmaxy)
302 { 335 {
303 /* text.min: 0 X 336 /* text.min: 0 X
304 * text.max: 1 1 */ 337 * text.max: 1 1 */
@@ -312,7 +345,7 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
312 if (min_calc_h > temp_h) 345 if (min_calc_h > temp_h)
313 temp_h = min_calc_h; 346 temp_h = min_calc_h;
314 347
315 if (chosen_desc->text.min_y) 348 if (dminy)
316 { 349 {
317 /* text.min: 0 1 350 /* text.min: 0 1
318 * text.max: 1 1 351 * text.max: 1 1
@@ -370,12 +403,12 @@ _edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
370 } 403 }
371 } 404 }
372 405
373 if (maxw && chosen_desc->text.max_x) 406 if (maxw && dmaxx)
374 { 407 {
375 if (tw > *maxw) *maxw = tw; 408 if (tw > *maxw) *maxw = tw;
376 if (minw && (*maxw < *minw)) *maxw = *minw; 409 if (minw && (*maxw < *minw)) *maxw = *minw;
377 } 410 }
378 if (maxh && chosen_desc->text.max_y) 411 if (maxh && dmaxy)
379 { 412 {
380 if (th > *maxh) *maxh = th; 413 if (th > *maxh) *maxh = th;
381 if (minh && (*maxh < *minh)) *maxh = *minh; 414 if (minh && (*maxh < *minh)) *maxh = *minh;
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 7ab54bb4bd..8c5af161a6 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -136,6 +136,16 @@ _edje_user_definition_free(Edje_User_Defined *eud)
136 if (rp) _edje_child_remove(eud->ed, rp, child); 136 if (rp) _edje_child_remove(eud->ed, rp, child);
137 break; 137 break;
138 138
139 case EDJE_USER_TEXT_STYLE:
140 {
141 Edje_Part_Text_Prop *prop;
142 EINA_LIST_FREE(eud->u.text_style.props, prop)
143 {
144 free(prop);
145 }
146 break;
147 }
148
139 case EDJE_USER_STRING: 149 case EDJE_USER_STRING:
140 case EDJE_USER_DRAG_STEP: 150 case EDJE_USER_DRAG_STEP:
141 case EDJE_USER_DRAG_PAGE: 151 case EDJE_USER_DRAG_PAGE:
@@ -1993,6 +2003,71 @@ _edje_object_part_text_raw_set(Edje *ed, Evas_Object *obj, Edje_Real_Part *rp, c
1993 EINA_FALSE, EINA_TRUE); 2003 EINA_FALSE, EINA_TRUE);
1994} 2004}
1995 2005
2006Edje_User_Defined *
2007_edje_user_definition_fetch(Edje *ed,
2008 const char *part, Edje_User_Defined_Type type)
2009{
2010 Edje_User_Defined *eud;
2011 Eina_List *l;
2012
2013 EINA_LIST_FOREACH(ed->user_defined, l, eud)
2014 {
2015 if (eud->type == type && !strcmp(eud->part, part))
2016 {
2017 return eud;
2018 }
2019 }
2020 eud = _edje_user_definition_new(type, part, ed);
2021 return eud;
2022}
2023
2024Edje_User_Defined *
2025_edje_user_text_style_definition_fetch(Edje *ed, const char *part)
2026{
2027 Edje_User_Defined *eud;
2028 Eina_List *l;
2029
2030 EINA_LIST_FOREACH(ed->user_defined, l, eud)
2031 {
2032 if (eud->type == EDJE_USER_TEXT_STYLE && !strcmp(eud->part, part))
2033 {
2034 break;
2035 }
2036 }
2037
2038 if (!eud)
2039 {
2040 eud = _edje_user_definition_new(EDJE_USER_TEXT_STYLE, part, ed);
2041 eud->u.text_style.types = EDJE_PART_TEXT_PROP_NONE;
2042 eud->u.text_style.props = NULL;
2043 }
2044
2045 return eud;
2046}
2047
2048Edje_User_Defined *
2049_edje_user_text_expand_definition_fetch(Edje *ed, const char *part)
2050{
2051 Edje_User_Defined *eud;
2052 Eina_List *l;
2053
2054 EINA_LIST_FOREACH(ed->user_defined, l, eud)
2055 {
2056 if (eud->type == EDJE_USER_TEXT_EXPAND && !strcmp(eud->part, part))
2057 {
2058 break;
2059 }
2060 }
2061
2062 if (!eud)
2063 {
2064 eud = _edje_user_definition_new(EDJE_USER_TEXT_EXPAND, part, ed);
2065 eud->u.text_expand.expand = EFL_CANVAS_LAYOUT_PART_TEXT_EXPAND_NONE;
2066 }
2067
2068 return eud;
2069}
2070
1996void 2071void
1997_edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type) 2072_edje_user_define_string(Edje *ed, const char *part, const char *raw_text, Edje_Text_Type type)
1998{ 2073{
diff --git a/src/lib/edje/efl_canvas_layout_part_text.eo b/src/lib/edje/efl_canvas_layout_part_text.eo
index b59f470a5b..4ea5d32349 100644
--- a/src/lib/edje/efl_canvas_layout_part_text.eo
+++ b/src/lib/edje/efl_canvas_layout_part_text.eo
@@ -1,11 +1,38 @@
1enum Efl.Canvas.Layout_Part_Text_Expand
2{
3 [[Text layout policy to enforce. If none is set, min/max descriptions
4 are taken in considerations solely.
5 ]]
6 none = 0, [[No policy. Use default description parameters.]]
7 min_x = 1,
8 min_y = 1 << 1,
9 max_x = 1 << 2,
10 max_y = 1 << 3,
11}
12
1class Efl.Canvas.Layout_Part_Text (Efl.Canvas.Layout_Part, Efl.Text, 13class Efl.Canvas.Layout_Part_Text (Efl.Canvas.Layout_Part, Efl.Text,
2Efl.Text_Markup, Efl.Text_Cursor) 14Efl.Text_Markup, Efl.Text_Cursor, Efl.Text_Format, Efl.Text_Font,
15Efl.Text_Style)
3{ 16{
4 [[Represents a TEXT part of a layout 17 [[Represents a TEXT part of a layout
5 18
6 Its lifetime is limited to one function call only, unless an extra 19 Its lifetime is limited to one function call only, unless an extra
7 reference is explicitly held. 20 reference is explicitly held.
8 ]] 21 ]]
22 methods {
23 @property text_expand {
24 [[Sizing policy for text parts.
25
26 This will determine whether to consider height or width
27 constraints, if text-specific behaviors occur (such as ellipsis,
28 line-wrapping etc.
29 ]]
30 values {
31 type: Efl.Canvas.Layout_Part_Text_Expand;
32 }
33 }
34
35 }
9 data: null; 36 data: null;
10 implements { 37 implements {
11 Efl.Text.text { set; get; } 38 Efl.Text.text { set; get; }
@@ -24,5 +51,26 @@ Efl.Text_Markup, Efl.Text_Cursor)
24 Efl.Text_Cursor.cursor_content { get; } 51 Efl.Text_Cursor.cursor_content { get; }
25 Efl.Text_Cursor.cursor_geometry { get; } 52 Efl.Text_Cursor.cursor_geometry { get; }
26 Efl.Text_Markup.cursor_markup_insert; 53 Efl.Text_Markup.cursor_markup_insert;
54 Efl.Text_Format.ellipsis { set; get; }
55 Efl.Text_Format.wrap { set; get; }
56 Efl.Text_Font.font { set; get; }
57 Efl.Text_Style.normal_color { set; get; }
58 Efl.Text_Style.backing_type { set; get; }
59 Efl.Text_Style.backing_color { set; get;}
60 Efl.Text_Style.underline_type { set; }
61 Efl.Text_Style.underline_color { set; get; }
62 Efl.Text_Style.underline2_color { set; get; }
63 Efl.Text_Style.underline_dashed_color { set; get; }
64 Efl.Text_Style.underline_height { set; }
65 Efl.Text_Style.underline_dashed_width { set; }
66 Efl.Text_Style.underline_dashed_gap { set; }
67 Efl.Text_Style.strikethrough_type { set; }
68 Efl.Text_Style.strikethrough_color { set; get; }
69 Efl.Text_Style.effect_type { set; }
70 Efl.Text_Style.shadow_direction { set; }
71 Efl.Text_Style.outline_color { set; get; }
72 Efl.Text_Style.shadow_color { set; get; }
73 Efl.Text_Style.glow_color { set; get; }
74 Efl.Text_Style.glow2_color { set; get; }
27 } 75 }
28} 76}
diff --git a/src/lib/efl/interfaces/efl_text_style.eo b/src/lib/efl/interfaces/efl_text_style.eo
index 395609626c..99552ac036 100644
--- a/src/lib/efl/interfaces/efl_text_style.eo
+++ b/src/lib/efl/interfaces/efl_text_style.eo
@@ -153,15 +153,6 @@ interface Efl.Text_Style {
153 } 153 }
154 } 154 }
155 155
156 @property underline2_type
157 {
158 [[Type of underline2 style]]
159 values
160 {
161 type: Efl.Text_Style_Underline_Type; [[Underline type]]
162 }
163 }
164
165 @property underline2_color 156 @property underline2_color
166 { 157 {
167 [[Color of underline2 style]] 158 [[Color of underline2 style]]
diff --git a/src/lib/evas/canvas/efl_canvas_text.eo b/src/lib/evas/canvas/efl_canvas_text.eo
index b24139e34a..488e38f835 100644
--- a/src/lib/evas/canvas/efl_canvas_text.eo
+++ b/src/lib/evas/canvas/efl_canvas_text.eo
@@ -294,7 +294,6 @@ class Efl.Canvas.Text (Efl.Canvas.Object, Efl.Text,
294 Efl.Text_Style.underline_dashed_color { get; set; } 294 Efl.Text_Style.underline_dashed_color { get; set; }
295 Efl.Text_Style.underline_dashed_width { get; set; } 295 Efl.Text_Style.underline_dashed_width { get; set; }
296 Efl.Text_Style.underline_dashed_gap { get; set; } 296 Efl.Text_Style.underline_dashed_gap { get; set; }
297 Efl.Text_Style.underline2_type { get; set; }
298 Efl.Text_Style.underline2_color { get; set; } 297 Efl.Text_Style.underline2_color { get; set; }
299 Efl.Text_Style.strikethrough_type { get; set; } 298 Efl.Text_Style.strikethrough_type { get; set; }
300 Efl.Text_Style.strikethrough_color { get; set; } 299 Efl.Text_Style.strikethrough_color { get; set; }
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 89397d2bf6..3636c42875 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -15561,11 +15561,26 @@ _efl_canvas_text_efl_text_style_backing_color_get(const Eo *obj EINA_UNUSED, Efl
15561 _FMT_COLOR_RET(backing); 15561 _FMT_COLOR_RET(backing);
15562} 15562}
15563 15563
15564static struct
15565{
15566 Eina_Bool underline_single : 1;
15567 Eina_Bool underline_double : 1;
15568 Eina_Bool underline_dashed : 1;
15569} _style_underline_map[] = {
15570 { 0, 0, 0 },
15571 { 1, 0, 0 },
15572 { 1, 1, 0 },
15573 { 0, 0, 1 }
15574};
15575
15564static void 15576static void
15565_efl_canvas_text_efl_text_style_underline_type_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Style_Underline_Type type EINA_UNUSED) 15577_efl_canvas_text_efl_text_style_underline_type_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Style_Underline_Type type EINA_UNUSED)
15566{ 15578{
15567 ASYNC_BLOCK; 15579 ASYNC_BLOCK;
15568 _FMT_SET(underline, type); 15580 _FMT_SET(underline, _style_underline_map[type].underline_single);
15581 _FMT_SET(underline2, _style_underline_map[type].underline_double);
15582 _FMT_SET(underline_dash, _style_underline_map[type].underline_dashed);
15583
15569} 15584}
15570 15585
15571static Efl_Text_Style_Underline_Type 15586static Efl_Text_Style_Underline_Type
@@ -15640,19 +15655,6 @@ _efl_canvas_text_efl_text_style_underline_dashed_gap_get(const Eo *obj EINA_UNUS
15640} 15655}
15641 15656
15642static void 15657static void
15643_efl_canvas_text_efl_text_style_underline2_type_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, Efl_Text_Style_Underline_Type type EINA_UNUSED)
15644{
15645 ASYNC_BLOCK;
15646 _FMT_SET(underline2, type);
15647}
15648
15649static Efl_Text_Style_Underline_Type
15650_efl_canvas_text_efl_text_style_underline2_type_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED)
15651{
15652 return _FMT(underline2);
15653}
15654
15655static void
15656_efl_canvas_text_efl_text_style_underline2_color_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, unsigned char r EINA_UNUSED, unsigned char g EINA_UNUSED, unsigned char b EINA_UNUSED, unsigned char a EINA_UNUSED) 15658_efl_canvas_text_efl_text_style_underline2_color_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Data *o EINA_UNUSED, unsigned char r EINA_UNUSED, unsigned char g EINA_UNUSED, unsigned char b EINA_UNUSED, unsigned char a EINA_UNUSED)
15657{ 15659{
15658 ASYNC_BLOCK; 15660 ASYNC_BLOCK;
diff --git a/src/tests/edje/data/test_text.edc b/src/tests/edje/data/test_text.edc
new file mode 100644
index 0000000000..9395a2d4de
--- /dev/null
+++ b/src/tests/edje/data/test_text.edc
@@ -0,0 +1,41 @@
1collections {
2 styles {
3 style { name: "tbstyle";
4 base: "";
5 }
6 }
7 group { name: "test";
8 parts {
9 textblock { "text"; nomouse;
10 desc { "default";
11 rel1.relative: 0.0 0.0;
12 rel2.relative: 1.0 1.0;
13 text {
14 style: "tbstyle";
15 font: FN; size: 10;
16 align: 0.5 0.5;
17 min: 0 0;
18 }
19 visible: 1;
20 }
21 }
22 }
23 }
24 group { name: "test2";
25 parts {
26 textblock { "text"; nomouse;
27 desc { "default";
28 rel1.relative: 0.0 0.0;
29 rel2.relative: 1.0 1.0;
30 text {
31 style: "tbstyle";
32 font: FN; size: 10;
33 align: 0.5 0.5;
34 min: 0 0;
35 }
36 visible: 1;
37 }
38 }
39 }
40 }
41}
diff --git a/src/tests/edje/edje_suite.c b/src/tests/edje/edje_suite.c
index 80cb84a8f6..cac6982874 100644
--- a/src/tests/edje/edje_suite.c
+++ b/src/tests/edje/edje_suite.c
@@ -8,6 +8,7 @@
8 8
9static const Efl_Test_Case etc[] = { 9static const Efl_Test_Case etc[] = {
10 { "Edje", edje_test_edje }, 10 { "Edje", edje_test_edje },
11 { "Edje Text", edje_test_text },
11 { NULL, NULL } 12 { NULL, NULL }
12}; 13};
13 14
diff --git a/src/tests/edje/edje_suite.h b/src/tests/edje/edje_suite.h
index a6f1354fec..85574ed928 100644
--- a/src/tests/edje/edje_suite.h
+++ b/src/tests/edje/edje_suite.h
@@ -4,6 +4,7 @@
4#include <check.h> 4#include <check.h>
5#include "../efl_check.h" 5#include "../efl_check.h"
6void edje_test_edje(TCase *tc); 6void edje_test_edje(TCase *tc);
7void edje_test_text(TCase *tc);
7 8
8 9
9#endif /* _EDJE_SUITE_H */ 10#endif /* _EDJE_SUITE_H */
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
new file mode 100644
index 0000000000..7d878a6153
--- /dev/null
+++ b/src/tests/edje/edje_test_text.c
@@ -0,0 +1,239 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include <Eina.h>
12#include <Edje.h>
13
14#include "edje_suite.h"
15#include "edje_tests_helpers.h"
16
17#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
18
19static const char *
20test_layout_get(const char *name)
21{
22 static char filename[PATH_MAX];
23
24 snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
25
26 return filename;
27}
28
29START_TEST(edje_test_text_ellipsis)
30{
31 Eo *evas = EDJE_TEST_INIT_EVAS();
32 Eo *layout;
33
34 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
35 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
36 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
37 fail_if(efl_file_load_error_get(layout));
38
39 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
40
41 EDJE_TEST_FREE_EVAS();
42}
43END_TEST
44
45START_TEST(edje_test_text_wrap)
46{
47 Eo *evas = EDJE_TEST_INIT_EVAS();
48 Eo *layout;
49
50 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
51 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
52 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
53 fail_if(efl_file_load_error_get(layout));
54
55 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
56
57 EDJE_TEST_FREE_EVAS();
58}
59END_TEST
60
61START_TEST(edje_test_text_font)
62{
63 Eo *evas = EDJE_TEST_INIT_EVAS();
64 Eo *layout;
65
66 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
67 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
68 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
69 fail_if(efl_file_load_error_get(layout));
70
71 efl_text_font_set(efl_part(layout, "text"), "Sans", 14);
72
73 EDJE_TEST_FREE_EVAS();
74}
75END_TEST
76
77START_TEST(edje_test_text_color)
78{
79 Eo *evas = EDJE_TEST_INIT_EVAS();
80 Eo *layout;
81
82 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
83 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
84 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
85 fail_if(efl_file_load_error_get(layout));
86
87 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 255, 255);
88
89 EDJE_TEST_FREE_EVAS();
90}
91END_TEST
92
93static void
94_basic_check(Eo *layout, Eina_Bool set)
95{
96 // Colors
97 {
98 unsigned char r, g, b, a;
99
100 // Just normal_color is enough
101 if (set)
102 {
103 efl_text_normal_color_set(efl_part(layout, "text"),
104 255, 255, 255, 255);
105 efl_text_backing_color_set(efl_part(layout, "text"),
106 255, 255, 255, 255);
107 efl_text_glow_color_set(efl_part(layout, "text"),
108 255, 255, 255, 255);
109 efl_text_glow2_color_set(efl_part(layout, "text"),
110 255, 255, 255, 255);
111 efl_text_outline_color_set(efl_part(layout, "text"),
112 255, 255, 255, 255);
113 efl_text_shadow_color_set(efl_part(layout, "text"),
114 255, 255, 255, 255);
115 efl_text_strikethrough_color_set(efl_part(layout, "text"),
116 255, 255, 255, 255);
117 efl_text_underline_color_set(efl_part(layout, "text"),
118 255, 255, 255, 255);
119 efl_text_underline2_color_set(efl_part(layout, "text"),
120 255, 255, 255, 255);
121 efl_text_underline_dashed_color_set(efl_part(layout, "text"),
122 255, 255, 255, 255);
123 }
124
125 efl_text_normal_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
126 ck_assert_int_eq(r, 255);
127 ck_assert_int_eq(g, 255);
128 ck_assert_int_eq(b, 255);
129 ck_assert_int_eq(a, 255);
130
131 efl_text_backing_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
132 ck_assert_int_eq(r, 255);
133 ck_assert_int_eq(g, 255);
134 ck_assert_int_eq(b, 255);
135 ck_assert_int_eq(a, 255);
136
137 efl_text_glow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
138 ck_assert_int_eq(r, 255);
139 ck_assert_int_eq(g, 255);
140 ck_assert_int_eq(b, 255);
141 ck_assert_int_eq(a, 255);
142
143 efl_text_glow2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
144 ck_assert_int_eq(r, 255);
145 ck_assert_int_eq(g, 255);
146 ck_assert_int_eq(b, 255);
147 ck_assert_int_eq(a, 255);
148
149 efl_text_outline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
150 ck_assert_int_eq(r, 255);
151 ck_assert_int_eq(g, 255);
152 ck_assert_int_eq(b, 255);
153 ck_assert_int_eq(a, 255);
154
155 efl_text_shadow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
156 ck_assert_int_eq(r, 255);
157 ck_assert_int_eq(g, 255);
158 ck_assert_int_eq(b, 255);
159 ck_assert_int_eq(a, 255);
160
161 efl_text_strikethrough_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
162 ck_assert_int_eq(r, 255);
163 ck_assert_int_eq(g, 255);
164 ck_assert_int_eq(b, 255);
165 ck_assert_int_eq(a, 255);
166
167 efl_text_underline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
168 ck_assert_int_eq(r, 255);
169 ck_assert_int_eq(g, 255);
170 ck_assert_int_eq(b, 255);
171 ck_assert_int_eq(a, 255);
172
173 efl_text_underline2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
174 ck_assert_int_eq(r, 255);
175 ck_assert_int_eq(g, 255);
176 ck_assert_int_eq(b, 255);
177 ck_assert_int_eq(a, 255);
178
179 efl_text_underline_dashed_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
180 ck_assert_int_eq(r, 255);
181 ck_assert_int_eq(g, 255);
182 ck_assert_int_eq(b, 255);
183 ck_assert_int_eq(a, 255);
184 }
185
186 // Rest of api
187 {
188 Efl_Text_Format_Wrap wrap;
189 double ellipsis;
190 const char *font;
191 Efl_Font_Size size;
192
193 if (set)
194 {
195 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
196 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
197 efl_text_font_set(efl_part(layout, "text"), "Sans", 12);
198 }
199
200 wrap = efl_text_wrap_get(efl_part(layout, "text"));
201 ck_assert_int_eq(wrap, EFL_TEXT_FORMAT_WRAP_WORD);
202
203 ellipsis = efl_text_ellipsis_get(efl_part(layout, "text"));
204 ck_assert(EINA_DBL_EQ(ellipsis, 1.0));
205
206 efl_text_font_get(efl_part(layout, "text"), &font, &size);
207 ck_assert_str_eq(font, "Sans");
208 ck_assert_int_eq(size, 12);
209 }
210}
211
212START_TEST(edje_test_text_part)
213{
214 Eo *evas = EDJE_TEST_INIT_EVAS();
215 Eo *layout;
216
217 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
218 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
219
220 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
221 fail_if(efl_file_load_error_get(layout));
222 _basic_check(layout, EINA_TRUE);
223
224 // Load again and check persistance
225 efl_file_set(layout, test_layout_get("test_text.edj"), "test2");
226 fail_if(efl_file_load_error_get(layout));
227 _basic_check(layout, EINA_FALSE);
228
229 EDJE_TEST_FREE_EVAS();
230}
231END_TEST
232void edje_test_text(TCase *tc)
233{
234 tcase_add_test(tc, edje_test_text_ellipsis);
235 tcase_add_test(tc, edje_test_text_wrap);
236 tcase_add_test(tc, edje_test_text_font);
237 tcase_add_test(tc, edje_test_text_color);
238 tcase_add_test(tc, edje_test_text_part);
239}