csharp ui container guide: Add a stacking box (WIP)
Also add a bit more comments.
This commit is contained in:
parent
a040529352
commit
82168cacbc
|
@ -1,16 +1,32 @@
|
||||||
/*
|
/*
|
||||||
* Efl.UI container examples.
|
* Efl.Ui container examples.
|
||||||
*
|
* Showcase a selection of containers.
|
||||||
* Load and pack a selection of containers.
|
|
||||||
* Each has its own unique layout and methods which are demonstrated below.
|
* Each has its own unique layout and methods which are demonstrated below.
|
||||||
|
*
|
||||||
|
* +vpanes---------------------+
|
||||||
|
* | +vbox---+ # +hpanes-----+ |
|
||||||
|
* | | | # | +table--+ | |
|
||||||
|
* | | | # | | | | |
|
||||||
|
* | | | # | | | | |
|
||||||
|
* | | | # | +-------+ | |
|
||||||
|
* | | | # | ######### | |
|
||||||
|
* | | | # | +stack--+ | |
|
||||||
|
* | | | # | | | | |
|
||||||
|
* | | | # | | | | |
|
||||||
|
* | | | # | +-------+ | |
|
||||||
|
* | +-------+ # +-----------+ |
|
||||||
|
* +---------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class Example
|
public class Example
|
||||||
{
|
{
|
||||||
|
efl.ui.IButton quit_btn;
|
||||||
|
efl.ui.IButton about_btn;
|
||||||
|
|
||||||
// Create a box container full of buttons
|
// Create a box container full of buttons
|
||||||
static efl.ui.IBox CreateBox(efl.ui.IWin win)
|
efl.ui.IBox CreateBox(efl.ui.IWin win)
|
||||||
{
|
{
|
||||||
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
|
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
|
||||||
// Set distance between contained elements
|
// Set distance between contained elements
|
||||||
|
@ -21,11 +37,31 @@ public class Example
|
||||||
{
|
{
|
||||||
// Add 4 buttons, one below the other
|
// Add 4 buttons, one below the other
|
||||||
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
||||||
ebutton.SetText($"Boxed {i}");
|
switch (i) {
|
||||||
if (i == 2)
|
case 1:
|
||||||
{
|
ebutton.SetText("Show About button");
|
||||||
// Button 2 has its maximum size limited, so it will be smaller
|
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
||||||
ebutton.SetHintMax(new eina.Size2D(100,50));
|
about_btn.SetVisible(true);
|
||||||
|
quit_btn.SetVisible(false);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ebutton.SetText("Show Quit button");
|
||||||
|
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
||||||
|
about_btn.SetVisible(false);
|
||||||
|
quit_btn.SetVisible(true);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// Button 2 has its maximum size limited, so it will be smaller
|
||||||
|
ebutton.SetText("Smaller button");
|
||||||
|
ebutton.SetHintMax(new eina.Size2D(100,50));
|
||||||
|
ebutton.SetDisabled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ebutton.SetText($"Boxed {i}");
|
||||||
|
ebutton.SetDisabled(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
box.DoPack(ebutton);
|
box.DoPack(ebutton);
|
||||||
});
|
});
|
||||||
|
@ -35,7 +71,7 @@ public class Example
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a simple table layout
|
// Create a simple table layout
|
||||||
static efl.ui.ITable CreateTable(efl.ui.IWin win)
|
efl.ui.ITable CreateTable(efl.ui.IWin win)
|
||||||
{
|
{
|
||||||
efl.ui.ITable table = new efl.ui.Table(win, (efl.ui.ITable etable) => {
|
efl.ui.ITable table = new efl.ui.Table(win, (efl.ui.ITable etable) => {
|
||||||
// Table with two columns, that get filled left to right, and then top to bottom
|
// Table with two columns, that get filled left to right, and then top to bottom
|
||||||
|
@ -48,6 +84,7 @@ public class Example
|
||||||
// Add 4 buttons, following the defined table flow
|
// Add 4 buttons, following the defined table flow
|
||||||
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
||||||
ebutton.SetText($"Table {i}");
|
ebutton.SetText($"Table {i}");
|
||||||
|
ebutton.SetDisabled(true);
|
||||||
table.DoPack(ebutton);
|
table.DoPack(ebutton);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,6 +92,7 @@ public class Example
|
||||||
// Last button spans two table cells
|
// Last button spans two table cells
|
||||||
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
||||||
ebutton.SetText("Long Button");
|
ebutton.SetText("Long Button");
|
||||||
|
ebutton.SetDisabled(true);
|
||||||
table.PackTable(ebutton, 0, 2, 2, 1);
|
table.PackTable(ebutton, 0, 2, 2, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,6 +104,8 @@ public class Example
|
||||||
#endif
|
#endif
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
|
var example = new Example();
|
||||||
|
|
||||||
// Initialize EFL and all UI components
|
// Initialize EFL and all UI components
|
||||||
efl.All.Init(efl.Components.Ui);
|
efl.All.Init(efl.Components.Ui);
|
||||||
|
|
||||||
|
@ -90,7 +130,7 @@ public class Example
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create some boxes and set them as the content of the first pane of the container
|
// Create some boxes and set them as the content of the first pane of the container
|
||||||
var box = CreateBox(win);
|
var box = example.CreateBox(win);
|
||||||
efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box);
|
efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box);
|
||||||
|
|
||||||
// Create a second, horizontally-split panes container and set it as the content of
|
// Create a second, horizontally-split panes container and set it as the content of
|
||||||
|
@ -103,20 +143,32 @@ public class Example
|
||||||
|
|
||||||
// Create a table and set it as the content of the first pane of the horizontal
|
// Create a table and set it as the content of the first pane of the horizontal
|
||||||
// container
|
// container
|
||||||
var table = CreateTable(win);
|
var table = example.CreateTable(win);
|
||||||
efl.Content.static_cast(hsplit.GetPart("first")).SetContent(table);
|
efl.Content.static_cast(hsplit.GetPart("first")).SetContent(table);
|
||||||
|
|
||||||
// Create a button and set it as the content of the second pane of the horizontal
|
// Create a stacked box and set it as the content of the second pane of the horizontal
|
||||||
// container
|
// container
|
||||||
efl.ui.IButton quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
efl.ui.IBox_Stack stack = new efl.ui.Box_Stack(win);
|
||||||
|
efl.Content.static_cast(hsplit.GetPart("second")).SetContent(stack);
|
||||||
|
|
||||||
|
// Add an About button to the stacked box container
|
||||||
|
example.about_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
||||||
|
ebutton.SetText("About");
|
||||||
|
ebutton.SetHintMax(new eina.Size2D(150, 30));
|
||||||
|
ebutton.SetDisabled(true);
|
||||||
|
stack.DoPack(ebutton);
|
||||||
|
});
|
||||||
|
// Add a Quit button to the stacked box container
|
||||||
|
example.quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
|
||||||
ebutton.SetText("Quit");
|
ebutton.SetText("Quit");
|
||||||
ebutton.SetHintMax(new eina.Size2D(150, 30));
|
ebutton.SetHintMax(new eina.Size2D(150, 30));
|
||||||
|
ebutton.SetVisible(false);
|
||||||
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
||||||
// Exit the EFL main loop
|
// Exit the EFL main loop
|
||||||
efl.ui.Config.Exit();
|
efl.ui.Config.Exit();
|
||||||
};
|
};
|
||||||
|
stack.DoPack(ebutton);
|
||||||
});
|
});
|
||||||
efl.Content.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
|
|
||||||
|
|
||||||
// Start the EFL main loop
|
// Start the EFL main loop
|
||||||
efl.ui.Config.Run();
|
efl.ui.Config.Run();
|
||||||
|
|
Loading…
Reference in New Issue