summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_sizing.cs
blob: 7ccfa109449b50e61371eff080e3c3abd9a72daf (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
/*
 * 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 : Efl.Csharp.Application
{
    protected override void OnInitialize(Eina.Array<System.String> args)
    {
        // Create a window and initialize it
        Efl.Ui.Win win = new Efl.Ui.Win(null, winType: Efl.Ui.WinType.Basic);
        win.SetText("Size Control");
        win.SetAutohide(true);
        win.VisibilityChangedEvt += (object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args e) => {
            // Exit the EFL main loop
            if (e.arg == false)
                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.SetHintSizeMax(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.SetHintSizeMin(new Eina.Size2D(100,100));
        box.DoPack(button);
    }

#if WIN32
    [STAThreadAttribute()]
#endif
    public static void Main()
    {
        var example = new Example();
        example.Launch();
    }
}