examples/reference/csharp/ui/src/ui_sizing.cs

60 lines
1.5 KiB
C#

/*
* 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();
}
}