summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/ui_sizing.cs
blob: 2f74b60efd3011b246f0a76658f35e0603692297 (plain) (blame)
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
 * and the last has a min size. Try resizing the window to see how this changes.
 */

using System;

public class Example
{
    public static void Main()
    {
        efl.All.Init(efl.Components.Ui);

        efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
            ewin.SetWinType(efl.ui.Win_Type.Basic);
            ewin.SetText("Size Control");
            ewin.SetAutohide(true);
        });
        eina.Size2D sz;
        sz.W = 320;
        sz.H = 320;
        win.SetSize(sz);

        // when the user clicks "close" on a window there is a request to hide
        win.HideEvt += (object sender, EventArgs e) => {
            // quit the app, called if the window is hidden
            efl.ui.Config.Exit();
        };

        efl.ui.IBox box = new efl.ui.Box(win);
        win.SetContent(box);

        efl.ui.IButton button = new efl.ui.Button(win);
        button.SetText("Button");
        box.DoPack(button);

        efl.ui.IButton small_btn = new efl.ui.Button(win);
        small_btn.SetText("Small");
        sz.W = 50;
        sz.H = 50;
        small_btn.SetHintMax(sz);
        box.DoPack(small_btn);

        efl.ui.IButton big_btn = new efl.ui.Button(win);
        big_btn.SetText("Big Button");
        sz.W = 100;
        sz.H = 100;
        big_btn.SetHintMin(sz);
        box.DoPack(big_btn);

        efl.ui.Config.Run();

        efl.All.Shutdown();
    }
}