ui_mono: Add hello-gui and focus tutorials for C#
This commit is contained in:
parent
5ef0044cca
commit
0e7a34e074
|
@ -0,0 +1,9 @@
|
|||
project(
|
||||
'efl-example-focus', 'cs',
|
||||
version : '0.0.1',
|
||||
meson_version : '>= 0.38.0')
|
||||
|
||||
efl_mono = dependency('efl-mono', version : '>=1.20.99')
|
||||
efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
|
||||
|
||||
subdir('src')
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
|
||||
public class Example
|
||||
{
|
||||
public static void QuitCb(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("Clicked Quit");
|
||||
efl.ui.Config.Exit();
|
||||
}
|
||||
|
||||
public static void AboutCb(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("Clicked About");
|
||||
}
|
||||
|
||||
public static void FocusChangedCb(object sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine($"Focus for object {((efl.Text)sender).GetText()} changed to {((efl.ui.Widget)sender).GetFocus()}");
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
efl.All.Init(efl.Components.Ui);
|
||||
|
||||
efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => {
|
||||
ewin.SetWinType(efl.ui.win.Type.Basic);
|
||||
ewin.SetText("Hello World");
|
||||
ewin.SetAutohide(true);
|
||||
});
|
||||
win.HIDE += QuitCb;
|
||||
|
||||
efl.ui.Box box = new efl.ui.BoxConcrete(win);
|
||||
eina.Size2D sz;
|
||||
sz.W = 360;
|
||||
sz.H = 240;
|
||||
box.SetHintMin(sz);
|
||||
win.SetContent(box);
|
||||
|
||||
efl.ui.Text text = new efl.ui.TextConcrete(box);
|
||||
text.SetText("Label");
|
||||
text.SetEditable(false);
|
||||
text.FOCUS_CHANGED += FocusChangedCb;
|
||||
box.Pack(text);
|
||||
|
||||
efl.ui.Box hbox = new efl.ui.BoxConcrete(box);
|
||||
hbox.SetDirection(efl.ui.Dir.Horizontal);
|
||||
hbox.SetHintWeight(1.0, 0.1);
|
||||
box.Pack(hbox);
|
||||
|
||||
efl.ui.Button about = new efl.ui.ButtonConcrete(hbox);
|
||||
about.SetText("About");
|
||||
about.FOCUS_CHANGED += FocusChangedCb;
|
||||
about.CLICKED += AboutCb;
|
||||
hbox.Pack(about);
|
||||
|
||||
efl.ui.Button quit = new efl.ui.ButtonConcrete(hbox);
|
||||
quit.SetText("Quit");
|
||||
quit.FOCUS_CHANGED += FocusChangedCb;
|
||||
quit.CLICKED += QuitCb;
|
||||
hbox.Pack(quit);
|
||||
|
||||
// TODO: Create public references to classes
|
||||
// efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about);
|
||||
|
||||
efl.ui.Config.Run();
|
||||
|
||||
efl.All.Shutdown();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
src = files([
|
||||
'focus_main.cs',
|
||||
])
|
||||
|
||||
deps = [efl_mono]
|
||||
|
||||
executable('efl_example_focus', src,
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
|
@ -0,0 +1,10 @@
|
|||
project(
|
||||
'efl-example-gui', 'cs',
|
||||
version : '0.0.1',
|
||||
meson_version : '>= 0.38.0')
|
||||
|
||||
efl_mono = dependency('efl-mono', version : '>=1.20.99')
|
||||
efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
|
||||
|
||||
subdir('src')
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
|
||||
public class Example
|
||||
{
|
||||
public static void QuitCb(object sender, EventArgs e)
|
||||
{
|
||||
efl.ui.Config.Exit();
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
efl.All.Init(efl.Components.Ui);
|
||||
|
||||
efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => {
|
||||
ewin.SetWinType(efl.ui.win.Type.Basic);
|
||||
ewin.SetText("Hello World");
|
||||
ewin.SetAutohide(true);
|
||||
});
|
||||
|
||||
// when the user clicks "close" on a window there is a request to hide
|
||||
win.HIDE += QuitCb;
|
||||
|
||||
efl.ui.Box box = new efl.ui.BoxConcrete(win);
|
||||
eina.Size2D sz;
|
||||
sz.W = 360;
|
||||
sz.H = 240;
|
||||
box.SetHintMin(sz);
|
||||
|
||||
win.SetContent(box);
|
||||
|
||||
efl.ui.Text text = new efl.ui.TextConcrete(box);
|
||||
// text.SetMarkup("Hello World.<br>This is an <b>Efl.Ui</b> application!"); // TODO: Correct .eo inheritance
|
||||
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);
|
||||
|
||||
box.Pack(text);
|
||||
|
||||
efl.ui.Button button = new efl.ui.ButtonConcrete(box);
|
||||
button.SetText("Quit");
|
||||
button.SetHintWeight(1.0, 0.1);
|
||||
|
||||
button.CLICKED += QuitCb;
|
||||
|
||||
box.Pack(button);
|
||||
|
||||
efl.ui.Config.Run();
|
||||
|
||||
efl.All.Shutdown();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
src = files([
|
||||
'gui_main.cs',
|
||||
])
|
||||
|
||||
deps = [efl_mono]
|
||||
|
||||
executable('efl_example_gui', src,
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
Loading…
Reference in New Issue