summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_sizing.cs
diff options
context:
space:
mode:
Diffstat (limited to 'reference/csharp/ui/src/ui_sizing.cs')
-rw-r--r--reference/csharp/ui/src/ui_sizing.cs71
1 files changed, 38 insertions, 33 deletions
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}