summaryrefslogtreecommitdiff
path: root/reference
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
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')
-rw-r--r--reference/c/ui/src/focus_main.c81
-rw-r--r--reference/c/ui/src/meson.build7
-rw-r--r--reference/csharp/ui/src/focus_main.cs69
-rw-r--r--reference/csharp/ui/src/meson.build7
4 files changed, 164 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
diff --git a/reference/csharp/ui/src/focus_main.cs b/reference/csharp/ui/src/focus_main.cs
new file mode 100644
index 00000000..741acb45
--- /dev/null
+++ b/reference/csharp/ui/src/focus_main.cs
@@ -0,0 +1,69 @@
1using System;
2
3public class Example
4{
5 public static void QuitCb(object sender, EventArgs e)
6 {
7 Console.WriteLine("Clicked Quit");
8 efl.ui.Config.Exit();
9 }
10
11 public static void AboutCb(object sender, EventArgs e)
12 {
13 Console.WriteLine("Clicked About");
14 }
15
16 public static void FocusChangedCb(object sender, EventArgs e)
17 {
18 Console.WriteLine($"Focus for object {((efl.IText)sender).GetText()} changed to {((efl.ui.IWidget)sender).GetFocus()}");
19 }
20
21 public static void Main()
22 {
23 efl.All.Init(efl.Components.Ui);
24
25 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
26 ewin.SetWinType(efl.ui.Win_Type.Basic);
27 ewin.SetText("Hello World");
28 ewin.SetAutohide(true);
29 });
30 win.HideEvt += QuitCb;
31
32 efl.ui.IBox box = new efl.ui.Box(win);
33 eina.Size2D sz;
34 sz.W = 360;
35 sz.H = 240;
36 box.SetHintMin(sz);
37 win.SetContent(box);
38
39 efl.ui.IText text = new efl.ui.Text(box);
40 text.SetText("Label");
41 text.SetEditable(false);
42 text.FocusChangedEvt += FocusChangedCb;
43 box.DoPack(text);
44
45 efl.ui.IBox hbox = new efl.ui.Box(box);
46 hbox.SetDirection(efl.ui.Dir.Horizontal);
47 hbox.SetHintWeight(1.0, 0.1);
48 box.DoPack(hbox);
49
50 efl.ui.IButton about = new efl.ui.Button(hbox);
51 about.SetText("About");
52 about.FocusChangedEvt += FocusChangedCb;
53 about.ClickedEvt += AboutCb;
54 hbox.DoPack(about);
55
56 efl.ui.IButton quit = new efl.ui.Button(hbox);
57 quit.SetText("Quit");
58 quit.FocusChangedEvt += FocusChangedCb;
59 quit.ClickedEvt += QuitCb;
60 hbox.DoPack(quit);
61
62 efl.ui.focus.Util.Focus(about);
63
64 efl.ui.Config.Run();
65
66 efl.All.Shutdown();
67 }
68}
69
diff --git a/reference/csharp/ui/src/meson.build b/reference/csharp/ui/src/meson.build
index a975e0f0..12a5ef33 100644
--- a/reference/csharp/ui/src/meson.build
+++ b/reference/csharp/ui/src/meson.build
@@ -13,3 +13,10 @@ executable('efl_reference_ui_container',
13 cs_args : efl_mono_libs, 13 cs_args : efl_mono_libs,
14 install : true 14 install : true
15) 15)
16
17executable('efl_reference_ui_focus',
18 files(['focus_main.cs']),
19 dependencies : deps,
20 cs_args : efl_mono_libs,
21 install : true
22)