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

58 lines
1.7 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 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);
win.SetWinType(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();
}
}