C# Hello Gui tutorial: bring it closer to the C version
Summary: Configure all widgets inside their constructors and a couple more minor things to make the C# Hello Gui more similar to the C version, which should simplify the tutorial. Reviewers: lauromoura, vitor.sousa Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D6906
This commit is contained in:
parent
006760cdf6
commit
ad93666875
|
@ -9,59 +9,55 @@ public class Example
|
||||||
efl.ui.Config.Exit();
|
efl.ui.Config.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WIN32
|
||||||
|
[STAThreadAttribute()]
|
||||||
|
#endif
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
// Initialize EFL and all UI components
|
// Initialize EFL and all UI components
|
||||||
efl.All.Init(efl.Components.Ui);
|
efl.All.Init(efl.Components.Ui);
|
||||||
|
|
||||||
// Create a window and initialize it
|
// Create a window and initialize it
|
||||||
efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
|
efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => {
|
||||||
// Request a simple window
|
|
||||||
ewin.SetWinType(efl.ui.Win_Type.Basic);
|
|
||||||
// Set the window's title
|
// Set the window's title
|
||||||
ewin.SetText("Hello World");
|
ewin.SetText("Hello World");
|
||||||
// Request that the window is automatically hidden when the "close"
|
// Request that the window is automatically hidden when the "close"
|
||||||
// button is pressed
|
// button is pressed
|
||||||
ewin.SetAutohide(true);
|
ewin.SetAutohide(true);
|
||||||
|
// Hook to the Hide event
|
||||||
|
ewin.HideEvt += QuitCb;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hook to the Hide event
|
|
||||||
win.HideEvt += QuitCb;
|
|
||||||
|
|
||||||
// Create a box container
|
// Create a box container
|
||||||
efl.ui.IBox box = new efl.ui.Box(win);
|
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
|
||||||
// Set its minimum size
|
// Set its minimum size
|
||||||
eina.Size2D sz;
|
ebox.SetHintMin(new eina.Size2D(360, 240));
|
||||||
sz.W = 360;
|
// Set the box as the content for the window
|
||||||
sz.H = 240;
|
// The window size will adapt to the box size
|
||||||
box.SetHintMin(sz);
|
win.SetContent(ebox);
|
||||||
|
});
|
||||||
// Set the box as the content for the window
|
|
||||||
// The window size will adapt to the box size
|
|
||||||
win.SetContent(box);
|
|
||||||
|
|
||||||
// Create a text label widget
|
// Create a text label widget
|
||||||
efl.ui.IText text = new efl.ui.Text(box);
|
new efl.ui.Text(box, (efl.ui.IText etext) => {
|
||||||
// Set its content and customize it
|
// Set its content and customize it
|
||||||
text.SetText("Hello World. This is an Efl.Ui application!");
|
etext.SetText("Hello World. This is an Efl.Ui application!");
|
||||||
text.SetSelectionAllowed(false);
|
etext.SetSelectionAllowed(false);
|
||||||
text.SetHintWeight(1.0, 0.9);
|
etext.SetHintWeight(1.0, 0.9);
|
||||||
text.SetHintAlign(0.5, 0.5);
|
etext.SetHintAlign(0.5, 0.5);
|
||||||
|
// Add the text to the box container
|
||||||
// Add the text to the box container
|
box.DoPack(etext);
|
||||||
box.DoPack(text);
|
});
|
||||||
|
|
||||||
// Create a button widget
|
// Create a button widget
|
||||||
efl.ui.IButton button = new efl.ui.Button(box);
|
new efl.ui.Button(box, (efl.ui.IButton ebutton) => {
|
||||||
// Customize it
|
// Customize it
|
||||||
button.SetText("Quit");
|
ebutton.SetText("Quit");
|
||||||
button.SetHintWeight(1.0, 0.1);
|
ebutton.SetHintWeight(1.0, 0.1);
|
||||||
|
// Set the method to be called when the button is pressed
|
||||||
// Set the method to be called when the button is pressed
|
ebutton.ClickedEvt += QuitCb;
|
||||||
button.ClickedEvt += QuitCb;
|
// Add the button to the box container
|
||||||
|
box.DoPack(ebutton);
|
||||||
// Add the button to the box container
|
});
|
||||||
box.DoPack(button);
|
|
||||||
|
|
||||||
// Start the EFL main loop
|
// Start the EFL main loop
|
||||||
efl.ui.Config.Run();
|
efl.ui.Config.Run();
|
||||||
|
|
Loading…
Reference in New Issue