summaryrefslogtreecommitdiff
path: root/src/examples/elementary/efl_ui_unit_converter.cs
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-11-29 21:04:37 -0200
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-11-29 21:29:48 -0200
commit3623753c1d6b893955a1c31e8559a2312f674192 (patch)
treee862682ff92d34ce4ebf44c95efa24ba3a57fe7a /src/examples/elementary/efl_ui_unit_converter.cs
parenteec7bc458eee333fd7237a3bd43e8c2c884f21ca (diff)
csharp: Change to new class API.
Summary: As discussed in T7204: - Eo Interfaces/mixins -> C# Interfaces with concrete class implementations - Eo Regular/Abstracts -> Proper C# classes - Added some new generators and helper methods. - Refactored the class generator, splitting into helper methods Eo handles now are stored only in the "root" class in any given inheritance tree (generally, Efl.Object), and accessible to each child. Methods also are defined in a single place instead of repeatedly generated in everyfile, reducing the size of the generated .dll from 30MB to around 4.5MB. Mixins are generated as C# interfaces but any regular class it inherits from is lost, as we can't have interfaces inheriting from regular classes. This will be dealt with in a later commit. Summary of API Changes: - Merged Inherit/Concrete classes. (These suffixes disappear from regular classes). - Interface still have implementations with 'Concrete' suffix for when they are returned from methods. - Removed 'I' from interface names. - Removed interfaces for regular/abstract Eo classes. - Concrete classes for interfaces/mixins hold the event argument struct. - Removed '_' from classes, enums, structs, etc, as indicated in C# naming conventions. - Namespaces are now Camel.Cased. - Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass Also renamed the test classes as after the namespace change, the test namespace Test can conflict with the helper Test namespace. (And use more meaningful names than Test.Testing...) Also Fixes T7336 by removing a deprecated example and adding efl_loop_timer_example to build system. Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper fields. The native handlers are used in the manual binding. Still need to work: - As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize" from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on the interface and implemented "namespaced" in the classes, requiring the cast to the interface to access the event. - The Mixin Conundrum. Mixin inheritance will be dealt in a future commit. Depends on D7260 Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7451, T7336 Differential Revision: https://phab.enlightenment.org/D7262
Diffstat (limited to 'src/examples/elementary/efl_ui_unit_converter.cs')
-rw-r--r--src/examples/elementary/efl_ui_unit_converter.cs56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/examples/elementary/efl_ui_unit_converter.cs b/src/examples/elementary/efl_ui_unit_converter.cs
index 3f6c7abd26..5bbbe1723a 100644
--- a/src/examples/elementary/efl_ui_unit_converter.cs
+++ b/src/examples/elementary/efl_ui_unit_converter.cs
@@ -14,16 +14,16 @@ public class Example
14 return miles * KMS_PER_MILE; 14 return miles * KMS_PER_MILE;
15 } 15 }
16 16
17 private static void ShowErrorPopup(efl.ui.Win win, string message) 17 private static void ShowErrorPopup(Efl.Ui.Win win, string message)
18 { 18 {
19 efl.ui.IAlert_Popup popup = new efl.ui.Alert_Popup(win); 19 Efl.Ui.AlertPopup popup = new Efl.Ui.AlertPopup(win);
20 efl.ui.Text popup_text = new efl.ui.Text(popup); 20 Efl.Ui.Text popup_text = new Efl.Ui.Text(popup);
21 popup_text.SetText($"Error: {message}"); 21 popup_text.SetText($"Error: {message}");
22 popup.SetContent(popup_text); 22 popup.SetContent(popup_text);
23 popup.SetVisible(true); 23 popup.SetVisible(true);
24 popup.SetButton(efl.ui.Alert_Popup_Button.Positive, "Ok", null); 24 popup.SetButton(Efl.Ui.AlertPopupButton.Positive, "Ok", null);
25 popup.SetSize(new eina.Size2D(150, 30)); 25 popup.SetSize(new Eina.Size2D(150, 30));
26 popup.ButtonClickedEvt += (object sender, efl.ui.Alert_Popup.ButtonClickedEvt_Args e) => { 26 popup.ButtonClickedEvt += (object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args e) => {
27 popup.SetParent(null); 27 popup.SetParent(null);
28 popup.Invalidate(); 28 popup.Invalidate();
29 }; 29 };
@@ -37,34 +37,34 @@ public class Example
37 public static void Main() { 37 public static void Main() {
38 int W = 120; 38 int W = 120;
39 int H = 30; 39 int H = 30;
40 eina.Size2D size = new eina.Size2D(W, H); 40 Eina.Size2D size = new Eina.Size2D(W, H);
41 41
42 efl.All.Init(efl.Components.Ui); 42 Efl.All.Init(Efl.Components.Ui);
43 43
44 efl.ui.Win win = new efl.ui.Win(null); 44 Efl.Ui.Win win = new Efl.Ui.Win(null);
45 win.SetText("C# Unit Converter"); 45 win.SetText("C# Unit Converter");
46 win.SetAutohide(true); 46 win.SetAutohide(true);
47 47
48 efl.ui.Box_Flow box = new efl.ui.Box_Flow(win); 48 Efl.Ui.BoxFlow box = new Efl.Ui.BoxFlow(win);
49 box.SetDirection(efl.ui.Dir.Horizontal); 49 box.SetDirection(Efl.Ui.Dir.Horizontal);
50 50
51 efl.ui.Box_Flow miles_box = new efl.ui.Box_Flow(box); 51 Efl.Ui.BoxFlow miles_box = new Efl.Ui.BoxFlow(box);
52 miles_box.SetDirection(efl.ui.Dir.Down); 52 miles_box.SetDirection(Efl.Ui.Dir.Down);
53 53
54 box.DoPack(miles_box); 54 box.DoPack(miles_box);
55 55
56 efl.ui.Text miles_label = new efl.ui.Text(miles_box); 56 Efl.Ui.Text miles_label = new Efl.Ui.Text(miles_box);
57 miles_label.SetText("Miles:"); 57 miles_label.SetText("Miles:");
58 miles_label.SetSize(size); 58 miles_label.SetSize(size);
59 miles_label.SetVisible(true); 59 miles_label.SetVisible(true);
60 60
61 efl.ui.Text_Editable miles_input = new efl.ui.Text_Editable(miles_box); 61 Efl.Ui.TextEditable miles_input = new Efl.Ui.TextEditable(miles_box);
62 miles_input.SetText(""); 62 miles_input.SetText("");
63 miles_input.SetScrollable(true); 63 miles_input.SetScrollable(true);
64 miles_input.SetSize(size); 64 miles_input.SetSize(size);
65 miles_input.SetVisible(true); 65 miles_input.SetVisible(true);
66 66
67 efl.ui.IButton miles_button = new efl.ui.Button(miles_box); 67 Efl.Ui.Button miles_button = new Efl.Ui.Button(miles_box);
68 miles_button.SetText("To Km"); 68 miles_button.SetText("To Km");
69 miles_button.SetSize(size); 69 miles_button.SetSize(size);
70 miles_button.SetVisible(true); 70 miles_button.SetVisible(true);
@@ -74,23 +74,23 @@ public class Example
74 miles_box.DoPack(miles_button); 74 miles_box.DoPack(miles_button);
75 75
76 76
77 efl.ui.Box_Flow kms_box = new efl.ui.Box_Flow(box); 77 Efl.Ui.BoxFlow kms_box = new Efl.Ui.BoxFlow(box);
78 kms_box.SetDirection(efl.ui.Dir.Down); 78 kms_box.SetDirection(Efl.Ui.Dir.Down);
79 79
80 box.DoPack(kms_box); 80 box.DoPack(kms_box);
81 81
82 efl.ui.Text kms_label = new efl.ui.Text(kms_box); 82 Efl.Ui.Text kms_label = new Efl.Ui.Text(kms_box);
83 kms_label.SetText("Kilometers:"); 83 kms_label.SetText("Kilometers:");
84 kms_label.SetSize(size); 84 kms_label.SetSize(size);
85 kms_label.SetVisible(true); 85 kms_label.SetVisible(true);
86 86
87 efl.ui.Text_Editable kms_input = new efl.ui.Text_Editable(kms_box); 87 Efl.Ui.TextEditable kms_input = new Efl.Ui.TextEditable(kms_box);
88 kms_input.SetText(""); 88 kms_input.SetText("");
89 kms_input.SetScrollable(true); 89 kms_input.SetScrollable(true);
90 kms_input.SetSize(size); 90 kms_input.SetSize(size);
91 kms_input.SetVisible(true); 91 kms_input.SetVisible(true);
92 92
93 efl.ui.IButton kms_button = new efl.ui.Button(kms_box); 93 Efl.Ui.Button kms_button = new Efl.Ui.Button(kms_box);
94 kms_button.SetText("To Miles"); 94 kms_button.SetText("To Miles");
95 kms_button.SetSize(size); 95 kms_button.SetSize(size);
96 kms_button.SetVisible(true); 96 kms_button.SetVisible(true);
@@ -99,7 +99,7 @@ public class Example
99 kms_box.DoPack(kms_input); 99 kms_box.DoPack(kms_input);
100 kms_box.DoPack(kms_button); 100 kms_box.DoPack(kms_button);
101 101
102 kms_button.ClickedEvt += (object sender, EventArgs e) => { 102 ((Efl.Ui.Clickable)kms_button).ClickedEvt += (object sender, EventArgs e) => {
103 try 103 try
104 { 104 {
105 string text = kms_input.GetText(); 105 string text = kms_input.GetText();
@@ -115,7 +115,7 @@ public class Example
115 } 115 }
116 }; 116 };
117 117
118 miles_button.ClickedEvt += (object sender, EventArgs e) => { 118 ((Efl.Ui.Clickable)miles_button).ClickedEvt += (object sender, EventArgs e) => {
119 try 119 try
120 { 120 {
121 string text = miles_input.GetText(); 121 string text = miles_input.GetText();
@@ -134,17 +134,17 @@ public class Example
134 kms_box.SetVisible(true); 134 kms_box.SetVisible(true);
135 miles_box.SetVisible(true); 135 miles_box.SetVisible(true);
136 136
137 box.SetPosition(new eina.Position2D(20, 30)); 137 box.SetPosition(new Eina.Position2D(20, 30));
138 box.SetVisible(true); 138 box.SetVisible(true);
139 139
140 win.SetPosition(new eina.Position2D(200, 200)); 140 win.SetPosition(new Eina.Position2D(200, 200));
141 141
142 win.SetSize(new eina.Size2D(400, 120)); 142 win.SetSize(new Eina.Size2D(400, 120));
143 win.SetVisible(true); 143 win.SetVisible(true);
144 144
145 efl.ui.Config.Run(); 145 Efl.Ui.Config.Run();
146 146
147 efl.All.Shutdown(); 147 Efl.All.Shutdown();
148 } 148 }
149 149
150} 150}