2018-02-19 11:19:01 -08:00
|
|
|
/*
|
2018-09-17 10:18:06 -07:00
|
|
|
* Efl.UI container examples.
|
2018-02-19 11:19:01 -08:00
|
|
|
*
|
|
|
|
* Load and pack a selection of containers.
|
2018-09-17 10:18:06 -07:00
|
|
|
* Each has its own unique layout and methods which are demonstrated below.
|
2018-02-19 11:19:01 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public class Example
|
|
|
|
{
|
2018-09-17 10:18:06 -07:00
|
|
|
// Create a box container full of buttons
|
2018-11-06 01:39:14 -08:00
|
|
|
static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
|
2018-02-19 11:19:01 -08:00
|
|
|
{
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Box box = new Efl.Ui.Box(win);
|
|
|
|
// Set distance between contained elements
|
|
|
|
box.SetPackPadding(5, 0, true);
|
2018-02-19 11:19:01 -08:00
|
|
|
|
|
|
|
for (int i = 1; i <= 4; ++i)
|
|
|
|
{
|
2018-09-17 10:18:06 -07:00
|
|
|
// Add 4 buttons, one below the other
|
2019-01-18 07:53:55 -08:00
|
|
|
var button = new Efl.Ui.Button(win);
|
|
|
|
button.SetText($"Boxed {i}");
|
|
|
|
if (i == 2)
|
|
|
|
{
|
|
|
|
// Button 2 has its maximum size limited, so it will be smaller
|
|
|
|
button.SetHintMax(new Eina.Size2D(100,50));
|
|
|
|
}
|
|
|
|
box.DoPack(button);
|
2018-02-19 11:19:01 -08:00
|
|
|
}
|
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
return box;
|
2018-02-19 11:19:01 -08:00
|
|
|
}
|
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Create a simple table layout
|
2018-11-06 01:39:14 -08:00
|
|
|
static Efl.Ui.Table CreateTable(Efl.Ui.Win win)
|
2018-02-19 11:19:01 -08:00
|
|
|
{
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Table table = new Efl.Ui.Table(win);
|
|
|
|
// Table with two columns, that get filled left to right, and then top to bottom
|
|
|
|
table.SetTableColumns(2);
|
|
|
|
table.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down);
|
|
|
|
Efl.Ui.Button button;
|
2018-02-19 11:19:01 -08:00
|
|
|
|
|
|
|
for (int i = 1; i <= 4; ++i)
|
|
|
|
{
|
2018-09-17 10:18:06 -07:00
|
|
|
// Add 4 buttons, following the defined table flow
|
2019-01-18 07:53:55 -08:00
|
|
|
button = new Efl.Ui.Button(win);
|
|
|
|
button.SetText($"Table {i}");
|
|
|
|
table.DoPack(button);
|
2018-02-19 11:19:01 -08:00
|
|
|
}
|
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Last button spans two table cells
|
2019-01-18 07:53:55 -08:00
|
|
|
button = new Efl.Ui.Button(win);
|
|
|
|
button.SetText("Long Button");
|
|
|
|
table.PackTable(button, 0, 2, 2, 1);
|
2018-09-17 10:18:06 -07:00
|
|
|
|
|
|
|
return table;
|
2018-02-19 11:19:01 -08:00
|
|
|
}
|
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
#if WIN32
|
|
|
|
[STAThreadAttribute()]
|
|
|
|
#endif
|
2018-02-19 11:19:01 -08:00
|
|
|
public static void Main()
|
|
|
|
{
|
2018-09-17 10:18:06 -07:00
|
|
|
// Initialize EFL and all UI components
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.All.Init(Efl.Components.Ui);
|
2018-02-19 11:19:01 -08:00
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Create a window and initialize it
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Win win = new Efl.Ui.Win(null);
|
|
|
|
win.SetWinType(Efl.Ui.WinType.Basic);
|
|
|
|
win.SetText("Container demo");
|
|
|
|
win.SetAutohide(true);
|
|
|
|
win.HideEvt += (object sender, EventArgs e) => {
|
|
|
|
// Exit the EFL main loop
|
|
|
|
Efl.Ui.Config.Exit();
|
|
|
|
};
|
2018-09-17 10:18:06 -07:00
|
|
|
// Give the window an initial size so there is room to resize the panes.
|
|
|
|
// Otherwise, all widgets are tightly packed
|
2018-11-06 01:39:14 -08:00
|
|
|
win.SetSize(new Eina.Size2D(350,250));
|
2018-09-17 10:18:06 -07:00
|
|
|
|
|
|
|
// Create a vertically-split panes container
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win);
|
|
|
|
vsplit.SetSplitRatio(0.75);
|
|
|
|
win.SetContent(vsplit);
|
2018-02-19 11:19:01 -08:00
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Create some boxes and set them as the content of the first pane of the container
|
|
|
|
var box = CreateBox(win);
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.ContentConcrete.static_cast(vsplit.GetPart("first")).SetContent(box);
|
2018-02-19 11:19:01 -08:00
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Create a second, horizontally-split panes container and set it as the content of
|
|
|
|
// the second pane of the first container
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win);
|
|
|
|
hsplit.SetDirection(Efl.Ui.Dir.Horizontal);
|
|
|
|
hsplit.SetSplitRatio(0.85);
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
|
2018-09-17 10:18:06 -07:00
|
|
|
|
|
|
|
// Create a table and set it as the content of the first pane of the horizontal
|
|
|
|
// container
|
|
|
|
var table = CreateTable(win);
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.ContentConcrete.static_cast(hsplit.GetPart("first")).SetContent(table);
|
2018-09-17 10:18:06 -07:00
|
|
|
|
|
|
|
// Create a button and set it as the content of the second pane of the horizontal
|
|
|
|
// container
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Button quit_btn = new Efl.Ui.Button(win);
|
|
|
|
quit_btn.SetText("Quit");
|
|
|
|
quit_btn.SetHintMax(new Eina.Size2D(150, 30));
|
|
|
|
quit_btn.ClickedEvt += (object sender, EventArgs e) => {
|
2018-09-17 10:18:06 -07:00
|
|
|
// Exit the EFL main loop
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.Ui.Config.Exit();
|
2019-01-18 07:53:55 -08:00
|
|
|
};
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
|
2018-02-19 11:19:01 -08:00
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Start the EFL main loop
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.Ui.Config.Run();
|
2018-02-19 11:19:01 -08:00
|
|
|
|
2018-09-17 10:18:06 -07:00
|
|
|
// Shutdown EFL
|
2018-11-06 01:39:14 -08:00
|
|
|
Efl.All.Shutdown();
|
2018-02-19 11:19:01 -08:00
|
|
|
}
|
|
|
|
}
|
2018-09-17 10:18:06 -07:00
|
|
|
|