mono-examples: Adapt to latest syntax

Summary:
Removed initializer methods as much as possible to prepare
for when they are removed from the C# bindings.
No functional changes in the examples.
Tutorial text needs to be adapted now.

Test Plan: All examples work as before (the containers one is currently broken, FML).

Reviewers: lauromoura, felipealmeida, vitor.sousa

Reviewed By: lauromoura

Maniphest Tasks: T7508

Differential Revision: https://phab.enlightenment.org/D7695
This commit is contained in:
Xavi Artigas 2019-01-18 16:53:55 +01:00
parent e674ff0d97
commit 500049f1eb
11 changed files with 214 additions and 247 deletions

View File

@ -37,11 +37,10 @@ public class LifeWindow
public LifeWindow() public LifeWindow()
{ {
Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { Efl.Ui.Win win = new Efl.Ui.Win(null);
ewin.SetWinType(Efl.Ui.WinType.Basic); win.SetWinType(Efl.Ui.WinType.Basic);
ewin.SetText("EFL Life"); win.SetText("EFL Life");
ewin.SetAutohide(true); win.SetAutohide(true);
});
// when the user clicks "close" on a window there is a request to hide // when the user clicks "close" on a window there is a request to hide
((Efl.Gfx.Entity)win).HideEvt += QuitEvt; ((Efl.Gfx.Entity)win).HideEvt += QuitEvt;

View File

@ -58,50 +58,46 @@ public class TextEditor
// Shows a modal message popup with an "OK" button // Shows a modal message popup with an "OK" button
private void ShowMessage(string message) private void ShowMessage(string message)
{ {
new Efl.Ui.TextAlertPopup (win, (Efl.Ui.TextAlertPopup epopup) => { var popup = new Efl.Ui.TextAlertPopup (win);
epopup.SetText(message); popup.SetText(message);
epopup.SetExpandable(new Eina.Size2D(200,200)); popup.SetExpandable(new Eina.Size2D(200, 200));
epopup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null); popup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null);
epopup.ButtonClickedEvt += popup.ButtonClickedEvt +=
(object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args ea) => { (object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args ea) => {
// Dismiss popup when the button is clicked // Dismiss popup when the button is clicked
((Efl.Ui.TextAlertPopup)sender).SetParent(null); ((Efl.Ui.TextAlertPopup)sender).SetParent(null);
}; };
});
} }
// Adds a button to the toolbar, with the given text, icon and click event handler // Adds a button to the toolbar, with the given text, icon and click event handler
private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name, private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name,
string iconName, EventHandler func) string iconName, EventHandler func)
{ {
return new Efl.Ui.Button(toolbar, (Efl.Ui.Button ebutton) => { var button = new Efl.Ui.Button(toolbar);
ebutton.SetText(name); button.SetText(name);
ebutton.ClickedEvt += func; button.ClickedEvt += func;
ebutton.SetHintWeight(0, 1); button.SetHintWeight(0, 1);
toolbar.DoPack(ebutton);
// Set the content of the button // Set the content of the button, which is an image
ebutton.SetContent( var image = new Efl.Ui.Image(toolbar);
// Which is an image image.SetIcon(iconName);
new Efl.Ui.Image(toolbar, (Efl.Ui.Image eimage) => { button.SetContent(image);
eimage.SetIcon(iconName);
}) toolbar.DoPack(button);
); return button;
});
} }
// Creates a new toolbar, with all its buttons // Creates a new toolbar, with all its buttons
private void GUIToolbarSetup(Efl.Ui.Box parent) private void GUIToolbarSetup(Efl.Ui.Box parent)
{ {
// Create a horizontal box container for the buttons // Create a horizontal box container for the buttons
Efl.Ui.Box bar = new Efl.Ui.Box(parent, (Efl.Ui.Box ebox) => { var bar = new Efl.Ui.Box(parent);
// 0 vertical weight means that the toolbar will have the minimum height // 0 vertical weight means that the toolbar will have the minimum height
// to accommodate all its buttons and not a pixel more. The rest of the // to accommodate all its buttons and not a pixel more. The rest of the
// space will be given to the other object in the parent container. // space will be given to the other object in the parent container.
ebox.SetHintWeight(1, 0); bar.SetHintWeight(1, 0);
ebox.SetDirection(Efl.Ui.Dir.Horizontal); bar.SetDirection(Efl.Ui.Dir.Horizontal);
parent.DoPack(ebox); parent.DoPack(bar);
});
// "New" button // "New" button
toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new", toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new",
@ -157,11 +153,10 @@ public class TextEditor
public TextEditor() public TextEditor()
{ {
// Create a window and initialize it // Create a window and initialize it
win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => { win = new Efl.Ui.Win(Efl.App.AppMain);
ewin.SetText("Text Editor"); win.SetText("Text Editor");
ewin.SetAutohide(true); win.SetAutohide(true);
ewin.HideEvt += GUIQuitCb; win.HideEvt += GUIQuitCb;
});
// Create a vertical box container // Create a vertical box container
Efl.Ui.Box box = new Efl.Ui.Box(win); Efl.Ui.Box box = new Efl.Ui.Box(win);
@ -171,16 +166,15 @@ public class TextEditor
GUIToolbarSetup(box); GUIToolbarSetup(box);
// Create the main text entry // Create the main text entry
editorTextBox = new Efl.Ui.Text(box, (Efl.Ui.Text etext) => { editorTextBox = new Efl.Ui.Text(box);
etext.SetFont("Mono", 14); editorTextBox.SetFont("Mono", 14);
etext.SetMultiline(true); editorTextBox.SetMultiline(true);
etext.SetEditable(true); editorTextBox.SetEditable(true);
etext.SetScrollable(true); editorTextBox.SetScrollable(true);
etext.SetHintMin(new Eina.Size2D(360, 240)); editorTextBox.SetHintMin(new Eina.Size2D(360, 240));
etext.ChangedEvt += EditorChangedCb; editorTextBox.ChangedEvt += EditorChangedCb;
etext.ChangedUserEvt += EditorChangedCb; editorTextBox.ChangedUserEvt += EditorChangedCb;
box.DoPack(etext); box.DoPack(editorTextBox);
});
// Initial refresh of the toolbar buttons // Initial refresh of the toolbar buttons
GUIToolbarRefresh(); GUIToolbarRefresh();

View File

@ -31,33 +31,33 @@ public class Example
mainloop.PollHighEvt += PollCb; mainloop.PollHighEvt += PollCb;
// This timer will control events fired by the main loop // This timer will control events fired by the main loop
new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => { var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
etimer.SetName("Timer");
// Trigger every 100ms // Trigger every 100ms
etimer.SetInterval(0.1); etimer.SetInterval(0.1);
// To count number of timer triggers
int tick_count = 0;
etimer.TickEvt += (object sender, EventArgs e) => {
string message = "Tick {0} from {1}: ";
// Depending on the number of timer ticks, it does a different thing
switch (tick_count) {
case 0:
message += "Freezing Mainloop events";
mainloop.FreezeEvent();
break;
case 1:
message += "Thawing Mainloop events";
mainloop.ThawEvent();
break;
default:
message += "Quitting";
mainloop.Quit(new Eina.Value(0));
break;
}
Console.WriteLine(message, tick_count, ((Efl.Object)sender).GetName());
tick_count++;
};
}); });
timer.SetName("Timer");
// To count number of timer triggers
int tick_count = 0;
timer.TickEvt += (object sender, EventArgs e) => {
string message = "Tick {0} from {1}: ";
// Depending on the number of timer ticks, it does a different thing
switch (tick_count) {
case 0:
message += "Freezing Mainloop events";
mainloop.FreezeEvent();
break;
case 1:
message += "Thawing Mainloop events";
mainloop.ThawEvent();
break;
default:
message += "Quitting";
mainloop.Quit(new Eina.Value(0));
break;
}
Console.WriteLine(message, tick_count, ((Efl.Object)sender).GetName());
tick_count++;
};
Console.WriteLine("Waiting for Timer to call back..."); Console.WriteLine("Waiting for Timer to call back...");

