diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs index fe5cc976..0cd9a9f7 100644 --- a/reference/csharp/ui/src/ui_container.cs +++ b/reference/csharp/ui/src/ui_container.cs @@ -1,16 +1,32 @@ /* - * Efl.UI container examples. - * - * Load and pack a selection of containers. + * Efl.Ui container examples. + * Showcase a selection of containers. * Each has its own unique layout and methods which are demonstrated below. + * + * +vpanes---------------------+ + * | +vbox---+ # +hpanes-----+ | + * | | | # | +table--+ | | + * | | | # | | | | | + * | | | # | | | | | + * | | | # | +-------+ | | + * | | | # | ######### | | + * | | | # | +stack--+ | | + * | | | # | | | | | + * | | | # | | | | | + * | | | # | +-------+ | | + * | +-------+ # +-----------+ | + * +---------------------------+ */ using System; public class Example { + efl.ui.IButton quit_btn; + efl.ui.IButton about_btn; + // 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) => { // Set distance between contained elements @@ -21,11 +37,31 @@ public class Example { // Add 4 buttons, one below the other new efl.ui.Button(win, (efl.ui.IButton ebutton) => { - ebutton.SetText($"Boxed {i}"); - if (i == 2) - { - // Button 2 has its maximum size limited, so it will be smaller - ebutton.SetHintMax(new eina.Size2D(100,50)); + switch (i) { + case 1: + ebutton.SetText("Show About button"); + ebutton.ClickedEvt += (object sender, EventArgs e) => { + 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); }); @@ -35,7 +71,7 @@ public class Example } // 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) => { // 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 new efl.ui.Button(win, (efl.ui.IButton ebutton) => { ebutton.SetText($"Table {i}"); + ebutton.SetDisabled(true); table.DoPack(ebutton); }); } @@ -55,6 +92,7 @@ public class Example // Last button spans two table cells new efl.ui.Button(win, (efl.ui.IButton ebutton) => { ebutton.SetText("Long Button"); + ebutton.SetDisabled(true); table.PackTable(ebutton, 0, 2, 2, 1); }); @@ -66,6 +104,8 @@ public class Example #endif public static void Main() { + var example = new Example(); + // Initialize EFL and all UI components 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 - var box = CreateBox(win); + var box = example.CreateBox(win); efl.Content.static_cast(vsplit.GetPart("first")).SetContent(box); // 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 // container - var table = CreateTable(win); + var table = example.CreateTable(win); 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 - 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.SetHintMax(new eina.Size2D(150, 30)); + ebutton.SetVisible(false); ebutton.ClickedEvt += (object sender, EventArgs e) => { // Exit the EFL main loop efl.ui.Config.Exit(); }; + stack.DoPack(ebutton); }); - efl.Content.static_cast(hsplit.GetPart("second")).SetContent(quit_btn); // Start the EFL main loop efl.ui.Config.Run();