aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2018-11-20 13:56:37 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2018-11-20 13:56:37 +0900
commit4f9c8d524c77fdd9eed30dc9ce211e0037efb9d4 (patch)
tree49924466e10d695fafc5edfbf2a3ff1cd386af69 /src/examples
parentefl_ui_bg: remove Efl.Ui.Bg interface and rename Efl.Ui.Bg_Widget class (diff)
downloadefl-4f9c8d524c77fdd9eed30dc9ce211e0037efb9d4.tar.gz
efl_ui_theme: Introduce Efl.Ui.Theme class
Summary: Efl.Ui.Theme class is required to support language bindings. Efl.Ui.Theme works based on current elm_theme features. This patch fixes https://phab.enlightenment.org/T7357. Reviewers: segfaultxavi, cedric, lauromoura, woohyun, zmike, SanghyeonLee Reviewed By: segfaultxavi, SanghyeonLee Subscribers: SanghyeonLee, herdsman, #reviewers, #committers Tags: #efl Maniphest Tasks: https://phab.enlightenment.org/T7357 Differential Revision: https://phab.enlightenment.org/D7244
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/elementary.mk11
-rw-r--r--src/examples/elementary/efl_ui_theme_example.edc190
-rw-r--r--src/examples/elementary/efl_ui_theme_example_01.c84
-rw-r--r--src/examples/elementary/efl_ui_theme_example_02.c84
4 files changed, 366 insertions, 3 deletions
diff --git a/src/examples/elementary.mk b/src/examples/elementary.mk
index e928d9d89e..0d817258dc 100644
--- a/src/examples/elementary.mk
+++ b/src/examples/elementary.mk
@@ -123,7 +123,9 @@ elementary/efl_ui_list_example_1.c \
elementary/efl_ui_list_view_example_1.c \
elementary/efl_ui_list_view_example_2.c \
elementary/efl_ui_list_view_example_3.c \
-elementary/efl_canvas_layout_text.c
+elementary/efl_canvas_layout_text.c \
+elementary/efl_ui_theme_example_01.c \
+elementary/efl_ui_theme_example_02.c
ELM_SRCS += \
elementary/bg_cxx_example_01.cc \
@@ -156,7 +158,8 @@ elementary/layout_example.edc \
elementary/codegen_example.edc \
elementary/efl_ui_list_view_example.edc \
elementary/prefs_example_03.edc \
-elementary/efl_canvas_layout_text.edc
+elementary/efl_canvas_layout_text.edc \
+elementary/efl_ui_theme_example.edc
ELM_EPCS = \
elementary/prefs_example_01.epc \
@@ -339,7 +342,9 @@ elementary/efl_ui_list_example_1 \
elementary/efl_ui_list_view_example_1 \
elementary/efl_ui_list_view_example_2 \
elementary/efl_ui_list_view_example_3 \
-elementary/efl_canvas_layout_text
+elementary/efl_canvas_layout_text \
+elementary/efl_ui_theme_example_01 \
+elementary/efl_ui_theme_example_02
#benchmark3d
#sphere-hunter
diff --git a/src/examples/elementary/efl_ui_theme_example.edc b/src/examples/elementary/efl_ui_theme_example.edc
new file mode 100644
index 0000000000..341663ac46
--- /dev/null
+++ b/src/examples/elementary/efl_ui_theme_example.edc
@@ -0,0 +1,190 @@
+collections {
+ group { "efl/button:custom";
+ alias: "efl/button";
+ parts {
+ rect { "border";
+ desc { "default";
+ color: 0 0 0 255;
+ }
+ desc { "in";
+ color: 50 180 180 255;
+ }
+ }
+ rect { "base";
+ mouse_events: 1;
+ desc { "default";
+ rel1.to: "border";
+ rel1.offset: 1 1;
+ rel2.to: "border";
+ rel2.offset: -2 -2;
+ }
+ desc { "disabled";
+ inherit: "default";
+ color: 230 230 230 255;
+ }
+ }
+ swallow { "efl.swallow.content";
+ mouse_events: 0;
+ desc { "default";
+ fixed: 1 0;
+ hid;
+ align: 0.0 0.5;
+ rel1.offset: 4 4;
+ rel2.offset: 3 -5;
+ rel2.relative: 0.0 1.0;
+ }
+ desc { "visible";
+ inherit: "default";
+ vis;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ rel2.offset: 4 -5;
+ }
+ desc { "icononly";
+ inherit: "default";
+ fixed: 0 0;
+ vis;
+ align: 0.5 0.5;
+ aspect: 1.0 1.0;
+ aspect_preference: VERTICAL;
+ rel2.offset: -5 -5;
+ rel2.relative: 1.0 1.0;
+ }
+ }
+ text { "efl.text";
+ mouse_events: 0;
+ scale: 1;
+ desc { "default";
+ vis;
+ rel1.to_x: "efl.swallow.content";
+ rel1.relative: 1.0 0.0;
+ rel1.offset: 0 4;
+ rel2.offset: -5 -5;
+ color: 0 0 0 255;
+ text {
+ font: "Sans";
+ size: 10;
+ min: 0 0;
+ text_class: "button";
+ }
+ }
+ desc { "visible";
+ inherit: "default";
+ vis;
+ text.min: 1 1;
+ text.ellipsis: -1;
+ }
+ desc { "disabled";
+ inherit: "default";
+ }
+ desc { "disabled_visible";
+ inherit: "default";
+ vis;
+ text.min: 1 1;
+ text.ellipsis: -1;
+ }
+ }
+ programs {
+ program { "button_mouse_in";
+ signal: "mouse,in";
+ source: "base";
+ action: STATE_SET "in" 0.0;
+ target: "border";
+ }
+ program { "button_mouse_out";
+ signal: "mouse,out";
+ source: "base";
+ action: STATE_SET "default" 0.0;
+ target: "border";
+ }
+ program { "button_unclick";
+ signal: "mouse,up,1";
+ source: "base";
+ action: SIGNAL_EMIT "efl,action,click" "";
+ }
+ program { "button_click";
+ signal: "mouse,down,1";
+ source: "base";
+ }
+ program { "text_show";
+ signal: "efl,state,text,visible";
+ source: "efl";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"efl.swallow.content", st, 30, vl);
+ if (!strcmp(st, "icononly"))
+ set_state(PART:"efl.swallow.content", "visible", 0.0);
+ set_state(PART:"efl.text", "visible", 0.0);
+ }
+ }
+ program { "text_hide";
+ signal: "efl,state,text,hidden";
+ source: "efl";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"efl.swallow.content", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"efl.swallow.content", "icononly", 0.0);
+ set_state(PART:"efl.text", "default", 0.0);
+ }
+ }
+ program { "icon_show";
+ signal: "efl,state,icon,visible";
+ source: "efl";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"efl.text", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"efl.swallow.content", "visible", 0.0);
+ else
+ set_state(PART:"efl.swallow.content", "icononly", 0.0);
+ }
+ }
+ program { "icon_hide";
+ signal: "efl,state,icon,hidden";
+ source: "efl";
+ action: STATE_SET "default" 0.0;
+ target: "efl.swallow.content";
+ }
+ program { "disable";
+ signal: "efl,state,disabled";
+ source: "efl";
+ action: STATE_SET "disabled" 0.0;
+ target: "base";
+ after: "disable_text";
+ }
+ program { "disable_text";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"efl.text", st, 30, vl);
+ if (!strcmp(st, "visible"))
+ set_state(PART:"efl.text", "disabled_visible", 0.0);
+ else if (!strcmp(st, "default"))
+ set_state(PART:"efl.text", "disabled", 0.0);
+ }
+ }
+ program { "enable";
+ signal: "efl,state,enabled";
+ source: "efl";
+ action: STATE_SET "default" 0.0;
+ target: "base";
+ after: "enable_text";
+ }
+ program { "enable_text";
+ script {
+ new st[31];
+ new Float:vl;
+ get_state(PART:"efl.text", st, 30, vl);
+ if (!strcmp(st, "disabled_visible"))
+ set_state(PART:"efl.text", "visible", 0.0);
+ else if (!strcmp(st, "disabled"))
+ set_state(PART:"efl.text", "default", 0.0);
+ }
+ }
+ }
+ }
+}
diff --git a/src/examples/elementary/efl_ui_theme_example_01.c b/src/examples/elementary/efl_ui_theme_example_01.c
new file mode 100644
index 0000000000..1c901a59b4
--- /dev/null
+++ b/src/examples/elementary/efl_ui_theme_example_01.c
@@ -0,0 +1,84 @@
+/*
+ * edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj
+ * gcc -o efl_ui_theme_example_01 efl_ui_theme_example_01.c `pkg-config --cflags --libs elementary`
+ */
+#define EFL_BETA_API_SUPPORT 1
+#define EFL_EO_API_SUPPORT 1
+
+#define EFL_UI_WIDGET_PROTECTED
+#include <Elementary.h>
+
+#define EXAMPLE_EDJ_FILE_PATH "./efl_ui_theme_example.edj"
+
+static void
+_btn_extension_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ static Eina_Bool loaded = EINA_TRUE;
+ Efl_Ui_Theme *default_theme;
+
+ default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
+
+ if (loaded)
+ {
+ efl_ui_theme_extension_del(default_theme, EXAMPLE_EDJ_FILE_PATH);
+ efl_text_set(event->object, "Load extension");
+ }
+ else
+ {
+ efl_ui_theme_extension_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
+ efl_text_set(event->object, "Unload extension");
+ }
+
+ loaded = !loaded;
+}
+
+EAPI_MAIN void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ Eo *win, *box;
+ Efl_Ui_Theme *default_theme;
+
+ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+ if (!ecore_file_exists(EXAMPLE_EDJ_FILE_PATH))
+ {
+ printf("efl_ui_theme_example.edj does not exist!\n"
+ "Please execute the following command first!\n"
+ "edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj\n");
+ efl_exit(0);
+ }
+
+ default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
+ efl_ui_theme_extension_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
+
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
+ efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
+ efl_text_set(efl_added, "Efl.Ui.Theme example"),
+ efl_ui_win_autodel_set(efl_added, EINA_TRUE)
+ );
+
+ box = efl_add(EFL_UI_BOX_CLASS, win,
+ efl_content_set(win, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_text_set(efl_added, "Unload extension"),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _btn_extension_clicked_cb, NULL),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_ui_widget_style_set(efl_added, "custom"),
+ efl_text_set(efl_added, "custom style"),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_text_set(efl_added, "default style"),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_ui_widget_style_set(efl_added, "anchor"),
+ efl_text_set(efl_added, "anchor style"),
+ efl_pack_end(box, efl_added));
+
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 320));
+}
+EFL_MAIN()
diff --git a/src/examples/elementary/efl_ui_theme_example_02.c b/src/examples/elementary/efl_ui_theme_example_02.c
new file mode 100644
index 0000000000..f742d1d266
--- /dev/null
+++ b/src/examples/elementary/efl_ui_theme_example_02.c
@@ -0,0 +1,84 @@
+/*
+ * edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj
+ * gcc -o efl_ui_theme_example_02 efl_ui_theme_example_02.c `pkg-config --cflags --libs elementary`
+ */
+#define EFL_BETA_API_SUPPORT 1
+#define EFL_EO_API_SUPPORT 1
+
+#define EFL_UI_WIDGET_PROTECTED
+#include <Elementary.h>
+
+#define EXAMPLE_EDJ_FILE_PATH "./efl_ui_theme_example.edj"
+
+static void
+_btn_overlay_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ static Eina_Bool loaded = EINA_TRUE;
+ Efl_Ui_Theme *default_theme;
+
+ default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
+
+ if (loaded)
+ {
+ efl_ui_theme_overlay_del(default_theme, EXAMPLE_EDJ_FILE_PATH);
+ efl_text_set(event->object, "Load overlay");
+ }
+ else
+ {
+ efl_ui_theme_overlay_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
+ efl_text_set(event->object, "Unload overlay");
+ }
+
+ loaded = !loaded;
+}
+
+EAPI_MAIN void
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+{
+ Eo *win, *box;
+ Efl_Ui_Theme *default_theme;
+
+ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+
+ if (!ecore_file_exists(EXAMPLE_EDJ_FILE_PATH))
+ {
+ printf("efl_ui_theme_example.edj does not exist!\n"
+ "Please execute the following command first!\n"
+ "edje_cc efl_ui_theme_example.edc efl_ui_theme_example.edj\n");
+ efl_exit(0);
+ }
+
+ default_theme = efl_ui_theme_default_get(efl_ui_theme_class_get());
+ efl_ui_theme_overlay_add(default_theme, EXAMPLE_EDJ_FILE_PATH);
+
+ win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
+ efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
+ efl_text_set(efl_added, "Efl.Ui.Theme example"),
+ efl_ui_win_autodel_set(efl_added, EINA_TRUE)
+ );
+
+ box = efl_add(EFL_UI_BOX_CLASS, win,
+ efl_content_set(win, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_text_set(efl_added, "Unload overlay"),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, _btn_overlay_clicked_cb, NULL),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_ui_widget_style_set(efl_added, "custom"),
+ efl_text_set(efl_added, "custom style"),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_text_set(efl_added, "default style"),
+ efl_pack_end(box, efl_added));
+
+ efl_add(EFL_UI_BUTTON_CLASS, box,
+ efl_ui_widget_style_set(efl_added, "anchor"),
+ efl_text_set(efl_added, "anchor style"),
+ efl_pack_end(box, efl_added));
+
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(300, 320));
+}
+EFL_MAIN()