aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-18 16:53:55 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2019-01-23 14:49:38 +0100
commit500049f1eb376dbd0b07a3688546c4f11a567d6b (patch)
treeac687fb0badf8c5c3aefe45e816bf1735e44a0af /reference
parentAdd arcconfig (diff)
downloadexamples-500049f1eb376dbd0b07a3688546c4f11a567d6b.tar.gz
mono-examples: Adapt to latest syntax
Summary: Removed initializer methods as much as possible to prepare for when they are removed from the C# bindings. No functional changes in the examples. Tutorial text needs to be adapted now. Test Plan: All examples work as before (the containers one is currently broken, FML). Reviewers: lauromoura, felipealmeida, vitor.sousa Reviewed By: lauromoura Maniphest Tasks: https://phab.enlightenment.org/T7508 Differential Revision: https://phab.enlightenment.org/D7695
Diffstat (limited to 'reference')
-rw-r--r--reference/csharp/core/src/core_event.cs48
-rw-r--r--reference/csharp/core/src/core_idler.cs10
-rw-r--r--reference/csharp/core/src/core_poll.cs10
-rw-r--r--reference/csharp/ui/src/focus_main.cs69
-rw-r--r--reference/csharp/ui/src/ui_container.cs90
-rw-r--r--reference/csharp/ui/src/ui_sizing.cs47
6 files changed, 128 insertions, 146 deletions
diff --git a/reference/csharp/core/src/core_event.cs b/reference/csharp/core/src/core_event.cs
index 20f38b7b..2cb6d8e0 100644
--- a/reference/csharp/core/src/core_event.cs
+++ b/reference/csharp/core/src/core_event.cs
@@ -31,33 +31,33 @@ public class Example
mainloop.PollHighEvt += PollCb;
// This timer will control events fired by the main loop
- new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
- etimer.SetName("Timer");
+ var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger every 100ms
etimer.SetInterval(0.1);
- // To count number of timer triggers
- int tick_count = 0;
- etimer.TickEvt += (object sender, EventArgs e) => {
- string message = "Tick {0} from {1}: ";
- // Depending on the number of timer ticks, it does a different thing
- switch (tick_count) {
- case 0:
- message += "Freezing Mainloop events";
- mainloop.FreezeEvent();
- break;
- case 1:
- message += "Thawing Mainloop events";
- mainloop.ThawEvent();
- break;
- default:
- message += "Quitting";
- mainloop.Quit(new Eina.Value(0));
- break;
- }
- Console.WriteLine(message, tick_count, ((Efl.Object)sender).GetName());
- tick_count++;
- };
});
+ timer.SetName("Timer");
+ // To count number of timer triggers
+ int tick_count = 0;
+ timer.TickEvt += (object sender, EventArgs e) => {
+ string message = "Tick {0} from {1}: ";
+ // Depending on the number of timer ticks, it does a different thing
+ switch (tick_count) {
+ case 0:
+ message += "Freezing Mainloop events";
+ mainloop.FreezeEvent();
+ break;
+ case 1:
+ message += "Thawing Mainloop events";
+ mainloop.ThawEvent();
+ break;
+ default:
+ message += "Quitting";
+ mainloop.Quit(new Eina.Value(0));
+ break;
+ }
+ Console.WriteLine(message, tick_count, ((Efl.Object)sender).GetName());
+ tick_count++;
+ };
Console.WriteLine("Waiting for Timer to call back...");
diff --git a/reference/csharp/core/src/core_idler.cs b/reference/csharp/core/src/core_idler.cs
index 85c5f456..e8853e51 100644
--- a/reference/csharp/core/src/core_idler.cs
+++ b/reference/csharp/core/src/core_idler.cs
@@ -34,14 +34,14 @@ public class Example
};
// Use a timer to exit the application
- new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
+ var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger after 10ms
etimer.SetInterval(0.01);
- etimer.TickEvt += (object sender, EventArgs e) => {
- Console.WriteLine("TIMER: timer callback called, exiting.");
- mainloop.Quit(new Eina.Value(0));
- };
});
+ timer.TickEvt += (object sender, EventArgs e) => {
+ Console.WriteLine("TIMER: timer callback called, exiting.");
+ mainloop.Quit(new Eina.Value(0));
+ };
// Start the EFL main loop (and the experiment)
mainloop.Begin();
diff --git a/reference/csharp/core/src/core_poll.cs b/reference/csharp/core/src/core_poll.cs
index 6c7c16ab..3ecf7bc1 100644
--- a/reference/csharp/core/src/core_poll.cs
+++ b/reference/csharp/core/src/core_poll.cs
@@ -33,14 +33,14 @@ public class Example
};
// Use a timer to exit the application
- new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
+ var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger after 30s
etimer.SetInterval(30);
- etimer.TickEvt += (object sender, EventArgs e) => {
- Console.WriteLine("\nTIMER: timer callback called, exiting.");
- mainloop.Quit(new Eina.Value(0));
- };
});
+ timer.TickEvt += (object sender, EventArgs e) => {
+ Console.WriteLine("\nTIMER: timer callback called, exiting.");
+ mainloop.Quit(new Eina.Value(0));
+ };
// Start the EFL main loop (and the experiment)
mainloop.Begin();
diff --git a/reference/csharp/ui/src/focus_main.cs b/reference/csharp/ui/src/focus_main.cs
index 5cf64638..700172f0 100644
--- a/reference/csharp/ui/src/focus_main.cs
+++ b/reference/csharp/ui/src/focus_main.cs
@@ -16,62 +16,57 @@ public class Example
Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it
- var win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
- ewin.SetWinType(Efl.Ui.WinType.Basic);
- ewin.SetText("Focus example");
- ewin.SetAutohide(true);
- ewin.HideEvt += (object sender, EventArgs e) => {
- // Exit the EFL main loop
- Efl.Ui.Config.Exit();
- };
- });
+ var win = new Efl.Ui.Win(null);
+ win.SetWinType(Efl.Ui.WinType.Basic);
+ win.SetText("Focus example");
+ win.SetAutohide(true);
+ win.HideEvt += (object sender, EventArgs e) => {
+ // Exit the EFL main loop
+ Efl.Ui.Config.Exit();
+ };
+
// Create the main box container
- var vbox = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
- ebox.SetHintMin(new Eina.Size2D(360, 240));
- win.SetContent(ebox);
- });
+ var vbox = new Efl.Ui.Box(win);
+ vbox.SetHintMin(new Eina.Size2D(360, 240));
+ win.SetContent(vbox);
// Create some check boxes
Efl.Ui.Check first_checkbox = null;
for (int i = 0; i< 5; i++) {
- var checkbox = new Efl.Ui.Check(vbox, (Efl.Ui.Check echeck) => {
- echeck.SetText("Check " + i);
- echeck.SetHintAlign(0.5, 0.5);
- echeck.FocusChangedEvt += FocusChangedCb;
- vbox.DoPack(echeck);
- });
+ var checkbox = new Efl.Ui.Check(vbox);
+ checkbox.SetText("Check " + i);
+ checkbox.SetHintAlign(0.5, 0.5);
+ checkbox.FocusChangedEvt += FocusChangedCb;
+ vbox.DoPack(checkbox);
if (i == 0) first_checkbox = checkbox;
};
// Create an horizontal box to contain the two buttons
- var hbox = new Efl.Ui.Box(vbox, (Efl.Ui.Box ebox) => {
- ebox.SetDirection(Efl.Ui.Dir.Horizontal);
- vbox.DoPack(ebox);
- });
+ var hbox = new Efl.Ui.Box(vbox);
+ hbox.SetDirection(Efl.Ui.Dir.Horizontal);
+ vbox.DoPack(hbox);
// Create a "Focus Mover" button
- new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Focus mover");
- ebutton.FocusChangedEvt += FocusChangedCb;
- ebutton.ClickedEvt += (object sender, EventArgs e) => {
+ var button = new Efl.Ui.Button(hbox);
+ button.SetText("Focus mover");
+ button.FocusChangedEvt += FocusChangedCb;
+ button.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Focus Mover");
// Manually transfer focus to the first check box
Efl.Ui.Focus.Util.Focus(first_checkbox);
- };
- hbox.DoPack(ebutton);
- });
+ };
+ hbox.DoPack(button);
// Create a Quit button
- new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Quit");
- ebutton.FocusChangedEvt += FocusChangedCb;
- ebutton.ClickedEvt += (object sender, EventArgs e) => {
+ button = new Efl.Ui.Button(hbox);
+ button.SetText("Quit");
+ button.FocusChangedEvt += FocusChangedCb;
+ button.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Quit");
Efl.Ui.Config.Exit();
- };
- hbox.DoPack(ebutton);
- });
+ };
+ hbox.DoPack(button);
// Show the focus highlight
win.SetFocusHighlightEnabled(true);
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
index 81e883b0..88dc3d03 100644
--- a/reference/csharp/ui/src/ui_container.cs
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -12,23 +12,21 @@ public class Example
// Create a box container full of buttons
static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
{
- Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
- // Set distance between contained elements
- ebox.SetPackPadding(5, 0, true);
- });
+ Efl.Ui.Box box = new Efl.Ui.Box(win);
+ // Set distance between contained elements
+ box.SetPackPadding(5, 0, true);
for (int i = 1; i <= 4; ++i)
{
// Add 4 buttons, one below the other
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText($"Boxed {i}");
- if (i == 2)
- {
- // Button 2 has its maximum size limited, so it will be smaller
- ebutton.SetHintMax(new Eina.Size2D(100,50));
- }
- box.DoPack(ebutton);
- });
+ var button = new Efl.Ui.Button(win);
+ button.SetText($"Boxed {i}");
+ if (i == 2)
+ {
+ // Button 2 has its maximum size limited, so it will be smaller
+ button.SetHintMax(new Eina.Size2D(100,50));
+ }
+ box.DoPack(button);
}
return box;
@@ -37,26 +35,24 @@ public class Example
// Create a simple table layout
static Efl.Ui.Table CreateTable(Efl.Ui.Win win)
{
- Efl.Ui.Table table = new Efl.Ui.Table(win, (Efl.Ui.Table etable) => {
- // Table with two columns, that get filled left to right, and then top to bottom
- etable.SetTableColumns(2);
- etable.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down);
- });
+ Efl.Ui.Table table = new Efl.Ui.Table(win);
+ // Table with two columns, that get filled left to right, and then top to bottom
+ table.SetTableColumns(2);
+ table.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down);
+ Efl.Ui.Button button;
for (int i = 1; i <= 4; ++i)
{
// Add 4 buttons, following the defined table flow
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText($"Table {i}");
- table.DoPack(ebutton);
- });
+ button = new Efl.Ui.Button(win);
+ button.SetText($"Table {i}");
+ table.DoPack(button);
}
// Last button spans two table cells
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Long Button");
- table.PackTable(ebutton, 0, 2, 2, 1);
- });
+ button = new Efl.Ui.Button(win);
+ button.SetText("Long Button");
+ table.PackTable(button, 0, 2, 2, 1);
return table;
}
@@ -70,24 +66,22 @@ public class Example
Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it
- Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
- ewin.SetWinType(Efl.Ui.WinType.Basic);
- ewin.SetText("Container demo");
- ewin.SetAutohide(true);
- ewin.HideEvt += (object sender, EventArgs e) => {
- // Exit the EFL main loop
- Efl.Ui.Config.Exit();
- };
- });
+ Efl.Ui.Win win = new Efl.Ui.Win(null);
+ win.SetWinType(Efl.Ui.WinType.Basic);
+ win.SetText("Container demo");
+ win.SetAutohide(true);
+ win.HideEvt += (object sender, EventArgs e) => {
+ // Exit the EFL main loop
+ Efl.Ui.Config.Exit();
+ };
// Give the window an initial size so there is room to resize the panes.
// Otherwise, all widgets are tightly packed
win.SetSize(new Eina.Size2D(350,250));
// Create a vertically-split panes container
- Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => {
- epanes.SetSplitRatio(0.75);
- win.SetContent(epanes);
- });
+ Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win);
+ vsplit.SetSplitRatio(0.75);
+ win.SetContent(vsplit);
// Create some boxes and set them as the content of the first pane of the container
var box = CreateBox(win);
@@ -95,10 +89,9 @@ public class Example
// Create a second, horizontally-split panes container and set it as the content of
// the second pane of the first container
- Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => {
- epanes.SetDirection(Efl.Ui.Dir.Horizontal);
- epanes.SetSplitRatio(0.85);
- });
+ Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win);
+ hsplit.SetDirection(Efl.Ui.Dir.Horizontal);
+ hsplit.SetSplitRatio(0.85);
Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
// Create a table and set it as the content of the first pane of the horizontal
@@ -108,14 +101,13 @@ public class Example
// Create a button and set it as the content of the second pane of the horizontal
// container
- Efl.Ui.Button quit_btn = new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Quit");
- ebutton.SetHintMax(new Eina.Size2D(150, 30));
- ebutton.ClickedEvt += (object sender, EventArgs e) => {
+ Efl.Ui.Button quit_btn = new Efl.Ui.Button(win);
+ quit_btn.SetText("Quit");
+ quit_btn.SetHintMax(new Eina.Size2D(150, 30));
+ quit_btn.ClickedEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop
Efl.Ui.Config.Exit();
- };
- });
+ };
Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
// Start the EFL main loop
diff --git a/reference/csharp/ui/src/ui_sizing.cs b/reference/csharp/ui/src/ui_sizing.cs
index dd6e5ffb..ac25283e 100644
--- a/reference/csharp/ui/src/ui_sizing.cs
+++ b/reference/csharp/ui/src/ui_sizing.cs
@@ -19,40 +19,35 @@ public class Example
Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it
- Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
- ewin.SetWinType(Efl.Ui.WinType.Basic);
- ewin.SetText("Size Control");
- ewin.SetAutohide(true);
- ewin.HideEvt += (object sender, EventArgs e) => {
- // Exit the EFL main loop
- Efl.Ui.Config.Exit();
- };
- });
+ Efl.Ui.Win win = new Efl.Ui.Win(null);
+ win.SetWinType(Efl.Ui.WinType.Basic);
+ win.SetText("Size Control");
+ win.SetAutohide(true);
+ win.HideEvt += (object sender, EventArgs e) => {
+ // Exit the EFL main loop
+ Efl.Ui.Config.Exit();
+ };
// Create a box container
- Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
- win.SetContent(ebox);
- });
+ Efl.Ui.Box box = new Efl.Ui.Box(win);
+ win.SetContent(box);
// Create a regular button (without size hints)
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Button");
- box.DoPack(ebutton);
- });
+ var button = new Efl.Ui.Button(win);
+ button.SetText("Button");
+ box.DoPack(button);
// Create a small button (max size is limited)
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Small");
- ebutton.SetHintMax(new Eina.Size2D(50,50));
- box.DoPack(ebutton);
- });
+ button = new Efl.Ui.Button(win);
+ button.SetText("Small");
+ button.SetHintMax(new Eina.Size2D(50,50));
+ box.DoPack(button);
// Create a big button (min size is limited)
- new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
- ebutton.SetText("Big button");
- ebutton.SetHintMin(new Eina.Size2D(100,100));
- box.DoPack(ebutton);
- });
+ button = new Efl.Ui.Button(win);
+ button.SetText("Big button");
+ button.SetHintMin(new Eina.Size2D(100,100));
+ box.DoPack(button);
// Start the EFL main loop
Efl.Ui.Config.Run();