View File

@ -34,14 +34,14 @@ public class Example
}; };
// Use a timer to exit the application // Use a timer to exit the application
new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => { var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger after 10ms // Trigger after 10ms
etimer.SetInterval(0.01); etimer.SetInterval(0.01);
etimer.TickEvt += (object sender, EventArgs e) => {
Console.WriteLine("TIMER: timer callback called, exiting.");
mainloop.Quit(new Eina.Value(0));
};
}); });
timer.TickEvt += (object sender, EventArgs e) => {
Console.WriteLine("TIMER: timer callback called, exiting.");
mainloop.Quit(new Eina.Value(0));
};
// Start the EFL main loop (and the experiment) // Start the EFL main loop (and the experiment)
mainloop.Begin(); mainloop.Begin();

View File

@ -33,14 +33,14 @@ public class Example
}; };
// Use a timer to exit the application // Use a timer to exit the application
new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => { var timer = new Efl.LoopTimer(mainloop, (Efl.LoopTimer etimer) => {
// Trigger after 30s // Trigger after 30s
etimer.SetInterval(30); etimer.SetInterval(30);
etimer.TickEvt += (object sender, EventArgs e) => {
Console.WriteLine("\nTIMER: timer callback called, exiting.");
mainloop.Quit(new Eina.Value(0));
};
}); });
timer.TickEvt += (object sender, EventArgs e) => {
Console.WriteLine("\nTIMER: timer callback called, exiting.");
mainloop.Quit(new Eina.Value(0));
};
// Start the EFL main loop (and the experiment) // Start the EFL main loop (and the experiment)
mainloop.Begin(); mainloop.Begin();

