113 lines
3.2 KiB
C#
113 lines
3.2 KiB
C#
/*
|
|
* Efl.UI container exmaples.
|
|
*
|
|
* Load and pack a selection of containers.
|
|
* Each has it's own unique layout and methods which are demonstrated below.
|
|
*/
|
|
|
|
using System;
|
|
|
|
public class Example
|
|
{
|
|
// quit the app, called if the user clicks the Quit button or the window is hidden
|
|
static void GuiQuitCb(object sender, EventArgs e)
|
|
{
|
|
efl.ui.Config.Exit();
|
|
}
|
|
|
|
// Load a simple table layout into the window
|
|
static efl.ui.Table SetupUiTable(efl.ui.Win win)
|
|
{
|
|
efl.ui.Table table = new efl.ui.TableConcrete(win);
|
|
|
|
table.SetTableColumns(2);
|
|
table.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
|
|
|
|
efl.ui.Button button = new efl.ui.ButtonConcrete(win);
|
|
button.SetText("Long Button");
|
|
|
|
table.PackTable(button, 0, 2, 2, 1);
|
|
|
|
for (int i = 1; i <= 4; ++i)
|
|
{
|
|
efl.ui.Button btn = new efl.ui.ButtonConcrete(win);
|
|
btn.SetText($"Table {i}");
|
|
table.Pack(btn);
|
|
}
|
|
|
|
return table;
|
|
}
|
|
|
|
// Load some boxes - a horizontal one for the window layout and a vertical
|
|
// one to contain a flow
|
|
static efl.ui.Box SetupUiBoxes(efl.ui.Win win)
|
|
{
|
|
efl.ui.Box box = new efl.ui.BoxConcrete(win);
|
|
box.SetPackPadding(5, 0, true);
|
|
|
|
for (int i = 1; i <= 4; ++i)
|
|
{
|
|
efl.ui.Button button = new efl.ui.ButtonConcrete(win);
|
|
button.SetText($"Boxed {i}");
|
|
if (i == 2)
|
|
{
|
|
eina.Size2D sz;
|
|
sz.W = 100;
|
|
sz.H = 50;
|
|
button.SetHintMax(sz);
|
|
}
|
|
box.Pack(button);
|
|
}
|
|
|
|
return box;
|
|
}
|
|
|
|
public static void Main()
|
|
{
|
|
efl.All.Init(efl.Components.Ui);
|
|
|
|
efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => {
|
|
ewin.SetWinType(efl.ui.win.Type.Basic);
|
|
ewin.SetText("Hello World");
|
|
ewin.SetAutohide(true);
|
|
});
|
|
eina.Size2D sz;
|
|
sz.W = 350;
|
|
sz.H = 250;
|
|
win.SetSize(sz);
|
|
|
|
// when the user clicks "close" on a window there is a request to hide
|
|
win.HIDE += GuiQuitCb;
|
|
|
|
// Load a vertical and horizontal split into the window
|
|
|
|
efl.ui.Panes split = new efl.ui.PanesConcrete(win);
|
|
split.SetSplitRatio(0.75);
|
|
win.SetContent(split);
|
|
|
|
var boxes = SetupUiBoxes(win);
|
|
efl.ContentConcrete.static_cast(split.Part("first")).SetContent(boxes);
|
|
|
|
efl.ui.Panes horiz_split = new efl.ui.PanesConcrete(win);
|
|
horiz_split.SetDirection(efl.ui.Dir.Horizontal);
|
|
horiz_split.SetSplitRatio(0.85);
|
|
efl.ContentConcrete.static_cast(split.Part("second")).SetContent(horiz_split);
|
|
|
|
var table = SetupUiTable(win);
|
|
efl.ContentConcrete.static_cast(horiz_split.Part("first")).SetContent(table);
|
|
|
|
efl.ui.Button quit_btn = new efl.ui.ButtonConcrete(win);
|
|
quit_btn.SetText("Quit");
|
|
sz.W = 150;
|
|
sz.H = 30;
|
|
quit_btn.SetHintMax(sz);
|
|
quit_btn.CLICKED += GuiQuitCb;
|
|
efl.ContentConcrete.static_cast(horiz_split.Part("second")).SetContent(quit_btn);
|
|
|
|
// Start event loop
|
|
efl.ui.Config.Run();
|
|
|
|
efl.All.Shutdown();
|
|
}
|
|
}
|