summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Edje.am2
-rw-r--r--src/examples/elementary.mk9
-rw-r--r--src/examples/elementary/efl_canvas_layout_text.c158
-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/tests/edje/data/test_text.edc41
-rw-r--r--src/tests/edje/edje_suite.c1
-rw-r--r--src/tests/edje/edje_test_text.c220
13 files changed, 1278 insertions, 31 deletions
diff --git a/src/Makefile_Edje.am b/src/Makefile_Edje.am
index 683583ae10..ae9e952881 100644
--- a/src/Makefile_Edje.am
+++ b/src/Makefile_Edje.am
@@ -300,6 +300,7 @@ tests/edje/data/test_signals.edc \
300tests/edje/data/test_signal_callback_del_full.edc \ 300tests/edje/data/test_signal_callback_del_full.edc \
301tests/edje/data/test_text_cursor.edc \ 301tests/edje/data/test_text_cursor.edc \
302tests/edje/data/test_textblock.edc \ 302tests/edje/data/test_textblock.edc \
303tests/edje/data/test_text.edc \
303tests/edje/data/filter.lua 304tests/edje/data/filter.lua
304 305
305 306
@@ -350,6 +351,7 @@ EDJE_TEST_FILES = tests/edje/data/test_layout.edj \
350 tests/edje/data/test_signal_callback_del_full.edj \ 351 tests/edje/data/test_signal_callback_del_full.edj \
351 tests/edje/data/test_text_cursor.edj \ 352 tests/edje/data/test_text_cursor.edj \
352 tests/edje/data/test_textblock.edj \ 353 tests/edje/data/test_textblock.edj \
354 tests/edje/data/test_text.edj \
353 $(NULL) 355 $(NULL)
354 356
355CLEANFILES += $(EDJE_TEST_FILES) 357CLEANFILES += $(EDJE_TEST_FILES)
diff --git a/src/examples/elementary.mk b/src/examples/elementary.mk
index 0d0fa0052b..e928d9d89e 100644
--- a/src/examples/elementary.mk
+++ b/src/examples/elementary.mk
@@ -122,7 +122,8 @@ elementary/efl_thread_6.c \
122elementary/efl_ui_list_example_1.c \ 122elementary/efl_ui_list_example_1.c \
123elementary/efl_ui_list_view_example_1.c \ 123elementary/efl_ui_list_view_example_1.c \
124elementary/efl_ui_list_view_example_2.c \ 124elementary/efl_ui_list_view_example_2.c \
125elementary/efl_ui_list_view_example_3.c 125elementary/efl_ui_list_view_example_3.c \
126elementary/efl_canvas_layout_text.c
126 127
127ELM_SRCS += \ 128ELM_SRCS += \
128elementary/bg_cxx_example_01.cc \ 129elementary/bg_cxx_example_01.cc \
@@ -154,7 +155,8 @@ elementary/theme_example.edc \
154elementary/layout_example.edc \ 155elementary/layout_example.edc \
155elementary/codegen_example.edc \ 156elementary/codegen_example.edc \
156elementary/efl_ui_list_view_example.edc \ 157elementary/efl_ui_list_view_example.edc \
157elementary/prefs_example_03.edc 158elementary/prefs_example_03.edc \
159elementary/efl_canvas_layout_text.edc
158 160
159ELM_EPCS = \ 161ELM_EPCS = \
160elementary/prefs_example_01.epc \ 162elementary/prefs_example_01.epc \
@@ -336,7 +338,8 @@ elementary/efl_thread_6 \
336elementary/efl_ui_list_example_1 \ 338elementary/efl_ui_list_example_1 \
337elementary/efl_ui_list_view_example_1 \ 339elementary/efl_ui_list_view_example_1 \
338elementary/efl_ui_list_view_example_2 \ 340elementary/efl_ui_list_view_example_2 \
339elementary/efl_ui_list_view_example_3 341elementary/efl_ui_list_view_example_3 \
342elementary/efl_canvas_layout_text
340#benchmark3d 343#benchmark3d
341#sphere-hunter 344#sphere-hunter
342 345
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..8e89403d19
--- /dev/null
+++ b/src/examples/elementary/efl_canvas_layout_text.c
@@ -0,0 +1,158 @@
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 'g' to cycle group examples.\n"
74 "Press 'e' to cycle ellipsis modes.\n"
75 "Press 'h' to display this help.\n");
76}
77
78static const char *edjefile = "efl_canvas_layout_text.edj";
79
80static void
81_on_key_down(void *data, const Efl_Event *event)
82{
83 Efl_Input_Key *ev = event->info;
84 Eo *layout = data;
85 const char *key = efl_input_key_name_get(ev);
86
87 if (!strcmp(key, "g"))
88 {
89 // edje group
90 group_itr = (group_itr + 1) % 2;
91 efl_file_set(layout, edjefile, groups[group_itr]);
92 printf("Changed layout group to: %s\n", groups[group_itr]);
93 }
94 else if (!strcmp(key, "w"))
95 {
96 // wrap mode
97 wrap_itr = (wrap_itr + 1) % 4;
98 efl_text_wrap_set(efl_part(layout, "text"), wraps[wrap_itr].wrap);
99 printf("Changed wrap to %s\n", wraps[wrap_itr].desc);
100 }
101 else if (!strcmp(key, "e"))
102 {
103 // ellipsis value
104 ellipsis_itr = (ellipsis_itr + 1) % 2;
105 efl_text_ellipsis_set(efl_part(layout, "text"), ellipsis[ellipsis_itr]);
106 printf("Changed ellipsis to %f\n", ellipsis[ellipsis_itr]);
107 }
108 else if (!strcmp(key, "s"))
109 {
110 Eina_Size2D sz;
111 // expand mode
112 expand_itr = (expand_itr + 1) % 6;
113 efl_canvas_layout_part_text_expand_set(efl_part(layout, "text"),
114 expands[expand_itr].expand);
115 printf("Changed expand mode to: %s\n", expands[expand_itr].desc);
116
117 sz = efl_layout_calc_size_min(layout, EINA_SIZE2D(10, 10));
118 printf("new expand_min: %dx%d\n", sz.w, sz.h);
119 }
120 else if (!strcmp(key, "h"))
121 {
122 _help();
123 }
124}
125
126EAPI_MAIN void
127efl_main(void *data EINA_UNUSED,
128 const Efl_Event *ev)
129{
130
131 Eo *layout;
132 Eo *win;
133
134 win = efl_add(EFL_UI_WIN_CLASS, NULL,
135 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
136 efl_text_set(efl_added, "Efl Canvas_Layout"),
137 efl_ui_win_autodel_set(efl_added, EINA_TRUE),
138 efl_event_callback_add(efl_added, EFL_UI_WIN_EVENT_DELETE_REQUEST, _on_win_delete, NULL));
139
140
141 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, win);
142 efl_file_set(layout, edjefile, groups[group_itr]);
143
144 efl_content_set(win, layout);
145 efl_gfx_entity_size_set(win, EINA_SIZE2D(110, 100));
146
147 efl_text_markup_set(efl_part(layout, "text"), "This is an example text. This is a layout text part.");
148 efl_text_wrap_set(efl_part(layout, "text"), wraps[wrap_itr].wrap);
149 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 0, 255);
150 efl_text_font_set(efl_part(layout, "text"), "Serif", 12);
151
152 efl_canvas_layout_part_text_expand_set(efl_part(layout, "text"),
153 expands[expand_itr].expand);
154
155 efl_event_callback_add(win, EFL_EVENT_KEY_DOWN, _on_key_down, layout);
156
157}
158EFL_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 c974342fc7..6d865d4408 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1645,6 +1645,25 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
1645 } 1645 }
1646 eina_stringshare_del(eud->u.string.text); 1646 eina_stringshare_del(eud->u.string.text);
1647 break; 1647 break;
1648
1649 case EDJE_USER_TEXT_STYLE:
1650 {
1651 Edje_Part_Text_Prop *prop;
1652 EINA_LIST_FREE(eud->u.text_style.props, prop)
1653 {
1654 _canvas_layout_user_text_apply(eud, obj,
1655 prop);
1656 free(prop);
1657 }
1658 }
1659 break;
1660 case EDJE_USER_TEXT_EXPAND:
1661 {
1662 efl_canvas_layout_part_text_expand_set(
1663 efl_part(obj, eud->part),
1664 eud->u.text_expand.expand);
1665 }
1666 break;
1648 } 1667 }
1649 if (eud) _edje_user_definition_remove(eud, child); 1668 if (eud) _edje_user_definition_remove(eud, child);
1650 } 1669 }
@@ -1840,10 +1859,15 @@ _edje_object_collect(Edje *ed)
1840 edje_object_part_unswallow(NULL, eud->u.swallow.child); 1859 edje_object_part_unswallow(NULL, eud->u.swallow.child);
1841 break; 1860 break;
1842 1861
1862 case EDJE_USER_TEXT_STYLE:
1863 _canvas_layout_user_text_collect(ed, eud);
1864 break;
1865
1843 case EDJE_USER_DRAG_STEP: 1866 case EDJE_USER_DRAG_STEP:
1844 case EDJE_USER_DRAG_PAGE: 1867 case EDJE_USER_DRAG_PAGE:
1845 case EDJE_USER_DRAG_VALUE: 1868 case EDJE_USER_DRAG_VALUE:
1846 case EDJE_USER_DRAG_SIZE: 1869 case EDJE_USER_DRAG_SIZE:
1870 case EDJE_USER_TEXT_EXPAND:
1847 break; 1871 break;
1848 } 1872 }
1849 } 1873 }
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 8429175a97..6b95b8dc1b 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
@@ -2968,9 +3030,15 @@ Eina_Bool _edje_multisense_internal_vibration_sample_play(Edje *ed, const char *
2968 3030
2969void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state); 3031void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);
2970 3032
3033Edje_User_Defined * _edje_user_definition_fetch(Edje *ed, const char *part, Edje_User_Defined_Type type);
3034Edje_User_Defined * _edje_user_text_style_definition_fetch(Edje *ed, const char *part);
3035Edje_User_Defined * _edje_user_text_expand_definition_fetch(Edje *ed, const char *part);
2971void _edje_user_definition_remove(Edje_User_Defined *eud, Evas_Object *child); 3036void _edje_user_definition_remove(Edje_User_Defined *eud, Evas_Object *child);
2972void _edje_user_definition_free(Edje_User_Defined *eud); 3037void _edje_user_definition_free(Edje_User_Defined *eud);
2973 3038
3039void _canvas_layout_user_text_apply(Edje_User_Defined *eud, Eo *obj, Edje_Part_Text_Prop *prop);
3040void _canvas_layout_user_text_collect(Edje *ed, Edje_User_Defined *eud);
3041
2974extern Efl_Observable *_edje_color_class_member; 3042extern Efl_Observable *_edje_color_class_member;
2975extern Efl_Observable *_edje_text_class_member; 3043extern Efl_Observable *_edje_text_class_member;
2976extern Efl_Observable *_edje_size_class_member; 3044extern Efl_Observable *_edje_size_class_member;
diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c
index 6786b0d91a..add799f954 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 35de55b3f7..c85f485a1c 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/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 e8f39cf011..819300306d 100644
--- a/src/tests/edje/edje_suite.c
+++ b/src/tests/edje/edje_suite.c
@@ -13,6 +13,7 @@ static const Efl_Test_Case etc[] = {
13 { "Signal", edje_test_signal }, 13 { "Signal", edje_test_signal },
14 { "Swallow", edje_test_swallow }, 14 { "Swallow", edje_test_swallow },
15 { "Text", edje_test_text }, 15 { "Text", edje_test_text },
16 { "Edje Text", edje_test_text },
16 { NULL, NULL } 17 { NULL, NULL }
17}; 18};
18 19
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
index 0e975f3de7..c4ac3c8758 100644
--- a/src/tests/edje/edje_test_text.c
+++ b/src/tests/edje/edje_test_text.c
@@ -12,7 +12,6 @@
12 12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas" 13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14 14
15
16EFL_START_TEST(edje_test_text_cursor) 15EFL_START_TEST(edje_test_text_cursor)
17{ 16{
18 Evas *evas; 17 Evas *evas;
@@ -115,8 +114,227 @@ EFL_START_TEST(edje_test_textblock)
115} 114}
116EFL_END_TEST 115EFL_END_TEST
117 116
117START_TEST(edje_test_text_ellipsis)
118{
119 Eo *evas;
120 Eo *layout;
121
122 evas = _setup_evas();
123
124 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
125 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
126 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
127 fail_if(efl_file_load_error_get(layout));
128
129 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
130
131 evas_free(evas);
132}
133END_TEST
134
135START_TEST(edje_test_text_wrap)
136{
137 Eo *evas;
138 Eo *layout;
139
140 evas = _setup_evas();
141
142 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
143 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
144 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
145 fail_if(efl_file_load_error_get(layout));
146
147 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
148
149 evas_free(evas);
150}
151END_TEST
152
153START_TEST(edje_test_text_font)
154{
155 Eo *evas;
156 Eo *layout;
157
158 evas = _setup_evas();
159
160 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
161 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
162 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
163 fail_if(efl_file_load_error_get(layout));
164
165 efl_text_font_set(efl_part(layout, "text"), "Sans", 14);
166
167 evas_free(evas);
168}
169END_TEST
170
171START_TEST(edje_test_text_color)
172{
173 Eo *evas;
174 Eo *layout;
175
176 evas = _setup_evas();
177
178 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
179 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
180 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
181 fail_if(efl_file_load_error_get(layout));
182
183 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 255, 255);
184
185 evas_free(evas);
186}
187END_TEST
188
189static void
190_basic_check(Eo *layout, Eina_Bool set)
191{
192 // Colors
193 {
194 unsigned char r, g, b, a;
195
196 // Just normal_color is enough
197 if (set)
198 {
199 efl_text_normal_color_set(efl_part(layout, "text"),
200 255, 255, 255, 255);
201 efl_text_backing_color_set(efl_part(layout, "text"),
202 255, 255, 255, 255);
203 efl_text_glow_color_set(efl_part(layout, "text"),
204 255, 255, 255, 255);
205 efl_text_glow2_color_set(efl_part(layout, "text"),
206 255, 255, 255, 255);
207 efl_text_outline_color_set(efl_part(layout, "text"),
208 255, 255, 255, 255);
209 efl_text_shadow_color_set(efl_part(layout, "text"),
210 255, 255, 255, 255);
211 efl_text_strikethrough_color_set(efl_part(layout, "text"),
212 255, 255, 255, 255);
213 efl_text_underline_color_set(efl_part(layout, "text"),
214 255, 255, 255, 255);
215 efl_text_underline2_color_set(efl_part(layout, "text"),
216 255, 255, 255, 255);
217 efl_text_underline_dashed_color_set(efl_part(layout, "text"),
218 255, 255, 255, 255);
219 }
220
221 efl_text_normal_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
222 ck_assert_int_eq(r, 255);
223 ck_assert_int_eq(g, 255);
224 ck_assert_int_eq(b, 255);
225 ck_assert_int_eq(a, 255);
226
227 efl_text_backing_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
228 ck_assert_int_eq(r, 255);
229 ck_assert_int_eq(g, 255);
230 ck_assert_int_eq(b, 255);
231 ck_assert_int_eq(a, 255);
232
233 efl_text_glow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
234 ck_assert_int_eq(r, 255);
235 ck_assert_int_eq(g, 255);
236 ck_assert_int_eq(b, 255);
237 ck_assert_int_eq(a, 255);
238
239 efl_text_glow2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
240 ck_assert_int_eq(r, 255);
241 ck_assert_int_eq(g, 255);
242 ck_assert_int_eq(b, 255);
243 ck_assert_int_eq(a, 255);
244
245 efl_text_outline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
246 ck_assert_int_eq(r, 255);
247 ck_assert_int_eq(g, 255);
248 ck_assert_int_eq(b, 255);
249 ck_assert_int_eq(a, 255);
250
251 efl_text_shadow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
252 ck_assert_int_eq(r, 255);
253 ck_assert_int_eq(g, 255);
254 ck_assert_int_eq(b, 255);
255 ck_assert_int_eq(a, 255);
256
257 efl_text_strikethrough_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
258 ck_assert_int_eq(r, 255);
259 ck_assert_int_eq(g, 255);
260 ck_assert_int_eq(b, 255);
261 ck_assert_int_eq(a, 255);
262
263 efl_text_underline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
264 ck_assert_int_eq(r, 255);
265 ck_assert_int_eq(g, 255);
266 ck_assert_int_eq(b, 255);
267 ck_assert_int_eq(a, 255);
268
269 efl_text_underline2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
270 ck_assert_int_eq(r, 255);
271 ck_assert_int_eq(g, 255);
272 ck_assert_int_eq(b, 255);
273 ck_assert_int_eq(a, 255);
274
275 efl_text_underline_dashed_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
276 ck_assert_int_eq(r, 255);
277 ck_assert_int_eq(g, 255);
278 ck_assert_int_eq(b, 255);
279 ck_assert_int_eq(a, 255);
280 }
281
282 // Rest of api
283 {
284 Efl_Text_Format_Wrap wrap;
285 double ellipsis;
286 const char *font;
287 Efl_Font_Size size;
288
289 if (set)
290 {
291 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
292 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
293 efl_text_font_set(efl_part(layout, "text"), "Sans", 12);
294 }
295
296 wrap = efl_text_wrap_get(efl_part(layout, "text"));
297 ck_assert_int_eq(wrap, EFL_TEXT_FORMAT_WRAP_WORD);
298
299 ellipsis = efl_text_ellipsis_get(efl_part(layout, "text"));
300 ck_assert(EINA_DBL_EQ(ellipsis, 1.0));
301
302 efl_text_font_get(efl_part(layout, "text"), &font, &size);
303 ck_assert_str_eq(font, "Sans");
304 ck_assert_int_eq(size, 12);
305 }
306}
307
308START_TEST(edje_test_text_part)
309{
310 Eo *evas;
311 Eo *layout;
312
313 evas = _setup_evas();
314
315 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
316 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
317
318 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
319 fail_if(efl_file_load_error_get(layout));
320 _basic_check(layout, EINA_TRUE);
321
322 // Load again and check persistance
323 efl_file_set(layout, test_layout_get("test_text.edj"), "test2");
324 fail_if(efl_file_load_error_get(layout));
325 _basic_check(layout, EINA_FALSE);
326
327 evas_free(evas);
328}
329END_TEST
330
118void edje_test_text(TCase *tc) 331void edje_test_text(TCase *tc)
119{ 332{
120 tcase_add_test(tc, edje_test_text_cursor); 333 tcase_add_test(tc, edje_test_text_cursor);
121 tcase_add_test(tc, edje_test_textblock); 334 tcase_add_test(tc, edje_test_textblock);
335 tcase_add_test(tc, edje_test_text_ellipsis);
336 tcase_add_test(tc, edje_test_text_wrap);
337 tcase_add_test(tc, edje_test_text_font);
338 tcase_add_test(tc, edje_test_text_color);
339 tcase_add_test(tc, edje_test_text_part);
122} 340}