summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-12-21 10:59:34 +0200
committerDaniel Hirt <hirt.danny@gmail.com>2018-12-30 15:37:14 +0200
commit3d6fed40c031bf88dda4c41d84b16c3d35081968 (patch)
tree7366022b1fcbad21feaa0141d1e0ca859006680e
parentbf2b99110fbdda43e660d9614104af5c22b905a1 (diff)
Ui layout text: implement Efl.Text.Font.font
This forwards the call to set the font to the underlying `TEXTBLOCK` part. The rest of the handling is done in the `Canvas.Layout` as implemented in the previous commits. See example file efl_ui_layout_part_text_example.c in this commit. @feature
-rw-r--r--src/examples/elementary/efl_ui_layout_part_text_example.c83
-rw-r--r--src/lib/elementary/efl_ui_layout.c21
-rw-r--r--src/lib/elementary/efl_ui_layout_part_text.eo3
-rw-r--r--src/lib/elementary/elm_part_helper.h22
4 files changed, 128 insertions, 1 deletions
diff --git a/src/examples/elementary/efl_ui_layout_part_text_example.c b/src/examples/elementary/efl_ui_layout_part_text_example.c
new file mode 100644
index 0000000000..18992f6139
--- /dev/null
+++ b/src/examples/elementary/efl_ui_layout_part_text_example.c
@@ -0,0 +1,83 @@
1/*
2 * edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj
3 * gcc -o efl_ui_theme_example_01 efl_ui_theme_example_01.c `pkg-config --cflags --libs elementary`
4 */
5#define EFL_BETA_API_SUPPORT 1
6#define EFL_EO_API_SUPPORT 1
7
8#define EFL_UI_WIDGET_PROTECTED
9#include <Elementary.h>
10
11#define EXAMPLE_EDJ_FILE_PATH "./efl_ui_theme_example.edj"
12
13static void
14_btn_extension_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event)
15{
16 static Eina_Bool loaded = EINA_TRUE;
17 Efl_Ui_Theme *default_theme;
18
19 default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
20
21 if (loaded)
22 {
23 efl_ui_theme_extension_del(default_theme, EXAMPLE_EDJ_FILE_PATH);
24 efl_text_set(event->object, "Load extension");
25 }
26 else
27 {
28 efl_ui_theme_extension_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
29 efl_text_set(event->object, "Unload extension");
30 }
31
32 loaded = !loaded;
33}
34
35EAPI_MAIN void
36efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
37{
38 Eo *win, *box;
39 Efl_Ui_Theme *default_theme;
40 Eo *custom_bt;
41
42 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
43
44 if (!ecore_file_exists(EXAMPLE_EDJ_FILE_PATH))
45 {
46 printf("efl_ui_theme_example.edj does not exist!\n"
47 "Please execute the following command first!\n"
48 "edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj\n");
49 efl_exit(0);
50 }
51
52 default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
53 efl_ui_theme_extension_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
54
55 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
56 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
57 efl_text_set(efl_added, "Efl.Ui.Layout Text Part Example"),
58 efl_ui_win_autodel_set(efl_added, EINA_TRUE)
59 );
60
61 box = efl_add(EFL_UI_BOX_CLASS, win,
62 efl_content_set(win, efl_added));
63
64 efl_add(EFL_UI_BUTTON_CLASS, box,
65 efl_text_set(efl_added, "Unload extension"),
66 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _btn_extension_clicked_cb, NULL),
67 efl_pack_end(box, efl_added));
68
69 custom_bt = efl_add(EFL_UI_BUTTON_CLASS, box,
70 efl_ui_widget_style_set(efl_added, "custom"),
71 efl_pack_end(box, efl_added));
72
73 efl_add(EFL_UI_BUTTON_CLASS, box,
74 efl_text_set(efl_added, "default style"),
75 efl_pack_end(box, efl_added));
76
77 efl_text_set(custom_bt, "custom style"),
78 efl_text_font_set(efl_part(custom_bt, "efl.text"), "Serif:style=Bold", 24);
79 efl_text_font_set(efl_part(custom_bt, "efl.text"), "Mono:style=Bold", 24);
80
81 efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 320));
82}
83EFL_MAIN()
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index deba292ce5..cac2704dcc 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -1353,6 +1353,22 @@ _efl_ui_layout_text_markup_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part
1353} 1353}
1354 1354
1355static void 1355static void
1356_efl_ui_layout_text_font_set(Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED,
1357 const char *part, const char *font, Efl_Font_Size size)
1358{
1359 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1360 efl_text_font_set(efl_part(wd->resize_obj, part), font, size);
1361}
1362
1363static void
1364_efl_ui_layout_text_font_get(Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED,
1365 const char *part, const char **font, Efl_Font_Size *size)
1366{
1367 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1368 efl_text_font_get(efl_part(wd->resize_obj, part), font, size);
1369}
1370
1371static void
1356_layout_box_subobj_init(Efl_Ui_Layout_Data *sd, Efl_Ui_Layout_Sub_Object_Data *sub_d, const char *part, Evas_Object *child) 1372_layout_box_subobj_init(Efl_Ui_Layout_Data *sd, Efl_Ui_Layout_Sub_Object_Data *sub_d, const char *part, Evas_Object *child)
1357{ 1373{
1358 sub_d->part = eina_stringshare_add(part); 1374 sub_d->part = eina_stringshare_add(part);
@@ -2526,12 +2542,17 @@ _efl_ui_layout_part_efl_ui_cursor_cursor_theme_search_enabled_get(const Eo *obj,
2526 ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \ 2542 ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \
2527 ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \ 2543 ELM_PART_OVERRIDE_TEXT_MARKUP_SET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \
2528 2544
2545#define FONT_FULL(part_typename, typename, CLASS, TYPENAME) \
2546 ELM_PART_OVERRIDE_TEXT_FONT_SET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \
2547 ELM_PART_OVERRIDE_TEXT_FONT_GET_FULL(part_typename, typename, ELM_PART_OVERRIDE_INTERNALS_FETCH(CLASS, TYPENAME)) \
2548
2529/* Efl.Ui.Layout_Part_Content */ 2549/* Efl.Ui.Layout_Part_Content */
2530CONTENT_FULL(efl_ui_layout_part_content, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) 2550CONTENT_FULL(efl_ui_layout_part_content, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data)
2531 2551
2532/* Efl.Ui.Layout_Part_Text */ 2552/* Efl.Ui.Layout_Part_Text */
2533TEXT_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) 2553TEXT_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data)
2534MARKUP_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data) 2554MARKUP_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data)
2555FONT_FULL(efl_ui_layout_part_text, efl_ui_layout, EFL_UI_LAYOUT, Efl_Ui_Layout_Data)
2535 2556
2536EOLIAN static const char * 2557EOLIAN static const char *
2537_efl_ui_layout_part_text_efl_ui_translatable_translatable_text_get(const Eo *obj, void *_pd EINA_UNUSED, const char **domain) 2558_efl_ui_layout_part_text_efl_ui_translatable_translatable_text_get(const Eo *obj, void *_pd EINA_UNUSED, const char **domain)
diff --git a/src/lib/elementary/efl_ui_layout_part_text.eo b/src/lib/elementary/efl_ui_layout_part_text.eo
index abe9fcef47..d78e0817f0 100644
--- a/src/lib/elementary/efl_ui_layout_part_text.eo
+++ b/src/lib/elementary/efl_ui_layout_part_text.eo
@@ -1,5 +1,5 @@
1class Efl.Ui.Layout_Part_Text (Efl.Ui.Layout_Part, Efl.Text, Efl.Text_Markup, 1class Efl.Ui.Layout_Part_Text (Efl.Ui.Layout_Part, Efl.Text, Efl.Text_Markup,
2 Efl.Ui.Translatable) 2 Efl.Ui.Translatable, Efl.Text_Font)
3{ 3{
4 [[Elementary layout internal part class]] 4 [[Elementary layout internal part class]]
5 data: null; 5 data: null;
@@ -7,5 +7,6 @@ class Efl.Ui.Layout_Part_Text (Efl.Ui.Layout_Part, Efl.Text, Efl.Text_Markup,
7 Efl.Text.text { set; get; } 7 Efl.Text.text { set; get; }
8 Efl.Text_Markup.markup { get; set; } 8 Efl.Text_Markup.markup { get; set; }
9 Efl.Ui.Translatable.translatable_text { get; set; } 9 Efl.Ui.Translatable.translatable_text { get; set; }
10 Efl.Text_Font.font { set; get; }
10 } 11 }
11} 12}
diff --git a/src/lib/elementary/elm_part_helper.h b/src/lib/elementary/elm_part_helper.h
index 6fe2304d8f..583bb7b02a 100644
--- a/src/lib/elementary/elm_part_helper.h
+++ b/src/lib/elementary/elm_part_helper.h
@@ -152,6 +152,22 @@ _ ## full ## _efl_text_markup_markup_set(Eo *obj, void *_pd EINA_UNUSED, const c
152 _ ## type ## _text_markup_set(pd->obj, sd, pd->part, markup); \ 152 _ ## type ## _text_markup_set(pd->obj, sd, pd->part, markup); \
153} 153}
154 154
155#define ELM_PART_OVERRIDE_TEXT_FONT_SET_FULL(full, type, internals) \
156EOLIAN static void \
157_ ## full ## _efl_text_font_font_set(Eo *obj, void *_pd EINA_UNUSED, const char *font, Efl_Font_Size size) \
158{ \
159 internals \
160 _ ## type ## _text_font_set(pd->obj, sd, pd->part, font, size); \
161}
162
163#define ELM_PART_OVERRIDE_TEXT_FONT_GET_FULL(full, type, internals) \
164EOLIAN static void \
165_ ## full ## _efl_text_font_font_get(const Eo *obj, void *_pd EINA_UNUSED, const char **font, Efl_Font_Size *size) \
166{ \
167 internals \
168 _ ## type ## _text_font_get(pd->obj, sd, pd->part, font, size); \
169}
170
155#define ELM_PART_OVERRIDE_CONTENT_SET(type, TYPE, typedata) \ 171#define ELM_PART_OVERRIDE_CONTENT_SET(type, TYPE, typedata) \
156 ELM_PART_OVERRIDE_CONTENT_SET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH(TYPE, typedata)) 172 ELM_PART_OVERRIDE_CONTENT_SET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH(TYPE, typedata))
157 173
@@ -194,6 +210,12 @@ _ ## full ## _efl_text_markup_markup_set(Eo *obj, void *_pd EINA_UNUSED, const c
194#define ELM_PART_OVERRIDE_MARKUP_GET_NO_SD(type) \ 210#define ELM_PART_OVERRIDE_MARKUP_GET_NO_SD(type) \
195 ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH_NO_SD()) 211 ELM_PART_OVERRIDE_TEXT_MARKUP_GET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH_NO_SD())
196 212
213#define ELM_PART_OVERRIDE_FONT_SET(type, TYPE, typedata) \
214 ELM_PART_OVERRIDE_TEXT_FONT_SET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH(TYPE, typedata))
215
216#define ELM_PART_OVERRIDE_FONT_GET(type, TYPE, typedata) \
217 ELM_PART_OVERRIDE_TEXT_FONT_GET_FULL(type ## _part, type, ELM_PART_OVERRIDE_INTERNALS_FETCH(TYPE, typedata))
218
197 219
198#define ELM_PART_TEXT_DEFAULT_IMPLEMENT(type, typedata) \ 220#define ELM_PART_TEXT_DEFAULT_IMPLEMENT(type, typedata) \
199EOLIAN static void \ 221EOLIAN static void \