View File

@ -16,62 +16,57 @@ public class Example
Efl.All.Init(Efl.Components.Ui); Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it // Create a window and initialize it
var win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { var win = new Efl.Ui.Win(null);
ewin.SetWinType(Efl.Ui.WinType.Basic); win.SetWinType(Efl.Ui.WinType.Basic);
ewin.SetText("Focus example"); win.SetText("Focus example");
ewin.SetAutohide(true); win.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => { win.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop // Exit the EFL main loop
Efl.Ui.Config.Exit(); Efl.Ui.Config.Exit();
}; };
});
// Create the main box container // Create the main box container
var vbox = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { var vbox = new Efl.Ui.Box(win);
ebox.SetHintMin(new Eina.Size2D(360, 240)); vbox.SetHintMin(new Eina.Size2D(360, 240));
win.SetContent(ebox); win.SetContent(vbox);
});
// Create some check boxes // Create some check boxes
Efl.Ui.Check first_checkbox = null; Efl.Ui.Check first_checkbox = null;
for (int i = 0; i< 5; i++) { for (int i = 0; i< 5; i++) {
var checkbox = new Efl.Ui.Check(vbox, (Efl.Ui.Check echeck) => { var checkbox = new Efl.Ui.Check(vbox);
echeck.SetText("Check " + i); checkbox.SetText("Check " + i);
echeck.SetHintAlign(0.5, 0.5); checkbox.SetHintAlign(0.5, 0.5);
echeck.FocusChangedEvt += FocusChangedCb; checkbox.FocusChangedEvt += FocusChangedCb;
vbox.DoPack(echeck); vbox.DoPack(checkbox);
});
if (i == 0) first_checkbox = checkbox; if (i == 0) first_checkbox = checkbox;
}; };
// Create an horizontal box to contain the two buttons // Create an horizontal box to contain the two buttons
var hbox = new Efl.Ui.Box(vbox, (Efl.Ui.Box ebox) => { var hbox = new Efl.Ui.Box(vbox);
ebox.SetDirection(Efl.Ui.Dir.Horizontal); hbox.SetDirection(Efl.Ui.Dir.Horizontal);
vbox.DoPack(ebox); vbox.DoPack(hbox);
});
// Create a "Focus Mover" button // Create a "Focus Mover" button
new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => { var button = new Efl.Ui.Button(hbox);
ebutton.SetText("Focus mover"); button.SetText("Focus mover");
ebutton.FocusChangedEvt += FocusChangedCb; button.FocusChangedEvt += FocusChangedCb;
ebutton.ClickedEvt += (object sender, EventArgs e) => { button.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Focus Mover"); Console.WriteLine("Clicked Focus Mover");
// Manually transfer focus to the first check box // Manually transfer focus to the first check box
Efl.Ui.Focus.Util.Focus(first_checkbox); Efl.Ui.Focus.Util.Focus(first_checkbox);
}; };
hbox.DoPack(ebutton); hbox.DoPack(button);
});
// Create a Quit button // Create a Quit button
new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => { button = new Efl.Ui.Button(hbox);
ebutton.SetText("Quit"); button.SetText("Quit");
ebutton.FocusChangedEvt += FocusChangedCb; button.FocusChangedEvt += FocusChangedCb;
ebutton.ClickedEvt += (object sender, EventArgs e) => { button.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Quit"); Console.WriteLine("Clicked Quit");
Efl.Ui.Config.Exit(); Efl.Ui.Config.Exit();
}; };
hbox.DoPack(ebutton); hbox.DoPack(button);
});
// Show the focus highlight // Show the focus highlight
win.SetFocusHighlightEnabled(true); win.SetFocusHighlightEnabled(true);

