summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-10-25 12:45:49 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2018-10-25 13:15:12 +0200
commit82168cacbc39b8ae0e8ae86e241db19a7baf079b (patch)
tree9c91e460ce4011bc2bb750bd1d561c7fb0628fb4
parenta040529352ca927329c557f9c1400c451752a87b (diff)
csharp ui container guide: Add a stacking box (WIP)devs/xartigas/csharp-tutorials
Also add a bit more comments.
-rw-r--r--reference/csharp/ui/src/ui_container.cs82
1 files changed, 67 insertions, 15 deletions
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
index fe5cc976..0cd9a9f7 100644
--- a/reference/csharp/ui/src/ui_container.cs
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -1,16 +1,32 @@
1/* 1/*
2 * Efl.UI container examples. 2 * Efl.Ui container examples.
3 * 3 * Showcase a selection of containers.
4 * Load and pack a selection of containers.
5 * Each has its own unique layout and methods which are demonstrated below. 4 * Each has its own unique layout and methods which are demonstrated below.
5 *
6 * +vpanes---------------------+
7 * | +vbox---+ # +hpanes-----+ |
8 * | | | # | +table--+ | |
9 * | | | # | | | | |
10 * | | | # | | | | |
11 * | | | # | +-------+ | |
12 * | | | # | ######### | |
13 * | | | # | +stack--+ | |
14 * | | | # | | | | |
15 * | | | # | | | | |
16 * | | | # | +-------+ | |
17 * | +-------+ # +-----------+ |
18 * +---------------------------+
6 */ 19 */
7 20
8using System; 21using System;
9 22
10public class Example 23public class Example
11{ 24{
25 efl.ui.IButton quit_btn;
26 efl.ui.IButton about_btn;
27
12 // Create a box container full of buttons 28 // Create a box container full of buttons
13 static efl.ui.IBox CreateBox(efl.ui.IWin win) 29 efl.ui.IBox CreateBox(efl.ui.IWin win)
14 { 30 {
15 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => { 31 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
16 // Set distance between contained elements 32 // Set distance between contained elements
@@ -21,11 +37,31 @@ public class Example
21 { 37 {
22 // Add 4 buttons, one below the other 38 // Add 4 buttons, one below the other
23 new efl.ui.Button(win, (efl.ui.IButton ebutton) => { 39 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
24 ebutton.SetText($"Boxed {i}"); 40 switch (i) {
25 if (i == 2) 41 case 1:
26 { 42 ebutton.SetText("Show About button");
27 // Button 2 has its maximum size limited, so it will be smaller 43 ebutton.ClickedEvt += (object sender, EventArgs e) => {
28 ebutton.SetHintMax(new eina.Size2D(100,50)); 44 about_btn.SetVisible(true);
45 quit_btn.SetVisible(false);
46 };
47 break;
48 case 2:
49 ebutton.SetText("Show Quit button");
50 ebutton.ClickedEvt += (object sender, EventArgs e) => {
51 about_btn.SetVisible(false);
52 quit_btn.SetVisible(true);
53 };
54 break;
55 case 3:
56 // Button 2 has its maximum size limited, so it will be smaller
57 ebutton.SetText("Smaller button");
58 ebutton.SetHintMax(new eina.Size2D(100,50));
59 ebutton.SetDisabled(true);
60 break;
61 default:
62 ebutton.SetText($"Boxed {i}");
63 ebutton.SetDisabled(true);
64 break;
29 } 65 }
30 box.DoPack(ebutton); 66 box.DoPack(ebutton);
31 }); 67 });
@@ -35,7 +71,7 @@ public class Example
35 } 71 }
36 72
37 // Create a simple table layout 73 // Create a simple table layout
38 static efl.ui.ITable CreateTable(efl.ui.IWin win) 74 efl.ui.ITable CreateTable(efl.ui.IWin win)
39 { 75 {
40 efl.ui.ITable table = new efl.ui.Table(win, (efl.ui.ITable etable) => { 76 efl.ui.ITable table = new efl.ui.Table(win, (efl.ui.ITable etable) => {
41 // Table with two columns, that get filled left to right, and then top to bottom 77 // Table with two columns, that get filled left to right, and then top to bottom
@@ -48,6 +84,7 @@ public class Example
48 // Add 4 buttons, following the defined table flow 84 // Add 4 buttons, following the defined table flow
49 new efl.ui.Button(win, (efl.ui.IButton ebutton) => { 85 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
50 ebutton.SetText($"Table {i}"); 86 ebutton.SetText($"Table {i}");
87 ebutton.SetDisabled(true);
51 table.DoPack(ebutton); 88 table.DoPack(ebutton);
52 }); 89 });
53 } 90 }
@@ -55,6 +92,7 @@ public class Example
55 // Last button spans two table cells 92 // Last button spans two table cells
56 new efl.ui.Button(win, (efl.ui.IButton ebutton) => { 93 new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
57 ebutton.SetText("Long Button"); 94 ebutton.SetText("Long Button");
95 ebutton.SetDisabled(true);
58 table.PackTable(ebutton, 0, 2, 2, 1); 96 table.PackTable(ebutton, 0, 2, 2, 1);
59 }); 97 });
60 98
@@ -66,6 +104,8 @@ public class Example
66#endif 104#endif
67 public static void Main() 105 public static void Main()
68 { 106 {
107 var example = new Example();
108
69 // Initialize EFL and all UI components 109 // Initialize EFL and all UI components
70 efl.All.Init(efl.Components.Ui); 110 efl.All.Init(efl.Components.Ui);
71 111
@@ -90,7 +130,7 @@ public class Example
90 }); 130 });
91 131
92 // Create some boxes and set them as the content of the first pane of the container 132 // Create some boxes and set them as the content of the first pane of the container
93 var box = CreateBox(win); 133 var box = example.CreateBox(win);
94 efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box); 134 efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box);
95 135
96 // Create a second, horizontally-split panes container and set it as the content of 136 // Create a second, horizontally-split panes container and set it as the content of
@@ -103,20 +143,32 @@ public class Example
103 143
104 // Create a table and set it as the content of the first pane of the horizontal 144 // Create a table and set it as the content of the first pane of the horizontal
105 // container 145 // container
106 var table = CreateTable(win); 146 var table = example.CreateTable(win);
107 efl.Content.static_cast(hsplit.GetPart("first")).SetContent(table); 147 efl.Content.static_cast(hsplit.GetPart("first")).SetContent(table);
108 148
109 // Create a button and set it as the content of the second pane of the horizontal 149 // Create a stacked box and set it as the content of the second pane of the horizontal
110 // container 150 // container
111 efl.ui.IButton quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => { 151 efl.ui.IBox_Stack stack = new efl.ui.Box_Stack(win);
152 efl.Content.static_cast(hsplit.GetPart("second")).SetContent(stack);
153
154 // Add an About button to the stacked box container
155 example.about_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
156 ebutton.SetText("About");
157 ebutton.SetHintMax(new eina.Size2D(150, 30));
158 ebutton.SetDisabled(true);
159 stack.DoPack(ebutton);
160 });
161 // Add a Quit button to the stacked box container
162 example.quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
112 ebutton.SetText("Quit"); 163 ebutton.SetText("Quit");
113 ebutton.SetHintMax(new eina.Size2D(150, 30)); 164 ebutton.SetHintMax(new eina.Size2D(150, 30));
165 ebutton.SetVisible(false);
114 ebutton.ClickedEvt += (object sender, EventArgs e) => { 166 ebutton.ClickedEvt += (object sender, EventArgs e) => {
115 // Exit the EFL main loop 167 // Exit the EFL main loop
116 efl.ui.Config.Exit(); 168 efl.ui.Config.Exit();
117 }; 169 };
170 stack.DoPack(ebutton);
118 }); 171 });
119 efl.Content.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
120 172
121 // Start the EFL main loop 173 // Start the EFL main loop
122 efl.ui.Config.Run(); 174 efl.ui.Config.Run();