summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-12-19 17:51:26 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-14 19:09:43 +0100
commitbc239358bf75a4a34b82292afcdbc75cf49a106b (patch)
tree68db092e8317b67e9369801cea8f9955fa329a79
parenta7c5ff510ec94f4b00ebfcf91c911dc0d3fedbbb (diff)
demonstrate application and SimpleApplicationdevs/bu5hm4n/POC
-rw-r--r--apps/csharp/life/src/life_main.cs31
-rw-r--r--apps/csharp/texteditor/src/texteditor_main.cs25
-rw-r--r--reference/c/ui/src/ui_translation.c6
3 files changed, 32 insertions, 30 deletions
diff --git a/apps/csharp/life/src/life_main.cs b/apps/csharp/life/src/life_main.cs
index e59b61de..9c16c109 100644
--- a/apps/csharp/life/src/life_main.cs
+++ b/apps/csharp/life/src/life_main.cs
@@ -1,9 +1,13 @@
1using System; 1using System;
2 2
3public class LifeWindow 3public class LifeWindow : Efl.Csharp.Application
4{ 4{
5 private LifeBoard lifeBoard; 5 private LifeBoard lifeBoard;
6 private LifeRender lifeRender; 6 private LifeRender lifeRender;
7 private Efl.Ui.Win win;
8 public LifeWindow() {
9
10 }
7 11
8 void ResizeEvt(object sender, EventArgs ev) 12 void ResizeEvt(object sender, EventArgs ev)
9 { 13 {
@@ -30,14 +34,13 @@ public class LifeWindow
30 34
31 void KeyDownEvt(object sender, Efl.Input.InterfaceKeyDownEvt_Args ev) 35 void KeyDownEvt(object sender, Efl.Input.InterfaceKeyDownEvt_Args ev)
32 { 36 {
33 Efl.Ui.Win win = (Efl.Ui.Win)sender;
34 if (ev.arg.GetKey() == "space") 37 if (ev.arg.GetKey() == "space")
35 lifeBoard.TogglePause(win); 38 lifeBoard.TogglePause(win);
36 } 39 }
37 40
38 public LifeWindow() 41 protected override void OnInitialize(Eina.Array<System.String> args)
39 { 42 {
40 Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { 43 win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
41 ewin.SetWinType(Efl.Ui.WinType.Basic); 44 ewin.SetWinType(Efl.Ui.WinType.Basic);
42 ewin.SetText("EFL Life"); 45 ewin.SetText("EFL Life");
43 ewin.SetAutohide(true); 46 ewin.SetAutohide(true);
@@ -62,19 +65,27 @@ public class LifeWindow
62 65
63 lifeBoard.Run(win); 66 lifeBoard.Run(win);
64 } 67 }
68 protected void OnPause() {
69 if (win != null) {
70 lifeBoard.TogglePause(win);
71 }
72 }
73 protected void OnResume() {
74 if (win != null) {
75 lifeBoard.TogglePause(win);
76 }
77 }
78 protected void OnTerminate() {
79 Console.WriteLine("Goodbye.");
80 }
65} 81}
66 82
67public class Example 83public class Example
68{ 84{
69 public static void Main() 85 public static void Main()
70 { 86 {
71 Efl.All.Init(Efl.Components.Ui);
72
73 var lifeWin = new LifeWindow(); 87 var lifeWin = new LifeWindow();
74 88
75 // start the mainloop 89 lifeWin.Launch();
76 Efl.Ui.Config.Run();
77
78 Efl.All.Shutdown();
79 } 90 }
80} 91}
diff --git a/apps/csharp/texteditor/src/texteditor_main.cs b/apps/csharp/texteditor/src/texteditor_main.cs
index 69e95bf4..a4fb0f63 100644
--- a/apps/csharp/texteditor/src/texteditor_main.cs
+++ b/apps/csharp/texteditor/src/texteditor_main.cs
@@ -17,7 +17,7 @@
17 17
18using System; 18using System;
19 19
20public class TextEditor 20public class TextEditor : Efl.Csharp.Application
21{ 21{
22 private Efl.Ui.Win win; // The main window 22 private Efl.Ui.Win win; // The main window
23 private Efl.Ui.Text editorTextBox; // The main text entry 23 private Efl.Ui.Text editorTextBox; // The main text entry
@@ -31,6 +31,10 @@ public class TextEditor
31 private readonly string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), 31 private readonly string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(),
32 "texteditor_example.txt"); 32 "texteditor_example.txt");
33 33
34 public TextEditor() {
35
36 }
37
34 // Quits the application 38 // Quits the application
35 private void GUIQuitCb(object sender, EventArgs ea) 39 private void GUIQuitCb(object sender, EventArgs ea)
36 { 40 {
@@ -154,7 +158,7 @@ public class TextEditor
154 } 158 }
155 159
156 // Builds the user interface for the text editor 160 // Builds the user interface for the text editor
157 public TextEditor() 161 protected override void OnInitialize(Eina.Array<System.String> args)
158 { 162 {
159 // Create a window and initialize it 163 // Create a window and initialize it
160 win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => { 164 win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => {
@@ -185,13 +189,6 @@ public class TextEditor
185 // Initial refresh of the toolbar buttons 189 // Initial refresh of the toolbar buttons
186 GUIToolbarRefresh(); 190 GUIToolbarRefresh();
187 } 191 }
188
189 // This method won't return until the application quits
190 public void Run()
191 {
192 // Start the EFL main loop
193 Efl.Ui.Config.Run();
194 }
195} 192}
196 193
197public class Example 194public class Example
@@ -201,14 +198,8 @@ public class Example
201#endif 198#endif
202 public static void Main() 199 public static void Main()
203 { 200 {
204 // Initialize EFL and all UI components 201 TextEditor editor = new TextEditor();
205 Efl.All.Init(Efl.Components.Ui); 202 editor.Launch();
206
207 var textEditor = new TextEditor();
208 textEditor.Run();
209
210 // Shutdown EFL
211 Efl.All.Shutdown();
212 } 203 }
213} 204}
214 205
diff --git a/reference/c/ui/src/ui_translation.c b/reference/c/ui/src/ui_translation.c
index b8aa9884..f4e5e48c 100644
--- a/reference/c/ui/src/ui_translation.c
+++ b/reference/c/ui/src/ui_translation.c
@@ -45,15 +45,15 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
45 efl_content_set(win, efl_added)); 45 efl_content_set(win, efl_added));
46 46
47 efl_add(EFL_UI_BUTTON_CLASS, win, 47 efl_add(EFL_UI_BUTTON_CLASS, win,
48 efl_ui_translatable_text_set(efl_added, "Translations", _TEXT_DOMAIN), 48// efl_ui_translatable_text_set(efl_added, "Translations", _TEXT_DOMAIN),
49 efl_pack_end(box, efl_added)); 49 efl_pack_end(box, efl_added));
50 50
51 efl_add(EFL_UI_BUTTON_CLASS, win, 51 efl_add(EFL_UI_BUTTON_CLASS, win,
52 efl_ui_translatable_text_set(efl_added, "Help", _TEXT_DOMAIN), 52// efl_ui_translatable_text_set(efl_added, "Help", _TEXT_DOMAIN),
53 efl_pack_end(box, efl_added)); 53 efl_pack_end(box, efl_added));
54 54
55 efl_add(EFL_UI_BUTTON_CLASS, win, 55 efl_add(EFL_UI_BUTTON_CLASS, win,
56 efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN), 56// efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN),
57 efl_pack_end(box, efl_added), 57 efl_pack_end(box, efl_added),
58 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)), 58 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)),
59 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED, 59 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,