summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--reference/csharp/ui/src/ui_container.cs158
-rw-r--r--reference/csharp/ui/src/ui_sizing.cs71
2 files changed, 125 insertions, 104 deletions
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
index 714572d3..fe5cc976 100644
--- a/reference/csharp/ui/src/ui_container.cs
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -1,112 +1,128 @@
1/* 1/*
2 * Efl.UI container exmaples. 2 * Efl.UI container examples.
3 * 3 *
4 * Load and pack a selection of containers. 4 * Load and pack a selection of containers.
5 * Each has it's own unique layout and methods which are demonstrated below. 5 * Each has its own unique layout and methods which are demonstrated below.
6 */ 6 */
7 7
8using System; 8using System;
9 9
10public class Example 10public class Example
11{ 11{
12 // quit the app, called if the user clicks the Quit button or the window is hidden 12 // Create a box container full of buttons
13 static void GuiQuitCb(object sender, EventArgs e) 13 static efl.ui.IBox CreateBox(efl.ui.IWin win)
14 { 14 {
15 efl.ui.Config.Exit(); 15 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
16 } 16 // Set distance between contained elements
17 17 ebox.SetPackPadding(5, 0, true);
18 // Load a simple table layout into the window 18 });
19 static efl.ui.ITable SetupUiTable(efl.ui.IWin win)
20 {
21 efl.ui.ITable table = new efl.ui.Table(win);
22
23 table.SetTableColumns(2);
24 table.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
25
26 efl.ui.IButton button = new efl.ui.Button(win);
27 button.SetText("Long Button");
28
29 table.PackTable(button, 0, 2, 2, 1);
30 19
31 for (int i = 1; i <= 4; ++i) 20 for (int i = 1; i <= 4; ++i)
32 { 21 {
33 efl.ui.IButton btn = new efl.ui.Button(win); 22 // Add 4 buttons, one below the other
34 btn.SetText($"Table {i}"); 23 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
35 table.DoPack(btn); 24 ebutton.SetText($"Boxed {i}");
25 if (i == 2)
26 {
27 // Button 2 has its maximum size limited, so it will be smaller
28 ebutton.SetHintMax(new eina.Size2D(100,50));
29 }
30 box.DoPack(ebutton);
31 });
36 } 32 }
37 33
38 return table; 34 return box;
39 } 35 }
40 36
41 // Load some boxes - a horizontal one for the window layout and a vertical 37 // Create a simple table layout
42 // one to contain a flow 38 static efl.ui.ITable CreateTable(efl.ui.IWin win)
43 static efl.ui.IBox SetupUiBoxes(efl.ui.IWin win)
44 { 39 {
45 efl.ui.IBox box = new efl.ui.Box(win); 40 efl.ui.ITable table = new efl.ui.Table(win, (efl.ui.ITable etable) => {
46 box.SetPackPadding(5, 0, true); 41 // Table with two columns, that get filled left to right, and then top to bottom
42 etable.SetTableColumns(2);
43 etable.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
44 });
47 45
48 for (int i = 1; i <= 4; ++i) 46 for (int i = 1; i <= 4; ++i)
49 { 47 {
50 efl.ui.IButton button = new efl.ui.Button(win); 48 // Add 4 buttons, following the defined table flow
51 button.SetText($"Boxed {i}"); 49 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
52 if (i == 2) 50 ebutton.SetText($"Table {i}");
53 { 51 table.DoPack(ebutton);
54 eina.Size2D sz; 52 });
55 sz.W = 100;
56 sz.H = 50;
57 button.SetHintMax(sz);
58 }
59 box.DoPack(button);
60 } 53 }
61 54
62 return box; 55 // Last button spans two table cells
56 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
57 ebutton.SetText("Long Button");
58 table.PackTable(ebutton, 0, 2, 2, 1);
59 });
60
61 return table;
63 } 62 }
64 63
64#if WIN32
65 [STAThreadAttribute()]
66#endif
65 public static void Main() 67 public static void Main()
66 { 68 {
69 // Initialize EFL and all UI components
67 efl.All.Init(efl.Components.Ui); 70 efl.All.Init(efl.Components.Ui);
68 71
72 // Create a window and initialize it
69 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => { 73 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
70 ewin.SetWinType(efl.ui.Win_Type.Basic); 74 ewin.SetWinType(efl.ui.Win_Type.Basic);
71 ewin.SetText("Hello World"); 75 ewin.SetText("Container demo");
72 ewin.SetAutohide(true); 76 ewin.SetAutohide(true);
77 ewin.HideEvt += (object sender, EventArgs e) => {
78 // Exit the EFL main loop
79 efl.ui.Config.Exit();
80 };
81 });
82 // Give the window an initial size so there is room to resize the panes.
83 // Otherwise, all widgets are tightly packed
84 win.SetSize(new eina.Size2D(350,250));
85
86 // Create a vertically-split panes container
87 efl.ui.IPanes vsplit = new efl.ui.Panes(win, (efl.ui.IPanes epanes) => {
88 epanes.SetSplitRatio(0.75);
89 win.SetContent(epanes);
73 }); 90 });
74 eina.Size2D sz;
75 sz.W = 350;
76 sz.H = 250;
77 win.SetSize(sz);
78
79 // when the user clicks "close" on a window there is a request to hide
80 win.HideEvt += GuiQuitCb;
81
82 // Load a vertical and horizontal split into the window
83
84 efl.ui.IPanes split = new efl.ui.Panes(win);
85 split.SetSplitRatio(0.75);
86 win.SetContent(split);
87
88 var boxes = SetupUiBoxes(win);
89 efl.Content.static_cast(split.GetPart("first")).SetContent(boxes);
90
91 efl.ui.IPanes horiz_split = new efl.ui.Panes(win);
92 horiz_split.SetDirection(efl.ui.Dir.Horizontal);
93 horiz_split.SetSplitRatio(0.85);
94 efl.Content.static_cast(split.GetPart("second")).SetContent(horiz_split);
95 91
96 var table = SetupUiTable(win); 92 // Create some boxes and set them as the content of the first pane of the container
97 efl.Content.static_cast(horiz_split.GetPart("first")).SetContent(table); 93 var box = CreateBox(win);
94 efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box);
98 95
99 efl.ui.IButton quit_btn = new efl.ui.Button(win); 96 // Create a second, horizontally-split panes container and set it as the content of
100 quit_btn.SetText("Quit"); 97 // the second pane of the first container
101 sz.W = 150; 98 efl.ui.IPanes hsplit = new efl.ui.Panes(win, (efl.ui.IPanes epanes) => {
102 sz.H = 30; 99 epanes.SetDirection(efl.ui.Dir.Horizontal);
103 quit_btn.SetHintMax(sz); 100 epanes.SetSplitRatio(0.85);
104 quit_btn.ClickedEvt += GuiQuitCb; 101 });
105 efl.Content.static_cast(horiz_split.GetPart("second")).SetContent(quit_btn); 102 efl.Content.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
103
104 // Create a table and set it as the content of the first pane of the horizontal
105 // container
106 var table = CreateTable(win);
107 efl.Content.static_cast(hsplit.GetPart("first")).SetContent(table);
108
109 // Create a button and set it as the content of the second pane of the horizontal
110 // container
111 efl.ui.IButton quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
112 ebutton.SetText("Quit");
113 ebutton.SetHintMax(new eina.Size2D(150, 30));
114 ebutton.ClickedEvt += (object sender, EventArgs e) => {
115 // Exit the EFL main loop
116 efl.ui.Config.Exit();
117 };
118 });
119 efl.Content.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
106 120
107 // Start event loop 121 // Start the EFL main loop
108 efl.ui.Config.Run(); 122 efl.ui.Config.Run();
109 123
124 // Shutdown EFL
110 efl.All.Shutdown(); 125 efl.All.Shutdown();
111 } 126 }
112} 127}
128
diff --git a/reference/csharp/ui/src/ui_sizing.cs b/reference/csharp/ui/src/ui_sizing.cs
index 2f74b60e..b56cf482 100644
--- a/reference/csharp/ui/src/ui_sizing.cs
+++ b/reference/csharp/ui/src/ui_sizing.cs
@@ -2,57 +2,62 @@
2 * Efl.UI sizing examples. 2 * Efl.UI sizing examples.
3 * 3 *
4 * Demonstrate how to use the sizing api from Efl.Gfx. 4 * Demonstrate how to use the sizing api from Efl.Gfx.
5 * We load a box with 3 buttons, one with default sizing, one that has a max 5 * We load a box with 3 buttons, one with default sizing, one that has a max size
6 * and the last has a min size. Try resizing the window to see how this changes. 6 * and the last one has a min size. Try resizing the window to see how this changes.
7 */ 7 */
8 8
9using System; 9using System;
10 10
11public class Example 11public class Example
12{ 12{
13#if WIN32
14 [STAThreadAttribute()]
15#endif
13 public static void Main() 16 public static void Main()
14 { 17 {
18 // Initialize EFL and all UI components
15 efl.All.Init(efl.Components.Ui); 19 efl.All.Init(efl.Components.Ui);
16 20
21 // Create a window and initialize it
17 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => { 22 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
18 ewin.SetWinType(efl.ui.Win_Type.Basic); 23 ewin.SetWinType(efl.ui.Win_Type.Basic);
19 ewin.SetText("Size Control"); 24 ewin.SetText("Size Control");
20 ewin.SetAutohide(true); 25 ewin.SetAutohide(true);
26 ewin.HideEvt += (object sender, EventArgs e) => {
27 // Exit the EFL main loop
28 efl.ui.Config.Exit();
29 };
21 }); 30 });
22 eina.Size2D sz;
23 sz.W = 320;
24 sz.H = 320;
25 win.SetSize(sz);
26
27 // when the user clicks "close" on a window there is a request to hide
28 win.HideEvt += (object sender, EventArgs e) => {
29 // quit the app, called if the window is hidden
30 efl.ui.Config.Exit();
31 };
32
33 efl.ui.IBox box = new efl.ui.Box(win);
34 win.SetContent(box);
35
36 efl.ui.IButton button = new efl.ui.Button(win);
37 button.SetText("Button");
38 box.DoPack(button);
39
40 efl.ui.IButton small_btn = new efl.ui.Button(win);
41 small_btn.SetText("Small");
42 sz.W = 50;
43 sz.H = 50;
44 small_btn.SetHintMax(sz);
45 box.DoPack(small_btn);
46
47 efl.ui.IButton big_btn = new efl.ui.Button(win);
48 big_btn.SetText("Big Button");
49 sz.W = 100;
50 sz.H = 100;
51 big_btn.SetHintMin(sz);
52 box.DoPack(big_btn);
53 31
32 // Create a box container
33 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
34 win.SetContent(ebox);
35 });
36
37 // Create a regular button (without size hints)
38 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
39 ebutton.SetText("Button");
40 box.DoPack(ebutton);
41 });
42
43 // Create a small button (max size is limited)
44 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
45 ebutton.SetText("Small");
46 ebutton.SetHintMax(new eina.Size2D(50,50));
47 box.DoPack(ebutton);
48 });
49
50 // Create a big button (min size is limited)
51 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
52 ebutton.SetText("Big button");
53 ebutton.SetHintMin(new eina.Size2D(100,100));
54 box.DoPack(ebutton);
55 });
56
57 // Start the EFL main loop
54 efl.ui.Config.Run(); 58 efl.ui.Config.Run();
55 59
60 // Shutdown EFL
56 efl.All.Shutdown(); 61 efl.All.Shutdown();
57 } 62 }
58} 63}