View File

@ -12,23 +12,21 @@ public class Example
// Create a box container full of buttons // Create a box container full of buttons
static Efl.Ui.Box CreateBox(Efl.Ui.Win win) static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
{ {
Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { Efl.Ui.Box box = new Efl.Ui.Box(win);
// Set distance between contained elements // Set distance between contained elements
ebox.SetPackPadding(5, 0, true); box.SetPackPadding(5, 0, true);
});
for (int i = 1; i <= 4; ++i) for (int i = 1; i <= 4; ++i)
{ {
// Add 4 buttons, one below the other // Add 4 buttons, one below the other
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { var button = new Efl.Ui.Button(win);
ebutton.SetText($"Boxed {i}"); button.SetText($"Boxed {i}");
if (i == 2) if (i == 2)
{ {
// Button 2 has its maximum size limited, so it will be smaller // Button 2 has its maximum size limited, so it will be smaller
ebutton.SetHintMax(new Eina.Size2D(100,50)); button.SetHintMax(new Eina.Size2D(100,50));
} }
box.DoPack(ebutton); box.DoPack(button);
});
} }
return box; return box;
@ -37,26 +35,24 @@ public class Example
// Create a simple table layout // Create a simple table layout
static Efl.Ui.Table CreateTable(Efl.Ui.Win win) static Efl.Ui.Table CreateTable(Efl.Ui.Win win)
{ {
Efl.Ui.Table table = new Efl.Ui.Table(win, (Efl.Ui.Table etable) => { 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 with two columns, that get filled left to right, and then top to bottom
etable.SetTableColumns(2); table.SetTableColumns(2);
etable.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down); table.SetTableDirection(Efl.Ui.Dir.Right, Efl.Ui.Dir.Down);
}); Efl.Ui.Button button;
for (int i = 1; i <= 4; ++i) for (int i = 1; i <= 4; ++i)
{ {
// Add 4 buttons, following the defined table flow // Add 4 buttons, following the defined table flow
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { button = new Efl.Ui.Button(win);
ebutton.SetText($"Table {i}"); button.SetText($"Table {i}");
table.DoPack(ebutton); table.DoPack(button);
});
} }
// Last button spans two table cells // Last button spans two table cells
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { button = new Efl.Ui.Button(win);
ebutton.SetText("Long Button"); button.SetText("Long Button");
table.PackTable(ebutton, 0, 2, 2, 1); table.PackTable(button, 0, 2, 2, 1);
});
return table; return table;
} }
@ -70,24 +66,22 @@ public class Example
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.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { Efl.Ui.Win win = new Efl.Ui.Win(null);
ewin.SetWinType(Efl.Ui.WinType.Basic); win.SetWinType(Efl.Ui.WinType.Basic);
ewin.SetText("Container demo"); win.SetText("Container demo");
ewin.SetAutohide(true); win.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => { win.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop // Exit the EFL main loop
Efl.Ui.Config.Exit(); Efl.Ui.Config.Exit();
}; };
});
// Give the window an initial size so there is room to resize the panes. // Give the window an initial size so there is room to resize the panes.
// Otherwise, all widgets are tightly packed // Otherwise, all widgets are tightly packed
win.SetSize(new Eina.Size2D(350,250)); win.SetSize(new Eina.Size2D(350,250));
// Create a vertically-split panes container // Create a vertically-split panes container
Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => { Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win);
epanes.SetSplitRatio(0.75); vsplit.SetSplitRatio(0.75);
win.SetContent(epanes); win.SetContent(vsplit);
});
// 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 = CreateBox(win);
@ -95,10 +89,9 @@ public class Example
// 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
// the second pane of the first container // the second pane of the first container
Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => { Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win);
epanes.SetDirection(Efl.Ui.Dir.Horizontal); hsplit.SetDirection(Efl.Ui.Dir.Horizontal);
epanes.SetSplitRatio(0.85); hsplit.SetSplitRatio(0.85);
});
Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit); Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
// 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
@ -108,14 +101,13 @@ public class Example
// Create a button and set it as the content of the second pane of the horizontal // Create a button and set it as the content of the second pane of the horizontal
// container // container
Efl.Ui.Button quit_btn = new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { Efl.Ui.Button quit_btn = new Efl.Ui.Button(win);
ebutton.SetText("Quit"); quit_btn.SetText("Quit");
ebutton.SetHintMax(new Eina.Size2D(150, 30)); quit_btn.SetHintMax(new Eina.Size2D(150, 30));
ebutton.ClickedEvt += (object sender, EventArgs e) => { quit_btn.ClickedEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop // Exit the EFL main loop
Efl.Ui.Config.Exit(); Efl.Ui.Config.Exit();
}; };
});
Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn); Efl.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
// Start the EFL main loop // Start the EFL main loop

