summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_container.cs
diff options
context:
space:
mode:
Diffstat (limited to 'reference/csharp/ui/src/ui_container.cs')
-rw-r--r--reference/csharp/ui/src/ui_container.cs90
1 files changed, 41 insertions, 49 deletions
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
index 81e883b..88dc3d0 100644
--- a/reference/csharp/ui/src/ui_container.cs
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -12,23 +12,21 @@ public class Example
12 // Create a box container full of buttons 12 // Create a box container full of buttons
13 static Efl.Ui.Box CreateBox(Efl.Ui.Win win) 13 static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
14 { 14 {
15 Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { 15 Efl.Ui.Box box = new Efl.Ui.Box(win);
16 // Set distance between contained elements 16 // Set distance between contained elements
17 ebox.SetPackPadding(5, 0, true); 17 box.SetPackPadding(5, 0, true);
18 });
19 18
20 for (int i = 1; i <= 4; ++i) 19 for (int i = 1; i <= 4; ++i)
21 { 20 {
22 // Add 4 buttons, one below the other 21 // Add 4 buttons, one below the other
23 new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { 22 var button = new Efl.Ui.Button(win);
24 ebutton.SetText($"Boxed {i}"); 23 button.SetText($"Boxed {i}");
25 if (i == 2) 24 if (i == 2)
26 { 25 {
27 // Button 2 has its maximum size limited, so it will be smaller 26 // Button 2 has its maximum size limited, so it will be smaller
28 ebutton.SetHintMax(new Eina.Size2D(100,50)); 27 button.SetHintMax(new Eina.Size2D(100,50));
29 } 28 }
30 box.DoPack(ebutton); 29 box.DoPack(button);
31 });
32 } 30 }
33 31
34 return box; 32 return box;
@@ -37,26 +35,24 @@ public class Example
37 // Create a simple table layout 35 // Create a simple table layout
38 static Efl.Ui.Table CreateTable(Efl.Ui.Win win) 36 static Efl.Ui.Table CreateTable(Efl.Ui.Win win)
39 { 37 {
40 Efl.Ui.Table table = new Efl.Ui.Table(win, (Efl.Ui.Table etable) => { 38 Efl.Ui.Table table = new Efl.Ui.Table(win);
41 // Table with two columns, that get filled left to right, and then top to bottom 39 // Table with two columns, that get filled left to right, and then top to bottom
42 etable.SetTableColumns(2); 40 table.SetTableColumns(2);
43 etable.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down); 41 table.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down);
44 }); 42 Efl.Ui.Button button;
45 43
46 for (int i = 1; i <= 4; ++i) 44 for (int i = 1; i <= 4; ++i)
47 { 45 {
48 // Add 4 buttons, following the defined table flow 46 // Add 4 buttons, following the defined table flow
49 new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { 47 button = new Efl.Ui.Button(win);
50 ebutton.SetText($"Table {i}"); 48 button.SetText($"Table {i}");
51 table.DoPack(ebutton); 49 table.DoPack(button);
52 });
53 } 50 }
54 51
55 // Last button spans two table cells 52 // Last button spans two table cells
56 new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { 53 button = new Efl.Ui.Button(win);
57 ebutton.SetText("Long Button"); 54 button.SetText("Long Button");
58 table.PackTable(ebutton, 0, 2, 2, 1); 55 table.PackTable(button, 0, 2, 2, 1);
59 });
60 56
61 return table; 57 return table;
62 } 58 }
@@ -70,24 +66,22 @@ public class Example
70 Efl.All.Init(Efl.Components.Ui); 66 Efl.All.Init(Efl.Components.Ui);
71 67
72 // Create a window and initialize it 68 // Create a window and initialize it
73 Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { 69 Efl.Ui.Win win = new Efl.Ui.Win(null);
74 ewin.SetWinType(Efl.Ui.WinType.Basic); 70 win.SetWinType(Efl.Ui.WinType.Basic);
75 ewin.SetText("Container demo"); 71 win.SetText("Container demo");
76 ewin.SetAutohide(true); 72 win.SetAutohide(true);
77 ewin.HideEvt += (object sender, EventArgs e) => { 73 win.HideEvt += (object sender, EventArgs e) => {
78 // Exit the EFL main loop 74 // Exit the EFL main loop
79 Efl.Ui.Config.Exit(); 75 Efl.Ui.Config.Exit();
80 }; 76 };
81 });
82 // Give the window an initial size so there is room to resize the panes. 77 // Give the window an initial size so there is room to resize the panes.
83 // Otherwise, all widgets are tightly packed 78 // Otherwise, all widgets are tightly packed
84 win.SetSize(new Eina.Size2D(350,250)); 79 win.SetSize(new Eina.Size2D(350,250));
85 80
86 // Create a vertically-split panes container 81 // Create a vertically-split panes container
87 Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => { 82 Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win);
88 epanes.SetSplitRatio(0.75); 83 vsplit.SetSplitRatio(0.75);
89 win.SetContent(epanes); 84 win.SetContent(vsplit);
90 });
91 85
92 // Create some boxes and set them as the content of the first pane of the container 86 // Create some boxes and set them as the content of the first pane of the container
93 var box = CreateBox(win); 87 var box = CreateBox(win);
@@ -95,10 +89,9 @@ public class Example
95 89
96 // Create a second, horizontally-split panes container and set it as the content of 90 // Create a second, horizontally-split panes container and set it as the content of
97 // the second pane of the first container 91 // the second pane of the first container
98 Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => { 92 Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win);
99 epanes.SetDirection(Efl.Ui.Dir.Horizontal); 93 hsplit.SetDirection(Efl.Ui.Dir.Horizontal);
100 epanes.SetSplitRatio(0.85); 94 hsplit.SetSplitRatio(0.85);
101 });
102 Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit); 95 Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
103 96
104 // Create a table and set it as the content of the first pane of the horizontal 97 // Create a table and set it as the content of the first pane of the horizontal
@@ -108,14 +101,13 @@ public class Example
108 101
109 // Create a button and set it as the content of the second pane of the horizontal 102 // Create a button and set it as the content of the second pane of the horizontal
110 // container 103 // container
111 Efl.Ui.Button quit_btn = new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { 104 Efl.Ui.Button quit_btn = new Efl.Ui.Button(win);
112 ebutton.SetText("Quit"); 105 quit_btn.SetText("Quit");
113 ebutton.SetHintMax(new Eina.Size2D(150, 30)); 106 quit_btn.SetHintMax(new Eina.Size2D(150, 30));
114 ebutton.ClickedEvt += (object sender, EventArgs e) => { 107 quit_btn.ClickedEvt += (object sender, EventArgs e) => {
115 // Exit the EFL main loop 108 // Exit the EFL main loop
116 Efl.Ui.Config.Exit(); 109 Efl.Ui.Config.Exit();
117 }; 110 };
118 });
119 Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn); 111 Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
120 112
121 // Start the EFL main loop 113 // Start the EFL main loop