aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2018-02-19 16:19:01 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2018-02-19 16:32:24 -0300
commitf22bd3aa1f4106acab3a51517d552fc2c79bcd6c (patch)
treed591a6c3908f39f47d63eea2eb143c309cb26c17 /reference
parenteina_mono: add first reference examples for Eina C# binding (diff)
downloadexamples-f22bd3aa1f4106acab3a51517d552fc2c79bcd6c.tar.gz
ui_mono: add ui_content reference example for C#
Diffstat (limited to 'reference')
-rw-r--r--reference/csharp/ui/src/meson.build7
-rw-r--r--reference/csharp/ui/src/ui_container.cs112
2 files changed, 119 insertions, 0 deletions
diff --git a/reference/csharp/ui/src/meson.build b/reference/csharp/ui/src/meson.build
index 3adaecf1..a975e0f0 100644
--- a/reference/csharp/ui/src/meson.build
+++ b/reference/csharp/ui/src/meson.build
@@ -6,3 +6,10 @@ executable('efl_reference_ui_sizing',
cs_args : efl_mono_libs,
install : true
)
+
+executable('efl_reference_ui_container',
+ files(['ui_container.cs']),
+ dependencies : deps,
+ cs_args : efl_mono_libs,
+ install : true
+)
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
new file mode 100644
index 00000000..a36a805e
--- /dev/null
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -0,0 +1,112 @@
+/*
+ * Efl.UI container exmaples.
+ *
+ * Load and pack a selection of containers.
+ * Each has it's own unique layout and methods which are demonstrated below.
+ */
+
+using System;
+
+public class Example
+{
+ // quit the app, called if the user clicks the Quit button or the window is hidden
+ static void GuiQuitCb(object sender, EventArgs e)
+ {
+ efl.ui.Config.Exit();
+ }
+
+ // Load a simple table layout into the window
+ static efl.ui.Table SetupUiTable(efl.ui.Win win)
+ {
+ efl.ui.Table table = new efl.ui.TableConcrete(win);
+
+ table.SetTableColumns(2);
+ table.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
+
+ efl.ui.Button button = new efl.ui.ButtonConcrete(win);
+ button.SetText("Long Button");
+
+ table.PackTable(button, 0, 2, 2, 1);
+
+ for (int i = 1; i <= 4; ++i)
+ {
+ efl.ui.Button btn = new efl.ui.ButtonConcrete(win);
+ btn.SetText($"Table {i}");
+ table.Pack(btn);
+ }
+
+ return table;
+ }
+
+ // Load some boxes - a horizontal one for the window layout and a vertical
+ // one to contain a flow
+ static efl.ui.Box SetupUiBoxes(efl.ui.Win win)
+ {
+ efl.ui.Box box = new efl.ui.BoxConcrete(win);
+ box.SetPackPadding(5, 0, true);
+
+ for (int i = 1; i <= 4; ++i)
+ {
+ efl.ui.Button button = new efl.ui.ButtonConcrete(win);
+ button.SetText($"Boxed {i}");
+ if (i == 2)
+ {
+ eina.Size2D sz;
+ sz.W = 100;
+ sz.H = 50;
+ button.SetHintMax(sz);
+ }
+ box.Pack(button);
+ }
+
+ return box;
+ }
+
+ public static void Main()
+ {
+ efl.All.Init(efl.Components.Ui);
+
+ efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => {
+ ewin.SetWinType(efl.ui.win.Type.Basic);
+ ewin.SetText("Hello World");
+ ewin.SetAutohide(true);
+ });
+ eina.Size2D sz;
+ sz.W = 350;
+ sz.H = 250;
+ win.SetSize(sz);
+
+ // when the user clicks "close" on a window there is a request to hide
+ win.HIDE += GuiQuitCb;
+
+ // Load a vertical and horizontal split into the window
+
+ efl.ui.Panes split = new efl.ui.PanesConcrete(win);
+ split.SetSplitRatio(0.75);
+ win.SetContent(split);
+
+ var boxes = SetupUiBoxes(win);
+ efl.ContentConcrete.static_cast(split.Part("first")).SetContent(boxes);
+
+ efl.ui.Panes horiz_split = new efl.ui.PanesConcrete(win);
+ horiz_split.SetDirection(efl.ui.Dir.Horizontal);
+ horiz_split.SetSplitRatio(0.85);
+ efl.ContentConcrete.static_cast(split.Part("second")).SetContent(horiz_split);
+
+ var table = SetupUiTable(win);
+ efl.ContentConcrete.static_cast(horiz_split.Part("first")).SetContent(table);
+
+ efl.ui.Button quit_btn = new efl.ui.ButtonConcrete(win);
+ quit_btn.SetText("Quit");
+ sz.W = 150;
+ sz.H = 30;
+ quit_btn.SetHintMax(sz);
+ quit_btn.CLICKED += GuiQuitCb;
+ efl.ContentConcrete.static_cast(horiz_split.Part("second")).SetContent(quit_btn);
+
+ // Start event loop
+ efl.ui.Config.Run();
+
+ efl.All.Shutdown();
+ }
+}