summaryrefslogtreecommitdiff
path: root/reference/c/ui
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-09-18 11:35:36 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-09-18 12:43:11 -0300
commitd1e530d25604d59a2e3f86ef59a5ecd47564800c (patch)
tree221a8e0ed31c9cca441b30648c57cf9554eebe70 /reference/c/ui
parentfce18f2ebe3dd22d817356594ee08dcd83cc3490 (diff)
Moved focus example to proper place
Summary: It is a guide, not a tutorial. Reviewers: vitor.sousa, lauromoura Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D7055
Diffstat (limited to 'reference/c/ui')
-rw-r--r--reference/c/ui/src/focus_main.c81
-rw-r--r--reference/c/ui/src/meson.build7
2 files changed, 88 insertions, 0 deletions
diff --git a/reference/c/ui/src/focus_main.c b/reference/c/ui/src/focus_main.c
new file mode 100644
index 00000000..9eaf79c6
--- /dev/null
+++ b/reference/c/ui/src/focus_main.c
@@ -0,0 +1,81 @@
1#define EFL_EO_API_SUPPORT 1
2#define EFL_BETA_API_SUPPORT 1
3
4#include <Eina.h>
5#include <Elementary.h>
6#include <Efl_Ui.h>
7
8static void
9_gui_about_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
10{
11 printf("Clicked About\n");
12}
13
14static void
15_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
16{
17 printf("Clicked Quit\n");
18 efl_exit(0);
19}
20
21static void
22_focus_changed(void *data EINA_UNUSED, const Efl_Event *event)
23{
24 printf("Focus for object '%s' changed to %d\n",
25 efl_text_get(event->object), efl_ui_focus_object_focus_get(event->object));
26}
27
28static void
29_gui_setup()
30{
31 Eo *win, *box, *hbox, *about;
32
33 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
34 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
35 efl_text_set(efl_added, "Hello World"),
36 efl_event_callback_add(efl_added,
37 EFL_UI_WIN_EVENT_DELETE_REQUEST,
38 _gui_quit_clicked_cb, NULL),
39 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
40
41 box = efl_add(EFL_UI_BOX_CLASS, win,
42 efl_content_set(win, efl_added),
43 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
44
45 efl_add(EFL_UI_TEXT_CLASS, box,
46 efl_text_set(efl_added, "Label"),
47 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
48 efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
49 _focus_changed, NULL),
50 efl_pack(box, efl_added));
51
52 hbox = efl_add(EFL_UI_BOX_CLASS, box,
53 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
54 efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
55 efl_pack(box, efl_added));
56
57 about = efl_add(EFL_UI_BUTTON_CLASS, hbox,
58 efl_text_set(efl_added, "About"),
59 efl_pack(hbox, efl_added),
60 efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
61 _focus_changed, NULL),
62 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
63 _gui_about_clicked_cb, efl_added));
64
65 efl_add(EFL_UI_BUTTON_CLASS, hbox,
66 efl_text_set(efl_added, "Quit"),
67 efl_pack(hbox, efl_added),
68 efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
69 _focus_changed, NULL),
70 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
71 _gui_quit_clicked_cb, efl_added));
72
73 efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about);
74}
75
76EAPI_MAIN void
77efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
78{
79 _gui_setup();
80}
81EFL_MAIN()
diff --git a/reference/c/ui/src/meson.build b/reference/c/ui/src/meson.build
index 07ff9fc6..f575a6a8 100644
--- a/reference/c/ui/src/meson.build
+++ b/reference/c/ui/src/meson.build
@@ -21,3 +21,10 @@ executable('efl_reference_ui_translation',
21 install : true 21 install : true
22) 22)
23 23
24executable('efl_reference_ui_focus',
25 files(['focus_main.c']),
26 dependencies : deps,
27 include_directories : inc,
28 install : true
29)
30