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();
|
||||
}
|
||||
|
||||
#if WIN32
|
||||
[STAThreadAttribute()]
|
||||
#endif
|
||||
public static void Main()
|
||||
{
|
||||
// Initialize EFL and all UI components
|
||||
efl.All.Init(efl.Components.Ui);
|
||||
|
||||
// Create a window and initialize it
|
||||
efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
|
||||
// Request a simple window
|
||||
ewin.SetWinType(efl.ui.Win_Type.Basic);
|
||||
efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => {
|
||||
// Set the window's title
|
||||
ewin.SetText("Hello World");
|
||||
// Request that the window is automatically hidden when the "close"
|
||||
// button is pressed
|
||||
ewin.SetAutohide(true);
|
||||
// Hook to the Hide event
|
||||
ewin.HideEvt += QuitCb;
|
||||
});
|
||||
|
||||
// Hook to the Hide event
|
||||
win.HideEvt += QuitCb;
|
||||
|
||||
// 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
|
||||
eina.Size2D sz;
|
||||
sz.W = 360;
|
||||
sz.H = 240;
|
||||
box.SetHintMin(sz);
|
||||
|
||||
ebox.SetHintMin(new eina.Size2D(360, 240));
|
||||
// Set the box as the content for the window
|
||||
// The window size will adapt to the box size
|
||||
win.SetContent(box);
|
||||
win.SetContent(ebox);
|
||||
});
|
||||
|
||||
// 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
|
||||
text.SetText("Hello World. This is an Efl.Ui application!");
|
||||
text.SetSelectionAllowed(false);
|
||||
text.SetHintWeight(1.0, 0.9);
|
||||
text.SetHintAlign(0.5, 0.5);
|
||||
|
||||
etext.SetText("Hello World. This is an Efl.Ui application!");
|
||||
etext.SetSelectionAllowed(false);
|
||||
etext.SetHintWeight(1.0, 0.9);
|
||||
etext.SetHintAlign(0.5, 0.5);
|
||||
// Add the text to the box container
|
||||
box.DoPack(text);
|
||||
box.DoPack(etext);
|
||||
});
|
||||
|
||||
// Create a button widget
|
||||
efl.ui.IButton button = new efl.ui.Button(box);
|
||||
new efl.ui.Button(box, (efl.ui.IButton ebutton) => {
|
||||
// Customize it
|
||||
button.SetText("Quit");
|
||||
button.SetHintWeight(1.0, 0.1);
|
||||
|
||||
ebutton.SetText("Quit");
|
||||
ebutton.SetHintWeight(1.0, 0.1);
|
||||
// Set the method to be called when the button is pressed
|
||||
button.ClickedEvt += QuitCb;
|
||||
|
||||
ebutton.ClickedEvt += QuitCb;
|
||||
// Add the button to the box container
|
||||
box.DoPack(button);
|
||||
box.DoPack(ebutton);
|
||||
});
|
||||
|
||||
// Start the EFL main loop
|
||||
efl.ui.Config.Run();
|
||||
|
|
Loading…
Reference in New Issue