View File

@ -19,40 +19,35 @@ public class Example
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.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { Efl.Ui.Win win = new Efl.Ui.Win(null);
ewin.SetWinType(Efl.Ui.WinType.Basic); win.SetWinType(Efl.Ui.WinType.Basic);
ewin.SetText("Size Control"); win.SetText("Size Control");
ewin.SetAutohide(true); win.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => { win.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop // Exit the EFL main loop
Efl.Ui.Config.Exit(); Efl.Ui.Config.Exit();
}; };
});
// Create a box container // Create a box container
Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { Efl.Ui.Box box = new Efl.Ui.Box(win);
win.SetContent(ebox); win.SetContent(box);
});
// Create a regular button (without size hints) // Create a regular button (without size hints)
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { var button = new Efl.Ui.Button(win);
ebutton.SetText("Button"); button.SetText("Button");
box.DoPack(ebutton); box.DoPack(button);
});
// Create a small button (max size is limited) // Create a small button (max size is limited)
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { button = new Efl.Ui.Button(win);
ebutton.SetText("Small"); button.SetText("Small");
ebutton.SetHintMax(new Eina.Size2D(50,50)); button.SetHintMax(new Eina.Size2D(50,50));
box.DoPack(ebutton); box.DoPack(button);
});
// Create a big button (min size is limited) // Create a big button (min size is limited)
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => { button = new Efl.Ui.Button(win);
ebutton.SetText("Big button"); button.SetText("Big button");
ebutton.SetHintMin(new Eina.Size2D(100,100)); button.SetHintMin(new Eina.Size2D(100,100));
box.DoPack(ebutton); box.DoPack(button);
});
// Start the EFL main loop // Start the EFL main loop
Efl.Ui.Config.Run(); Efl.Ui.Config.Run();

