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
This commit is contained in:
Xavi Artigas 2019-12-11 17:09:56 +00:00 committed by Cedric BAIL
parent 0902bb4e01
commit e097df4164
3 changed files with 62 additions and 0 deletions

View File

@ -139,6 +139,7 @@ elementary_test_src = [
'test_ui_table.c',
'test_ui_popup.c',
'test_ui_textpath.c',
'test_canvas_textblock.c',
'test_video.c',
'test_weather.c',
'test_web.c',

View File

@ -372,6 +372,7 @@ void test_evas_snapshot(void *data, Evas_Object *obj, void *event_info);
void test_evas_map(void *data, Edje_Object *obj, void *event_info);
void test_efl_gfx_mapping(void *data, Edje_Object *obj, void *event_info);
void test_ui_textpath(void *data, Edje_Object *obj, void *event_info);
void test_canvas_textblock(void *data, Edje_Object *obj, void *event_info);
void test_efl_anim_alpha(void *data, Evas_Object *obj, void *event_info);
void test_efl_anim_rotate(void *data, Evas_Object *obj, void *event_info);
@ -1209,6 +1210,7 @@ add_tests:
ADD_TEST(NULL, "Text", "Label Colors", test_label_colors);
ADD_TEST(NULL, "Text", "Label Emoji", test_label_emoji);
ADD_TEST_EO(NULL, "Text", "Efl.Ui.Textpath", test_ui_textpath);
ADD_TEST_EO(NULL, "Text", "Efl.Canvas.Textblock style", test_canvas_textblock);
//------------------------------//
ADD_TEST(NULL, "Stored Surface Buffer", "Launcher", test_launcher);

View File

@ -0,0 +1,59 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Efl_Ui.h>
#include <Elementary.h>
static void
_apply_style(const Eo *input, Eo *textblock)
{
const char *style = efl_text_get(input);
efl_canvas_textblock_style_apply(textblock, style);
}
static void
_style_changed_cb(void *data, const Efl_Event *ev)
{
_apply_style(ev->object, data);
}
void
test_canvas_textblock(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eo *win, *box, *textblock, *input;
const char *default_style;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_text_set(efl_added, "Efl.Canvas.Textblock style"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL));
efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_gfx_hint_weight_set(efl_added, 1, 0),
efl_text_set(efl_added, "Live style editor. Enter a style string below:"),
efl_pack(box, efl_added));
input = efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_gfx_hint_weight_set(efl_added, 1, 0),
efl_text_set(efl_added, "font=Sans font_size=24 color=white"),
efl_pack(box, efl_added));
efl_ui_textbox_scrollable_set(input, EINA_TRUE);
textblock = efl_add(EFL_CANVAS_TEXTBLOCK_CLASS, box,
efl_text_multiline_set(efl_added, EINA_TRUE),
efl_text_set(efl_added, "This is a sample text block."),
efl_pack(box, efl_added));
efl_event_callback_add(input, EFL_TEXT_INTERACTIVE_EVENT_CHANGED_USER,
_style_changed_cb, textblock),
efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 240));
default_style = efl_canvas_textblock_all_styles_get(textblock);
printf("Default style string: %s\n", default_style);
_apply_style(input, textblock);
}