summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-12-11 17:09:56 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-12-11 11:11:04 -0800
commite097df41642cfb9a9ceb4dca5abcc56f275846f1 (patch)
tree9d298381098e126417a70cbf3c9404d1c02023ba
parent0902bb4e013d3aed7432747357e6c3b97e40ab15 (diff)
elementary_test: Add Canvas.Textblock style test
This test accepts a style string (as defined in the style_apply method) and continuously applies it to a sample text block. Useful for debugging Efl.Canvas.Textblock styles. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10853
-rw-r--r--src/bin/elementary/meson.build1
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_canvas_textblock.c59
3 files changed, 62 insertions, 0 deletions
diff --git a/src/bin/elementary/meson.build b/src/bin/elementary/meson.build
index 342e184..27dabe6 100644
--- a/src/bin/elementary/meson.build
+++ b/src/bin/elementary/meson.build
@@ -139,6 +139,7 @@ elementary_test_src = [
139 'test_ui_table.c', 139 'test_ui_table.c',
140 'test_ui_popup.c', 140 'test_ui_popup.c',
141 'test_ui_textpath.c', 141 'test_ui_textpath.c',
142 'test_canvas_textblock.c',
142 'test_video.c', 143 'test_video.c',
143 'test_weather.c', 144 'test_weather.c',
144 'test_web.c', 145 'test_web.c',
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 355a5cc..cab1923 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -372,6 +372,7 @@ void test_evas_snapshot(void *data, Evas_Object *obj, void *event_info);
372void test_evas_map(void *data, Edje_Object *obj, void *event_info); 372void test_evas_map(void *data, Edje_Object *obj, void *event_info);
373void test_efl_gfx_mapping(void *data, Edje_Object *obj, void *event_info); 373void test_efl_gfx_mapping(void *data, Edje_Object *obj, void *event_info);
374void test_ui_textpath(void *data, Edje_Object *obj, void *event_info); 374void test_ui_textpath(void *data, Edje_Object *obj, void *event_info);
375void test_canvas_textblock(void *data, Edje_Object *obj, void *event_info);
375 376
376void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info); 377void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info);
377void test_efl_anim_rotate(void *data, Evas_Object *obj, void *event_info); 378void test_efl_anim_rotate(void *data, Evas_Object *obj, void *event_info);
@@ -1209,6 +1210,7 @@ add_tests:
1209 ADD_TEST(NULL, "Text", "Label Colors", test_label_colors); 1210 ADD_TEST(NULL, "Text", "Label Colors", test_label_colors);
1210 ADD_TEST(NULL, "Text", "Label Emoji", test_label_emoji); 1211 ADD_TEST(NULL, "Text", "Label Emoji", test_label_emoji);
1211 ADD_TEST_EO(NULL, "Text", "Efl.Ui.Textpath", test_ui_textpath); 1212 ADD_TEST_EO(NULL, "Text", "Efl.Ui.Textpath", test_ui_textpath);
1213 ADD_TEST_EO(NULL, "Text", "Efl.Canvas.Textblock style", test_canvas_textblock);
1212 1214
1213 //------------------------------// 1215 //------------------------------//
1214 ADD_TEST(NULL, "Stored Surface Buffer", "Launcher", test_launcher); 1216 ADD_TEST(NULL, "Stored Surface Buffer", "Launcher", test_launcher);
diff --git a/src/bin/elementary/test_canvas_textblock.c b/src/bin/elementary/test_canvas_textblock.c
new file mode 100644
index 0000000..1c20ac5
--- /dev/null
+++ b/src/bin/elementary/test_canvas_textblock.c
@@ -0,0 +1,59 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Efl_Ui.h>
5#include <Elementary.h>
6
7static void
8_apply_style(const Eo *input, Eo *textblock)
9{
10 const char *style = efl_text_get(input);
11 efl_canvas_textblock_style_apply(textblock, style);
12}
13
14static void
15_style_changed_cb(void *data, const Efl_Event *ev)
16{
17 _apply_style(ev->object, data);
18}
19
20
21void
22test_canvas_textblock(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
23{
24 Eo *win, *box, *textblock, *input;
25 const char *default_style;
26
27 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
28 efl_text_set(efl_added, "Efl.Canvas.Textblock style"),
29 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
30
31 box = efl_add(EFL_UI_BOX_CLASS, win,
32 efl_content_set(win, efl_added),
33 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
34
35 efl_add(EFL_UI_TEXTBOX_CLASS, box,
36 efl_gfx_hint_weight_set(efl_added, 1, 0),
37 efl_text_set(efl_added, "Live style editor. Enter a style string below:"),
38 efl_pack(box, efl_added));
39
40 input = efl_add(EFL_UI_TEXTBOX_CLASS, box,
41 efl_gfx_hint_weight_set(efl_added, 1, 0),
42 efl_text_set(efl_added, "font=Sans font_size=24 color=white"),
43 efl_pack(box, efl_added));
44 efl_ui_textbox_scrollable_set(input, EINA_TRUE);
45
46 textblock = efl_add(EFL_CANVAS_TEXTBLOCK_CLASS, box,
47 efl_text_multiline_set(efl_added, EINA_TRUE),
48 efl_text_set(efl_added, "This is a sample text block."),
49 efl_pack(box, efl_added));
50
51 efl_event_callback_add(input, EFL_TEXT_INTERACTIVE_EVENT_CHANGED_USER,
52 _style_changed_cb, textblock),
53
54 efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 240));
55
56 default_style = efl_canvas_textblock_all_styles_get(textblock);
57 printf("Default style string: %s\n", default_style);
58 _apply_style(input, textblock);
59}