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

61 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
{
#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.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);
// Start the EFL main loop
Efl.Ui.Config.Run();
// Shutdown EFL
Efl.All.Shutdown();
}
}