summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_sizing.cs
blob: dd6e5ffb1d1f75224ebeac734593899d8c2e4126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Efl.UI sizing examples.
 *
 * Demonstrate how to use the sizing api from Efl.Gfx.
 * We load a box with 3 buttons, one with default sizing, one that has a max size
 * and the last one has a min size. Try resizing the window to see how this changes.
 */

using System;

public class Example
{
#if WIN32
    [STAThreadAttribute()]
#endif
    public static void Main()
    {
        // Initialize EFL and all UI components
        Efl.All.Init(Efl.Components.Ui);

        // Create a window and initialize it
        Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
            ewin.SetWinType(Efl.Ui.WinType.Basic);
            ewin.SetText("Size Control");
            ewin.SetAutohide(true);
            ewin.HideEvt += (object sender, EventArgs e) => {
                // Exit the EFL main loop
                Efl.Ui.Config.Exit();
            };
        });

        // Create a box container
        Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
          win.SetContent(ebox);
        });

        // Create a regular button (without size hints)
        new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
          ebutton.SetText("Button");
          box.DoPack(ebutton);
        });

        // Create a small button (max size is limited)
        new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
          ebutton.SetText("Small");
          ebutton.SetHintMax(new Eina.Size2D(50,50));
          box.DoPack(ebutton);
        });

        // Create a big button (min size is limited)
        new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
          ebutton.SetText("Big button");
          ebutton.SetHintMin(new Eina.Size2D(100,100));
          box.DoPack(ebutton);
        });

        // Start the EFL main loop
        Efl.Ui.Config.Run();

        // Shutdown EFL
        Efl.All.Shutdown();
    }
}