View File

@ -8,19 +8,16 @@ public class Example
static void ObjCreate() static void ObjCreate()
{ {
// First create a root element // First create a root element
root = new Efl.ModelItem(null, (Efl.ModelItem eroot) => { root = new Efl.ModelItem(null);
eroot.SetName("Root"); root.SetName("Root");
});
// Create the first child element // Create the first child element
new Efl.ModelItem(root, (Efl.ModelItem eroot) => { var child = new Efl.ModelItem(root);
eroot.SetName("Child1"); child.SetName("Child1");
});
// Create the second child element, this time, with an extra reference // Create the second child element, this time, with an extra reference
child2 = new Efl.ModelItem(root, (Efl.ModelItem eroot) => { child2 = new Efl.ModelItem(root);
eroot.SetName("Child2"); child2.SetName("Child2");
});
} }
// Destroy the test hierarchy // Destroy the test hierarchy

View File

@ -18,46 +18,42 @@ public class Example
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.Win win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => { Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
// Set the window's title // Set the window's title
ewin.SetText("Hello World"); win.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); win.SetAutohide(true);
// Hook to the Hide event // Hook to the Hide event
ewin.HideEvt += QuitCb; win.HideEvt += QuitCb;
});
// Create a box container // Create a box container
Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { var box = new Efl.Ui.Box(win);
// Set its minimum size // Set its minimum size
ebox.SetHintMin(new Eina.Size2D(360, 240)); box.SetHintMin(new Eina.Size2D(360, 240));
// Set the box as the content for the window // Set the box as the content for the window
// The window size will adapt to the box size // The window size will adapt to the box size
win.SetContent(ebox); win.SetContent(box);
});
// Create a text label widget // Create a text label widget
new Efl.Ui.Text(box, (Efl.Ui.Text etext) => { var label = new Efl.Ui.Text(box);
// Set its content and customize it // Set its content and customize it
etext.SetText("Hello World. This is an Efl.Ui application!"); label.SetText("Hello World. This is an Efl.Ui application!");
etext.SetSelectionAllowed(false); label.SetSelectionAllowed(false);
etext.SetHintWeight(1.0, 0.9); label.SetHintWeight(1.0, 0.9);
etext.SetHintAlign(0.5, 0.5); label.SetHintAlign(0.5, 0.5);
// Add the text to the box container // Add the text to the box container
box.DoPack(etext); box.DoPack(label);
});
// Create a button widget // Create a button widget
new Efl.Ui.Button(box, (Efl.Ui.Button ebutton) => { var button = new Efl.Ui.Button(box);
// Customize it // Customize it
ebutton.SetText("Quit"); button.SetText("Quit");
ebutton.SetHintWeight(1.0, 0.1); button.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 // Add the button to the box container
box.DoPack(ebutton); box.DoPack(button);
});
// Start the EFL main loop // Start the EFL main loop
Efl.Ui.Config.Run(); Efl.Ui.Config.Run();

View File

@ -11,13 +11,12 @@ public class Example
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.Win win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => { Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
// Set the window's title // Set the window's title
ewin.SetText("Hello World"); win.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); win.SetAutohide(true);
});
// Window size must be explicitly set, otherwise it will be invisible // Window size must be explicitly set, otherwise it will be invisible
// due to its lack of content. // due to its lack of content.
win.SetSize(new Eina.Size2D(360, 240)); win.SetSize(new Eina.Size2D(360, 240));