summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_sizing.cs
blob: ac25283e2bada40199087d30e8f3087e1da3b249 (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
/*
 * 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);
        win.SetWinType(Efl.Ui.WinType.Basic);
        win.SetText("Size Control");
        win.SetAutohide(true);
        win.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);
        win.SetContent(box);

        // Create a regular button (without size hints)
        var button = new Efl.Ui.Button(win);
        button.SetText("Button");
        box.DoPack(button);

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

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

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

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