Compare commits

...

78 Commits

Author SHA1 Message Date
Xavi Artigas df21c3770e calculator: Adapt to latest Text_Cursor API 2020-04-27 12:19:03 +02:00
Xavi Artigas f835d45622 mono calculator: fix font size of main screen
Apparently setting editable=false resets the font size.
While we investigate that, this is a workaround.
2020-02-20 18:57:35 +01:00
Xavi Artigas 5f1be675ee mono-examples: Adapt to latest syntax
Setter and Getters have disappeared. Now everything is accessed through properties like:
Text, Disabled, Autohide, Color, Orientation, ContentPadding, Size, ScrollableText, Align, Name.
Also the Life and Containers examples had several issues.
Text override from custom widgets is still not solved.
2020-02-20 18:48:55 +01:00
Xavi Artigas 6e77c4aae2 homescreen: Do not show apps that do not want to be shown
As mandated by the .desktop files.
Otherwise, you might get missing icons.
2020-02-20 16:55:35 +01:00
Xavi Artigas f3076c6d19 homescreen: Simplify code and UI structure
Remove global variables.
Add comments.
General beautification.
2020-02-20 16:55:35 +01:00
Xavi Artigas ac5879e3e5 homescreen: Initial import from bu5hm4n code
Just removed custom Edje classes and tried to replace them with
Efl.Ui classes (for simplicity).
2020-02-12 10:27:59 +01:00
Xavi Artigas b694a830af Updated .gitignore 2020-02-12 10:27:17 +01:00
Xavi Artigas 6a470840d9 mono-examples: Adapt to latest syntax (EventArgs.arg -> Arg)
Also workaround some temporary inability to set struct members.
2020-02-07 09:49:57 +01:00
Xavi Artigas dfa678e9dc Add the now-mandatory @since tags to example EO files 2020-02-07 09:11:59 +01:00
Xavi Artigas 4b6740b258 Adapt Eina.Array example to latest syntax 2020-01-17 10:18:13 +01:00
Ali Alzyod 870cda6730 EXAMPLES efl.text.style: reflect updates
Reviewers: segfaultxavi

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D10898
2019-12-20 10:01:00 +01:00
Xavi Artigas be0ade4350 Adapt to latest Textbox changes 2019-12-17 16:34:34 +01:00
Xavi Artigas 6f183d62c2 Adapt to latest changes
Including removal of the manual inclusion of text headers!
2019-12-13 13:27:06 +01:00
Xavi Artigas cba451e99b More adaptation to latest Text changes
Previous fix relied on old headers still being present, which is not good.
2019-12-11 15:51:03 +01:00
Xavi Artigas aeaba83065 Adapt to latest Text changes 2019-12-09 15:46:27 +01:00
Xavi Artigas 868ed77548 Update code comments (and typos) 2019-10-28 09:48:42 +01:00
Xavi Artigas d57c8e2d28 Add documentation for C and C# calculator examples 2019-10-24 12:44:25 +02:00
Xavi Artigas f9486b6bfd Example C# calculator app
For simplicity, only integer operations and no direct editing of the numbers.
This is meant as a simple UI example, not as a CS exercise.
2019-10-24 10:54:17 +02:00
Xavi Artigas 8caeaaf071 Example C Calculator app
For simplicity, only integer operations and no direct editing of the numbers.
This is meant as a simple UI example, not as a CS exercise.
2019-10-23 17:11:33 +02:00
Xavi Artigas 95c373e8e3 Only ignore topmost meson.build
This is autogenerated, but not all other meson.build files in subdirs.
2019-10-23 13:37:58 +02:00
Lauro Moura b8f57276ef Initial version of demo MVVM app
Summary:
For now, a static model with a simple CollectionView.

The idea is to create a model that fetches some info from the web,
like weather forecast, and show it to the user.

Depends on D10300

Reviewers: SanghyeonLee, felipealmeida, cedric, bu5hm4n

Reviewed By: SanghyeonLee

Subscribers: brunobelo

Differential Revision: https://phab.enlightenment.org/D10302
2019-10-17 13:09:27 -03:00
Xavi Artigas b8fd0c3b74 Adapt examples to latest Unified API changes
Efl.Ui.Text headers have to be manually included for now, since they still depend
on Legacy headers.
Padding API has lost a parameter.
2019-10-03 12:19:03 +02:00
Xavi Artigas 0a23c904cb Game of Life: Remove last uses of Legacy API 2019-10-03 12:12:38 +02:00
Xavi Artigas 6dfa4bac1d cs snippets: small updates to Slider and Box 2019-10-02 16:27:28 +02:00
Lukasz Oleksak 9f0eebb54f Example code for Efl.Ui.* widgets
Reviewers: segfaultxavi, woohyun

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D10269
2019-10-02 16:24:48 +02:00
Lukasz Oleksak 670a6bc902 Example code for Efl.Ui.Win
Reviewers: segfaultxavi, woohyun

Reviewed By: segfaultxavi

Tags: #efl, #examples

Differential Revision: https://phab.enlightenment.org/D9982
2019-09-23 13:12:12 +02:00
Mike Blumenkrantz fea913d1e1 life: remove Elementary.h usage
Summary: this should not be needed

Reviewers: segfaultxavi

Reviewed By: segfaultxavi

Tags: #examples

Differential Revision: https://phab.enlightenment.org/D10021
2019-09-19 16:33:08 +02:00
Xavi Artigas fd32510f35 mono snippets: Added README in the snippets folder 2019-09-17 12:10:22 +02:00
Bruno da Silva Belo 242ed076f3 csharp: Basic components for all tests without Ui.
Summary:
Uiless tests use basic components.
Make test terminate again.

Reviewers: lauromoura, felipealmeida, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: brunobelo, felipealmeida, lauromoura

Differential Revision: https://phab.enlightenment.org/D9916
2019-09-12 15:04:11 +02:00
Xavi Artigas f161620f9f mono-examples: Do not initialize the UI component if it is not needed 2019-09-12 11:20:37 +02:00
Lauro Moura 3aecb39a18 csharp: Use basic components in core event test
Summary: No need to start elm, as T7770 was fixed.

Reviewers: brunobelo, felipealmeida

Reviewed By: brunobelo

Differential Revision: https://phab.enlightenment.org/D9915
2019-09-11 18:05:28 -03:00
Xavi Artigas 5a4c817d16 mono-examples: Use Del() to dispose of widgets 2019-09-09 22:10:43 +02:00
Xavi Artigas 40801d9285 mono-examples: adapt to latest bindings syntax 2019-09-06 16:10:16 +02:00
Xavi Artigas 5472a77fb3 mono-examples: adapt to latest bindings syntax 2019-09-06 16:01:45 +02:00
Ali Alzyod 17609ba6bf example: fix compilation error
Reviewers: segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D9815
2019-09-02 16:18:46 +02:00
Xavi Artigas 93120a13f5 Adapt to latest changes in Efl.Ui.AlertPopup 2019-08-27 13:22:00 +02:00
Bruno da Silva Belo fa93b9f7c0 Fixing compiles errors from examples, c and c#.
Summary: Change from efl broke the compilation of examples, updating names to the new changes.

Reviewers: lauromoura, felipealmeida

Reviewed By: lauromoura

Differential Revision: https://phab.enlightenment.org/D9581
2019-08-16 15:31:38 -03:00
Xavi Artigas e8245fe5dd Remove EFL_EO_API_SUPPORT
This is not needed anymore.
2019-07-24 12:11:58 +02:00
Xavi Artigas 4c2c569c7e hello-gui: make text non-editable
Non-editable was the default when these tutorials were created, but not anymore.
2019-07-17 12:49:42 +02:00
Lauro Moura 9ed9d94501 csharp: Make examples build again.
Summary: OnInitialize changed signature in D9178

Reviewers: vitor.sousa, segfaultxavi

Reviewed By: vitor.sousa

Differential Revision: https://phab.enlightenment.org/D9213
2019-06-28 20:04:38 -03:00
Xavi Artigas a49641d9b4 efl-mono: Make the setup.py script work again
It was broken when the snippets folder was added without a meson.build file.
2019-06-14 12:46:50 +02:00
Xavi Artigas b2c7e2c2dd efl-mono: Add custom widget example 2019-06-14 12:27:40 +02:00
Xavi Artigas d325da2119 efl-mono: Efl.Ui.Dir -> Efl.Ui.LayoutOrientation 2019-06-14 12:25:26 +02:00
Xavi Artigas 21567fcccf Efl.Ui.Dir -> Efl.Ui.Layout_Orientation 2019-06-14 11:18:23 +02:00
Xavi Artigas af73959386 Use direction instead of table_direction in table examples
Efl.Ui.Direction.direction is simpler to understand than
Efl.Pack_table.table_direction. Also, the latter might disappear very soon.
2019-05-17 15:26:02 +02:00
Xavi Artigas 836a9edf73 mono examples: Update to latest Efl.Ui.Clickable syntax 2019-05-15 12:01:16 +02:00
Xavi Artigas 05d9b74e19 texteditor app: no need to use efl_part
efl_content_set() will access that part, there's no need to retrieve "efl.content".
Plus, that part is not advertised in the button's EO file, so I am not sure it is
legal to access it.
2019-05-14 17:01:17 +02:00
Xavi Artigas 6cb115480e mono-examples: Update to latest Part syntax 2019-05-07 13:56:23 +02:00
Xavi Artigas fdeb87bb75 Fix alignment of some widgets
Summary:
Commit 78ae9c0ae069ff86e701ff98cf5674cc491ee156 introduced a new API
(efl_gfx_hint_fill_set) and changed the default behavior of aligned widgets.
The same commit made the necessary changes to all examples in the efl repo,
but not in the examples repo.
This patch here aligns the widgets again they way they were meant to.
We have gone 6 months without anybody noticing that the examples did not
render correctly... let's try and add some unit tests later.

Test Plan: Try the hello-gui c tutorial. The text should be centered instead of in a corner.

Reviewers: YOhoho, bu5hm4n

Differential Revision: https://phab.enlightenment.org/D8791
2019-04-30 18:56:39 +02:00
Xavi Artigas b2c41e4e01 mono-examples: Adapt to changes in Efl.Pack 2019-04-26 12:58:15 +02:00
Lauro Moura 595be4aa12 csharp: Update examples after repeated method name
Summary:
In essence, IPack.DoPack became IPack.Pack

Depends on D8650

Reviewers: felipealmeida, vitor.sousa, segfaultxavi

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D8651
2019-04-23 12:33:00 +02:00
Xavi Artigas f47f1f3672 mono-example: Remove ugly static_cast
Since D8550 apps do not need to use static_cast nor Concrete classes.
2019-04-17 11:03:21 +02:00
Xavi Artigas d4e81b7b65 mono-snippets: Add sample property snippet 2019-04-12 09:57:51 +02:00
Xavi Artigas 5f436d2874 mono: Initial snippet example to use with DocFX
eolian_mono now allows external examples to be embedded in the cs files, which
then appear in the DocFX pages.
This new folder is the proposed place to put all these external examples.
2019-04-11 16:21:09 +02:00
Xavi Artigas 169f569af6 Fix runtime ERR regarding WinType
WinType can only be set during construction, so SetWinType() should never
be called. Use the constructor parameter for this.
2019-04-04 13:17:30 +02:00
Xavi Artigas b55e5150c9 mono examples: Adapt to Efl.Csharp.Application
This class simplifies app development, so the examples have to showcase it.
Basically:
- Your app inherits form it
- You do not need to init() or shutdown()
- You override the methods you want (like OnInitialize).

Fixes T7655
Differential Revision: https://phab.enlightenment.org/D8477
2019-03-26 16:24:20 +01:00
Xavi Artigas 871add6fe5 Remove BETA support from Hello Cmd
This tutorial only requires stable API now!
No need to request BETA (or EO) support.
2019-03-25 13:40:03 +01:00
Lauro Moura 735b848660 csharp: Changes after adding I to interfaces
Summary:
 Ref T7751
 Depends on D8397 in the EFL repo

Reviewers: segfaultxavi, vitor.sousa, felipealmeida

Reviewed By: segfaultxavi

Tags: #efl_language_bindings

Maniphest Tasks: T7751

Differential Revision: https://phab.enlightenment.org/D8398
2019-03-22 09:14:27 +01:00
Ali Alzyod 82dd23ba02 Fix Hello World tutorial (multiline support)
Summary: Add the missing multiline enable, to reflect <br> in markup text

Reviewers: segfaultxavi, woohyun, bowonryu

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D8391
2019-03-18 19:32:53 +01:00
Xavi Artigas 43bb6e3896 mono examples: Adapt to latest event names 2019-03-09 16:00:08 +01:00
Xavi Artigas 679c89d98d Adapt to latest event names 2019-03-09 15:54:38 +01:00
Xavi Artigas aad5b641c8 More fixes to adapt to latest API changes
EFL_UI_WIN_BASIC -> EFL_UI_WIN_TYPE_BASIC
2019-03-05 09:30:09 +01:00
Xavi Artigas 3e1aefa7ea Further fixes to adapt to latest API changes 2019-03-04 18:17:36 +01:00
Mike Blumenkrantz d16b7e48bc fix examples build for latest efl 2019-03-02 10:38:07 -05:00
Lauro Moura 780ebf91c5 examples: Changes after optional parameters
Summary:
After a new iteration of D7789, constructor parameters were split among
required and optionals.

This patch depends on making some Efl.Ui.Win parameters optional.

Reviewers: segfaultxavi, vitor.sousa

Reviewed By: vitor.sousa

Tags: #efl_language_bindings

Differential Revision: https://phab.enlightenment.org/D7851
2019-02-07 18:42:36 -02:00
Lauro Moura 09416b5ccf examples: Change Model_Item to Generic_Model
Summary: This class was renamed in D7533 in the EFL repo.

Test Plan: Run examples

Reviewers: segfaultxavi, felipealmeida

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D7850
2019-02-01 10:14:28 +01:00
Felipe Magno de Almeida 1d5a5322df efl-mono: Fix examples based on new D7789 2019-01-28 16:03:49 +09:00
Xavi Artigas 500049f1eb 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
2019-01-23 14:49:38 +01:00
Lauro Moura e674ff0d97 Add arcconfig
Reviewers: bu5hm4n, segfaultxavi

Reviewed By: segfaultxavi

Differential Revision: https://phab.enlightenment.org/D7726
2019-01-23 14:37:33 +01:00
Xavi Artigas af8036ab17 Adapt EO tutorials to latest Eolian inheritance syntax
Rectangle(Efl.Object, ...) -> Rectangle extends Efl.Object implements ...
2019-01-23 11:18:45 +01:00
Xavi Artigas 9751e2ed82 Adapt examples translation API changes
translatable -> l10n
2019-01-18 13:35:35 +01:00
Xavi Artigas a5c08814d8 examples-mono: Update Eina comments to latest syntax 2019-01-15 13:19:08 +01:00
Xavi Artigas e06157c1f6 efl-mono: Use new Eina.Value implicit conversions 2018-12-31 17:36:21 +01:00
Marcel Hollerbach a7c5ff510e Adapt examples to new App API
loop_main has been renamed to app_main.
2018-12-20 16:33:33 +01:00
Xavi Artigas d74a4df994 csharp examples: Adapt to new classes syntax
Summary: Mainly use PascalCase Namespaces and Classes and proper event names.

Test Plan: Check all examples still build.

Reviewers: lauromoura, vitor.sousa, felipealmeida, bu5hm4n

Reviewed By: bu5hm4n

Differential Revision: https://phab.enlightenment.org/D7479
2018-12-19 16:51:15 +01:00
Marcel Hollerbach 656b746be7 README: add instructions for using setup.py 2018-11-19 16:42:12 +01:00
Marcel Hollerbach d8ea961985 build: autodetect if cxx bindings or mono is build
if it is - build the examples, if not - don't add the examples to the
subprojects that are build.
2018-11-19 16:42:12 +01:00
Xavi Artigas e6aa5e6aa0 csharp-texteditor: adapt to new efl.ui.Popup API 2018-11-16 11:50:50 +01:00
179 changed files with 2157 additions and 1102 deletions

7
.arcconfig Normal file
View File

@ -0,0 +1,7 @@
{
"project_id" : "examples",
"projects" : "examples",
"conduit_uri" : "https://phab.enlightenment.org/",
"phabricator.uri" : "https://phab.enlightenment.org/",
"repository.callsign" : "examples"
}

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
build
*.pot
.*.swp
subprojects
meson.build
/meson.build

17
README
View File

@ -19,3 +19,20 @@ the appropriate steps automatically.
Directory naming is <type>/<language>/<name> please be careful to
namespace example binaries in case they are installed by the user.
Building the whole set of Examples
==================================
You can build all examples at once, all you have to do is:
./setup.py
This will create a folder called subprojects, all examples are
then sym-linked into this directory, a corresponding meson.build
file is generated, which uses every example as a subproject.
After that you can build the meson project with:
* mkdir build
* meson build/
* cd build
* ninja all

View File

@ -0,0 +1,13 @@
project(
'efl-example-calculator', 'c',
version : '0.0.1',
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
meson_version : '>= 0.38.0')
eina = dependency('eina', version : '>=1.20.99')
efl = dependency('efl-ui', version : '>=1.20.99')
elm = dependency('elementary', version : '>=1.20.99')
inc = include_directories('.')
subdir('src')

View File

@ -0,0 +1,212 @@
#define EFL_BETA_API_SUPPORT 1
#include <Elementary.h>
#include <Efl_Ui.h>
static Efl_Ui_Textbox *_screen = NULL; // Text widget showing current value
static int _prev_value = 0; // Value introduced before an operation (first operand
static int _curr_value = 0; // Value currently being introduced (second operand)
static char _operation = '='; // Last operation button pressed
static Eina_Bool _must_overwrite = EINA_FALSE; // Whether next number must be appended to current input
// or overwrite it
// Quits the application
static void
_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
efl_exit(0);
}
// Performs "operation" on "currValue" and "prevValue" and leaves result in "currValue"
static void
_operate()
{
switch (_operation)
{
case '+':
_curr_value += _prev_value;
break;
case '-':
_curr_value = _prev_value - _curr_value;
break;
case '*':
_curr_value *= _prev_value;
break;
case '/':
_curr_value = _prev_value / _curr_value;
break;
default:
break;
}
}
// Called every time a button is pressed
static void
_button_pressed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
char button = ((const char *)data)[0];
// If it is a number, append it to current input (or replace it)
if (button >= '0' && button <= '9')
{
char str[2] = { button, '\0' };
if (_must_overwrite)
{
efl_text_set(_screen, "");
_must_overwrite = EINA_FALSE;
}
Efl_Text_Cursor_Object *cursor = efl_text_interactive_main_cursor_get(_screen);
efl_text_cursor_object_text_insert(cursor, str);
}
else
{
char str[32] = "";
// No need to sanitize these values, so do not emit "text changed" events
efl_event_freeze(_screen);
switch (button)
{
case 'C':
// Clear current input
efl_text_set(_screen, "0");
break;
case '+':
case '-':
case '*':
case '/':
case '=':
// If there was a pending operation, perform it
if (_operation != '=')
{
_operate();
snprintf(str, sizeof(str), "%d", _curr_value);
efl_text_set(_screen, str);
}
// Store this operation
_operation = button;
_must_overwrite = EINA_TRUE;
_prev_value = _curr_value;
break;
default:
break;
}
efl_event_thaw(_screen);
}
}
// Called every time the content of the screen changes
// We use it to sanitize input (remove leading zeros, for example)
// This makes more sense when the Text widget is editable, since the user
// is free to type anything.
static void
_screen_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
char _text[32] = "";
const char *str = efl_text_get(_screen);
int d;
if ((strcmp(str, "") == 0) || (strcmp(str, "-") == 0))
{
snprintf(_text, sizeof(_text), "0");
}
else if (sscanf(str, "%d", &d) == 1)
{
snprintf(_text, sizeof(_text), "%d", d);
_curr_value = d;
}
if (strncmp(_text, str, sizeof(_text)))
{
// Avoid infinite recursion when setting the text from the
// "text changed" callback
efl_event_freeze(_screen);
efl_text_set(_screen, _text);
efl_event_thaw(_screen);
}
}
// Creates an Efl.Ui.Button and positions it in the given position inside the table
// The button text is colored with "r, g, b"
// "text" is what is drawn on the button, which might be a multi-byte unicode string.
// "command" is a single-char id for the button.
static void
_button_add(Efl_Ui_Table *table, const char *text, const char *command, int posx, int posy, int r, int g, int b)
{
Efl_Ui_Button *button =
efl_add(EFL_UI_BUTTON_CLASS, table,
efl_pack_table(table, efl_added, posx, posy, 1, 1),
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _button_pressed_cb, command));
// Buttons can only have simple text (no font, styles or markup) but can swallow
// any other object we want.
// Therefore we create a more complex Efl_Ui_Text object and use it as content for the button.
Efl_Ui_Textbox *label =
efl_add(EFL_UI_TEXTBOX_CLASS, button,
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_text_horizontal_align_set(efl_added, 0.5),
efl_text_vertical_align_set(efl_added, 0.5),
efl_gfx_color_set(efl_added, r, g, b, 255),
efl_text_set(efl_added, text));
efl_text_font_family_set(label, "Sans");
efl_text_font_size_set(label, 36);
efl_content_set(button, label);
}
// Creates the UI
static void
_gui_setup()
{
Eo *win, *table;
// The window
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "EFL Calculator"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
// when the user clicks "close" on a window there is a request to delete
efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);
// The table is the main layout
table = efl_add(EFL_UI_TABLE_CLASS, win,
efl_content_set(win, efl_added),
efl_pack_table_size_set(efl_added, 4, 5),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(300, 400)));
// Create all buttons using the _button_add helper
_button_add(table, "1", "1", 0, 3, 255, 255, 255);
_button_add(table, "2", "2", 1, 3, 255, 255, 255);
_button_add(table, "3", "3", 2, 3, 255, 255, 255);
_button_add(table, "4", "4", 0, 2, 255, 255, 255);
_button_add(table, "5", "5", 1, 2, 255, 255, 255);
_button_add(table, "6", "6", 2, 2, 255, 255, 255);
_button_add(table, "7", "7", 0, 1, 255, 255, 255);
_button_add(table, "8", "8", 1, 1, 255, 255, 255);
_button_add(table, "9", "9", 2, 1, 255, 255, 255);
_button_add(table, "0", "0", 1, 4, 255, 255, 255);
_button_add(table, "+", "+", 3, 1, 128, 128, 128);
_button_add(table, "", "-", 3, 2, 128, 128, 128);
_button_add(table, "×", "*", 3, 3, 128, 128, 128);
_button_add(table, "÷", "/", 3, 4, 128, 128, 128);
_button_add(table, "=", "=", 2, 4, 128, 128, 128);
_button_add(table, "C", "C", 0, 4, 0, 0, 0);
// Create a big Efl.Ui.Textbox screen to display the current input
_screen = efl_add(EFL_UI_TEXTBOX_CLASS, table,
efl_text_set(efl_added, "0"),
efl_text_multiline_set(efl_added, EINA_FALSE),
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
efl_pack_table(table, efl_added, 0, 0, 4, 1),
efl_text_horizontal_align_set(efl_added, 0.9),
efl_text_vertical_align_set(efl_added, 0.5),
efl_text_effect_type_set(efl_added, EFL_TEXT_STYLE_EFFECT_TYPE_GLOW),
efl_text_glow_color_set(efl_added, 128, 128, 128, 128),
efl_event_callback_add(efl_added, EFL_UI_TEXTBOX_EVENT_CHANGED,
_screen_changed_cb, NULL));
efl_text_font_family_set(_screen, "Sans");
efl_text_font_size_set(_screen, 48);
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
_gui_setup();
}
EFL_MAIN()

View File

@ -0,0 +1,12 @@
src = files([
'calculator.c',
])
deps = [eina, efl, elm]
executable('efl_example_calculator', src,
dependencies : deps,
include_directories : inc,
install : true
)

View File

@ -0,0 +1,13 @@
project(
'efl-example-homescreen', 'c',
version : '0.0.1',
default_options: [ 'c_std=gnu99', 'warning_level=2' ],
meson_version : '>= 0.38.0')
eina = dependency('eina', version : '>=1.20.99')
efl = dependency('efl-ui', version : '>=1.20.99')
elm = dependency('elementary', version : '>=1.20.99')
inc = include_directories('.')
subdir('src')

Binary file not shown.

View File

@ -0,0 +1,311 @@
#define EFL_BETA_API_SUPPORT
#include <Efl_Ui.h>
#include <Eio.h>
#define TABLE_COLUMNS 4
#define TABLE_ROWS 5
typedef struct _Build_Data
{
Eo *over_container;
Efl_Io_Manager *io_manager;
Eo *table;
int x, y;
} Build_Data;
static const char *launcher_apps[][3] =
{ { "Call", "", "call-start" },
{ "Contacts", "", "contact-new" },
{ "Home", "xdg-open $HOME", "user-home" },
{ "Mail", "xdg-email 'info@enlightenment.org'", "mail-send-receive" },
{ "Documents", "xdg-open $(xdg-user-dir DOCUMENTS)", "folder-documents" } };
static void
_icon_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
const char *command = data;
printf("%s\n", command);
efl_add(EFL_EXE_CLASS, efl_main_loop_get(),
efl_core_command_line_command_string_set(efl_added, command),
efl_task_run(efl_added));
}
static void
_icon_deleted_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
free(data);
}
// If "string" begins with the "key" prefix, sets "value" to whatever comes after "key"
// up until the next \n, replacing it with a \0, in a newly allocated string
// (which must be freed).
// Returns 1 if key was found.
static int
_parse_token(const char *string, const char *key, char **value)
{
if (eina_str_has_prefix(string, key))
{
int key_len = strlen(key);
const char *end = strchr(string + key_len, '\n');
if (!end)
end = string + strlen(string); // Point to EOF '\0'
int len = end - string - key_len;
if (*value) free(*value);
*value = eina_strndup(string + key_len, len + 1);
*((*value) + len) = '\0';
return 1;
}
return 0;
}
// Reads a .desktop file and returns the app name, the command to launch and the icon name.
// Returns 0 if it didn't work.
// Free the strings after usage.
static int
_parse_desktop_file(const char *desktop_file_path, char **app_name, char **app_command, char **app_icon_name)
{
EINA_RW_SLICE_DECLARE(slice, 1024);
Efl_Io_File *desktop_file;
int ret = 0;
desktop_file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, desktop_file_path),
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE));
if (!desktop_file)
return 0;
char *name = NULL, *command = NULL, *icon = NULL, *onlyshow = NULL, *nodisplay = NULL;
while (!efl_io_reader_eos_get(desktop_file) &&
efl_io_reader_read(desktop_file, &slice) == EINA_ERROR_NO_ERROR)
{
char *content = eina_rw_slice_strdup(slice);
char *ptr = content;
while ((ptr = strchr(ptr, '\n')))
{
ptr++;
_parse_token(ptr, "Name=", &name);
_parse_token(ptr, "Exec=", &command);
_parse_token(ptr, "Icon=", &icon);
_parse_token(ptr, "OnlyShowIn=", &onlyshow);
_parse_token(ptr, "NoDisplay=", &nodisplay);
}
free(content);
}
if (name && command && icon && !onlyshow && (!nodisplay || eina_streq(nodisplay, "false")))
{
*app_name = name;
*app_command = command;
*app_icon_name = icon;
ret = 1;
}
else
{
if (name)
free(name);
if (command)
free(command);
if (icon)
free(icon);
}
if (onlyshow)
free(onlyshow);
if (nodisplay)
free(nodisplay);
efl_unref(desktop_file);
return ret;
}
// Creates a widget "button" with the specified name, icon and command
// to execute on click.
// These buttons are actually just an image with a label below.
static Efl_Ui_Widget *
_create_icon(Eo *parent, const char *name, const char *command, const char *icon)
{
Eo *box = efl_add(EFL_UI_BOX_CLASS, parent);
// Icon
efl_add(EFL_UI_IMAGE_CLASS, box,
efl_ui_image_icon_set(efl_added, icon),
efl_gfx_hint_weight_set(efl_added, 1.0, 1.0),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(64, 64)),
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _icon_clicked_cb, command),
efl_event_callback_add(efl_added, EFL_EVENT_DEL, _icon_deleted_cb, command),
efl_pack(box, efl_added));
// Label
efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_text_set(efl_added, name),
efl_text_multiline_set(efl_added, EINA_TRUE),
efl_canvas_textblock_style_apply(efl_added,
"effect_type=soft_shadow shadow_color=#444 wrap=word font_size=10 align=center ellipsis=1"),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(0, 40)),
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
efl_pack(box, efl_added));
return box;
}
// Creates a widget "button" for the specified .desktop file.
// These buttons are actually just an image with a label below.
static Efl_Ui_Widget *
_create_app_icon(Eo *parent, const char *desktop_file_path)
{
char *name = NULL, *command = NULL, *icon = NULL;
Eo *widget = NULL;
if (!_parse_desktop_file(desktop_file_path, &name, &command, &icon))
return NULL;
widget = _create_icon(parent, name, command, icon);
free(name);
free(icon);
return widget;
}
// Adds a new empty page to the homescreen
static void
_add_page(Build_Data *bdata)
{
bdata->table = efl_add(EFL_UI_TABLE_CLASS, bdata->over_container,
efl_pack_table_size_set(efl_added, TABLE_COLUMNS, TABLE_ROWS));
efl_pack_end(bdata->over_container, bdata->table);
bdata->x = bdata->y = 0;
}
// Adds all files in the array to the homescreen, adding pages as they become full.
static void
_app_found(void *data, Eina_Array *files)
{
unsigned int i;
const char *item;
Eina_Array_Iterator iterator;
Build_Data *bdata = data;
EINA_ARRAY_ITER_NEXT(files, i, item, iterator)
{
Eo *app = _create_app_icon(bdata->over_container, item);
if (app)
{
if (!bdata->table)
_add_page(bdata);
efl_pack_table(bdata->table, app, bdata->x, bdata->y, 1, 1);
bdata->x++;
if (bdata->x == TABLE_COLUMNS)
{
bdata->x = 0;
bdata->y++;
if (bdata->y == TABLE_ROWS)
bdata->table = NULL;
}
}
}
}
// Called when directory listing has finished
static Eina_Value
_file_listing_done_cb (void *data, const Eina_Value file, const Eina_Future *dead EINA_UNUSED)
{
Build_Data *bdata = data;
// Fill any remaining empty cells with invisible rectangles so the rest of the cells
// keep the same size as other pages
while (bdata->y < TABLE_ROWS)
{
while (bdata->x < TABLE_COLUMNS)
{
efl_add(EFL_CANVAS_RECTANGLE_CLASS, bdata->table,
efl_gfx_color_set(efl_added, 0, 0, 0, 0),
efl_pack_table(bdata->table, efl_added, bdata->x, bdata->y, 1, 1));
bdata->x++;
}
bdata->x = 0;
bdata->y++;
}
return file;
}
// Create Spotlight widget and start populating it with user apps.
static void
_build_homescreen(Efl_Ui_Win *win, Build_Data *bdata)
{
Efl_Ui_Spotlight_Indicator *indicator = efl_new(EFL_UI_SPOTLIGHT_ICON_INDICATOR_CLASS);
Efl_Ui_Spotlight_Manager *scroll = efl_new(EFL_UI_SPOTLIGHT_SCROLL_MANAGER_CLASS);
bdata->over_container = efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, win,
efl_ui_spotlight_manager_set(efl_added, scroll),
efl_ui_spotlight_indicator_set(efl_added, indicator)
);
bdata->table = NULL;
Eina_Future *future = efl_io_manager_ls(bdata->io_manager, "/usr/share/applications", bdata, _app_found, NULL);
eina_future_then(future, _file_listing_done_cb, bdata, NULL);
}
// The main box, with an upper space for the apps list and a lower space
// for the quick-action buttons.
static Efl_Ui_Widget*
_build_overall_structure(Efl_Ui_Win *win, Efl_Ui_Widget *homescreen)
{
Efl_Ui_Widget *box, *start_line;
box = efl_add(EFL_UI_BOX_CLASS, win);
// Set box background
// Objects retrieved with efl_part() only survive one function call, so we ref it
Eo *background = efl_ref(efl_part(box, "background"));
efl_file_key_set(background, "e/desktop/background");
efl_file_set(background, "../src/Hills.edj");
efl_file_load(background);
efl_unref(background);
efl_pack_end(box, homescreen);
// Start line
start_line = efl_add(EFL_UI_BOX_CLASS, win,
efl_gfx_color_set(efl_part(efl_added, "background"), 128, 128, 128, 128));
efl_gfx_hint_weight_set(start_line, 1.0, 0.0);
efl_ui_layout_orientation_set(start_line, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
efl_pack_end(box, start_line);
for (unsigned int i = 0; i < sizeof(launcher_apps)/sizeof(launcher_apps[0]); ++i)
{
efl_pack_end(start_line, _create_icon(start_line,
launcher_apps[i][0],
strdup(launcher_apps[i][1]),
launcher_apps[i][2]));
}
return box;
}
// Called when the app is closed
static void
_gui_quit_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Build_Data *bdata = data;
if (bdata->io_manager)
efl_del(bdata->io_manager);
free(bdata);
efl_exit(0);
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
Eo *win, *desktop;
Build_Data *bdata = calloc (1, sizeof(Build_Data));
bdata->io_manager = efl_add(EFL_IO_MANAGER_CLASS, efl_main_loop_get());
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
// when the user clicks "close" on a window there is a request to delete
efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, bdata);
_build_homescreen(win, bdata);
desktop = _build_overall_structure(win, bdata->over_container);
efl_content_set(win, desktop);
}
EFL_MAIN()

View File

@ -0,0 +1,11 @@
src = files([
'homescreen.c',
])
deps = [eina, efl, elm]
executable('efl_example_homescreen', src,
dependencies : deps,
include_directories : inc,
install : true
)

View File

@ -1,7 +1,5 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Elementary.h>
#include <Efl_Ui.h>
#include "life_private.h"
@ -67,7 +65,7 @@ life_board_run(Efl_Ui_Win *win)
_life_timer = efl_add(EFL_LOOP_TIMER_CLASS, efl_main_loop_get(),
efl_loop_timer_interval_set(efl_added, 0.1));
efl_event_callback_add(_life_timer, EFL_LOOP_TIMER_EVENT_TICK, _life_tick, win);
efl_event_callback_add(_life_timer, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _life_tick, win);
}
int

View File

@ -1,7 +1,5 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Elementary.h>
#include <Efl_Ui.h>
#include "life_private.h"
@ -49,19 +47,19 @@ _life_win_key_down(void *data EINA_UNUSED, const Efl_Event *event)
ev = event->info;
win = event->object;
if (!strcmp(efl_input_key_get(ev), "space"))
if (!strcmp(efl_input_key_sym_get(ev), "space"))
life_board_pause_toggle(win);
}
static Evas_Object *
static Efl_Ui_Win *
_life_win_setup(void)
{
Efl_Ui_Win *win;
Evas_Coord w;
Evas_Coord h;
int w;
int h;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "EFL Life"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
if (!win) return NULL;
@ -76,7 +74,7 @@ _life_win_setup(void)
life_render_init(win);
life_render_refresh(win);
efl_event_callback_add(win, EFL_GFX_ENTITY_EVENT_RESIZE, _life_win_resize, NULL);
efl_event_callback_add(win, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _life_win_resize, NULL);
efl_event_callback_add(win, EFL_EVENT_POINTER_DOWN, _life_win_touch, NULL);
efl_event_callback_add(win, EFL_EVENT_KEY_DOWN, _life_win_key_down, NULL);

View File

@ -1,7 +1,6 @@
#ifndef LIFE_PRIVATE_H_
# define LIFE_PRIVATE_H_
#include <Elementary.h>
#include <Efl_Ui.h>
#define LIFE_BOARD_WIDTH 47

View File

@ -1,7 +1,5 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Elementary.h>
#include <Efl_Ui.h>
#include "life_private.h"
@ -48,7 +46,7 @@ life_render_layout(Efl_Ui_Win *win)
{
Eina_Size2D size;
double cw, ch;
Evas_Object *rect;
Efl_Canvas_Rectangle *rect;
int x, y;
size = efl_gfx_entity_size_get(win);
@ -69,7 +67,7 @@ life_render_layout(Efl_Ui_Win *win)
void
life_render_cell(Efl_Ui_Win *win EINA_UNUSED, int x, int y)
{
Evas_Object *rect;
Efl_Canvas_Rectangle *rect;
int i;
i = life_render_index_for_position(x, y);

View File

@ -1,11 +1,9 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
Efl_Ui_Text *_editor;
Efl_Ui_Textbox *_editor;
Efl_Ui_Button *_toolbar_new;
Eina_Bool _edited = EINA_FALSE;
@ -42,12 +40,12 @@ _gui_toolbar_button_add(Efl_Ui_Box *toolbar, const char *name,
button = efl_add(EFL_UI_BUTTON_CLASS, toolbar,
efl_text_set(efl_added, name),
efl_pack(toolbar, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
func, efl_added));
efl_add(EFL_UI_IMAGE_CLASS, toolbar,
efl_ui_image_icon_set(efl_added, icon_name),
efl_content_set(efl_part(button, "efl.content"), efl_added));
efl_content_set(button, efl_added));
return button;
}
@ -59,15 +57,15 @@ _gui_toolbar_setup(Efl_Ui_Box *parent)
bar = efl_add(EFL_UI_BOX_CLASS, parent,
efl_pack(parent, efl_added),
efl_gfx_size_hint_weight_set(efl_added, 1, 0),
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL));
efl_gfx_hint_weight_set(efl_added, 1, 0),
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL));
_toolbar_new = _gui_toolbar_button_add(bar, "New", "document-new", _gui_new_clicked_cb);
// spacer box
efl_add(EFL_UI_BOX_CLASS, parent,
efl_pack(bar, efl_added),
efl_gfx_size_hint_weight_set(efl_added, 10, 0));
efl_gfx_hint_weight_set(efl_added, 10, 0));
_gui_toolbar_button_add(bar, "Quit", "application-exit", _gui_quit_cb);
_gui_toolbar_refresh();
@ -80,8 +78,8 @@ _gui_toolbar_refresh(void)
}
EFL_CALLBACKS_ARRAY_DEFINE(_editor_callbacks,
{ EFL_UI_TEXT_EVENT_CHANGED, _editor_changed_cb },
{ EFL_UI_TEXT_EVENT_CHANGED_USER, _editor_changed_cb });
{ EFL_UI_TEXTBOX_EVENT_CHANGED, _editor_changed_cb },
{ EFL_TEXT_INTERACTIVE_EVENT_CHANGED_USER, _editor_changed_cb });
static void
_gui_setup()
@ -89,7 +87,7 @@ _gui_setup()
Eo *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Text Editor"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -98,17 +96,18 @@ _gui_setup()
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)));
_gui_toolbar_setup(box);
_editor = efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_font_set(efl_added, "Mono", 14),
_editor = efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_text_multiline_set(efl_added, EINA_TRUE),
efl_text_interactive_editable_set(efl_added, EINA_TRUE),
efl_ui_text_scrollable_set(efl_added, EINA_TRUE),
efl_event_callback_array_add(efl_added, _editor_callbacks(), NULL),
efl_pack(box, efl_added));
efl_ui_textbox_scrollable_set(_editor, EINA_TRUE);
efl_text_font_family_set(_editor, "Mono");
efl_text_font_size_set(_editor, 14);
}
EAPI_MAIN void

View File

@ -0,0 +1,10 @@
project(
'efl-example-calculator', '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')

View File

@ -0,0 +1,198 @@
/* Simple calculator using an Efl.Ui.Table to place the buttons
*/
using System;
public class Calculator : Efl.Csharp.Application
{
private Efl.Ui.Textbox screen; // Text widget showing current value
private int prevValue = 0; // Value introduced before an operation (first operand)
private int currValue = 0; // Value currently being introduced (second operand)
private char operation = '='; // Last operation button pressed
private bool mustOverwrite = false; // Whether next number must be appended to current input
// or overwrite it
// Quits the application
private void GUIQuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ea)
{
if (ea.Arg == false)
Efl.App.AppMain.Quit(0);
}
// Performs "operation" on "currValue" and "prevValue" and leaves result in "currValue"
private void Operate()
{
switch (operation)
{
case '+':
currValue += prevValue;
break;
case '-':
currValue = prevValue - currValue;
break;
case '*':
currValue *= prevValue;
break;
case '/':
currValue = prevValue / currValue;
break;
default:
break;
}
}
// Called every time a button is pressed
private void ButtonPressedCb(char button)
{
// If it is a number, append it to current input (or replace it)
if (button >= '0' && button <= '9')
{
if (mustOverwrite)
{
screen.Text = "";
mustOverwrite = false;
}
screen.Text = screen.Text + button.ToString();
}
else
{
switch (button)
{
case 'C':
// Clear current input
screen.Text = "0";
break;
case '+':
case '-':
case '*':
case '/':
case '=':
// If there was a pending operation, perform it
if (operation != '=')
{
Operate();
screen.Text = currValue.ToString();
}
// Store this operation
operation = button;
mustOverwrite = true;
prevValue = currValue;
break;
default:
break;
}
}
}
// Called every time the content of the screen changes
// We use it to sanitize input (remove heading zeros, for example)
// This makes more sense when the Text widget is editable, since the user
// is free to type anything.
private void ScreenChangedCb(object sender, EventArgs ea)
{
string text = "";
string str = screen.Text;
int d;
if (str == "" || str == "-")
{
text = "0";
}
else
{
try
{
d = Convert.ToInt32(str);
text = d.ToString();
currValue = d;
}
catch {}
}
if (text != str) screen.Text = text;
}
// Creates an Efl.Ui.Button and positions it in the given position inside the table
// The button text is colored with "r, g, b"
// "text" is what is drawn on the button, which might be a multi-byte unicode string.
// "command" is a single-char id for the button.
private void AddButton(Efl.Ui.Table table, string text, char command, int posx, int posy, int r, int g, int b)
{
var button = new Efl.Ui.Button(table);
table.PackTable(button, posx, posy, 1, 1);
button.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs ea) => {
ButtonPressedCb(command);
};
// Buttons can only have simple text (no font, styles or markup) but can swallow
// any other object we want.
// Therefore we create a more complex Efl.Ui.Text object and use it as content for the button.
var label = new Efl.Ui.Textbox(table);
label.Editable = false;
label.TextHorizontalAlign = 0.5;
label.TextVerticalAlign = 0.5;
label.Color = (r, g, b, 255);
label.Text = text;
label.FontFamily = "Sans";
label.FontSize = 36;
button.Content = label;
}
// Called on start up. We use it to create the UI.
protected override void OnInitialize(string[] args)
{
// The window
var win = new Efl.Ui.Win(Efl.App.AppMain);
win.Text = "EFL Calculator";
win.Autohide = true;
win.VisibilityChangedEvent += GUIQuitCb;
// The table is the main layout
var table = new Efl.Ui.Table(win);
win.Content = table;
table.TableSize = (4, 5);
table.HintSizeMin = new Eina.Size2D(300, 400);
// Create all buttons using the AddButton helper
AddButton(table, "1", '1', 0, 3, 255, 255, 255);
AddButton(table, "2", '2', 1, 3, 255, 255, 255);
AddButton(table, "3", '3', 2, 3, 255, 255, 255);
AddButton(table, "4", '4', 0, 2, 255, 255, 255);
AddButton(table, "5", '5', 1, 2, 255, 255, 255);
AddButton(table, "6", '6', 2, 2, 255, 255, 255);
AddButton(table, "7", '7', 0, 1, 255, 255, 255);
AddButton(table, "8", '8', 1, 1, 255, 255, 255);
AddButton(table, "9", '9', 2, 1, 255, 255, 255);
AddButton(table, "0", '0', 1, 4, 255, 255, 255);
AddButton(table, "+", '+', 3, 1, 128, 128, 128);
AddButton(table, "", '-', 3, 2, 128, 128, 128);
AddButton(table, "×", '*', 3, 3, 128, 128, 128);
AddButton(table, "÷", '/', 3, 4, 128, 128, 128);
AddButton(table, "=", '=', 2, 4, 128, 128, 128);
AddButton(table, "C", 'C', 0, 4, 0, 0, 0);
// Create a big Efl.Ui.Text screen to display the current input
screen = new Efl.Ui.Textbox(table);
screen.Text = "0";
screen.Multiline = false;
screen.Editable = false;
screen.SelectionAllowed = false;
screen.TextHorizontalAlign = 0.9;
screen.TextVerticalAlign = 0.5;
screen.TextEffectType = Efl.TextStyleEffectType.Glow;
screen.TextGlowColor = (128, 128, 128, 128);
screen.FontFamily = "Sans";
screen.FontSize = 48;
screen.ChangedEvent += ScreenChangedCb;
table.PackTable(screen, 0, 0, 4, 1);
}
}
public class Example
{
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var calculator = new Calculator();
calculator.Launch();
}
}

View File

@ -0,0 +1,12 @@
src = files([
'calculator.cs',
])
deps = [efl_mono]
executable('efl_example_calculator', src,
dependencies : deps,
cs_args : efl_mono_libs,
install : true
)

View File

@ -19,7 +19,7 @@ public class LifeBoard
private bool[] board;
private bool[] board1, board2;
private efl.ILoop_Timer lifeTimer = null;
private Efl.LoopTimer lifeTimer = null;
private LifeRender lifeRender = null;
private void CellOn(int x, int y)
@ -58,13 +58,11 @@ public class LifeBoard
board = board1;
}
public void Run(efl.ui.IWin win)
public void Run(Efl.Ui.Win win)
{
lifeTimer = new efl.Loop_Timer(win, (efl.ILoop_Timer etimer) => {
etimer.SetInterval(0.1);
});
lifeTimer = new Efl.LoopTimer(win, 0.1);
lifeTimer.TickEvt += (object sender, EventArgs ev) => {
lifeTimer.TimerTickEvent += (object sender, EventArgs ev) => {
Nextgen();
if (this.lifeRender != null)
this.lifeRender.Refresh(win);
@ -141,12 +139,11 @@ public class LifeBoard
board = work;
}
public void TogglePause(efl.ui.IWin win)
public void TogglePause(Efl.Ui.Win win)
{
if (lifeTimer != null)
{
lifeTimer.SetParent(null);
lifeTimer.Dispose();
lifeTimer.Del();
lifeTimer = null;
}
else

View File

@ -1,26 +1,27 @@
using System;
public class LifeWindow
public class LifeWindow : Efl.Csharp.Application
{
private LifeBoard lifeBoard;
private LifeRender lifeRender;
private Efl.Ui.Win win;
void ResizeEvt(object sender, EventArgs ev)
void ResizeEvent(object sender, EventArgs ev)
{
lifeRender.RenderLayout((efl.ui.IWin)sender);
lifeRender.RenderLayout((Efl.Ui.Win)sender);
}
void QuitEvt(object sender, EventArgs ev)
void QuitEvent(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
{
// quit the mainloop
efl.ui.Config.Exit();
if (ev.Arg == false)
Efl.App.AppMain.Quit(0);
}
void TouchEvt(object sender, efl.input.Interface.PointerDownEvt_Args ev)
void TouchEvent(object sender, Efl.Input.InterfacePointerDownEventArgs ev)
{
int cellx, celly;
efl.ui.IWin win = (efl.ui.IWin)sender;
var position = ev.arg.GetPosition();
var position = ev.Arg.Position;
lifeRender.CellForCoords(win, position, out cellx, out celly);
int i = LifeBoard.IndexForPosition(cellx, celly);
@ -28,53 +29,58 @@ public class LifeWindow
lifeRender.RenderCell(win, cellx, celly);
}
void KeyDownEvt(object sender, efl.input.Interface.KeyDownEvt_Args ev)
void KeyDownEvent(object sender, Efl.Input.InterfaceKeyDownEventArgs ev)
{
efl.ui.IWin win = (efl.ui.IWin)sender;
if (ev.arg.GetKey() == "space")
if (ev.Arg.KeySym == "space")
lifeBoard.TogglePause(win);
}
public LifeWindow()
protected override void OnInitialize(string[] args)
{
efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
ewin.SetWinType(efl.ui.Win_Type.Basic);
ewin.SetText("EFL Life");
ewin.SetAutohide(true);
});
win = new Efl.Ui.Win(parent: null, winName: "Life", winType: Efl.Ui.WinType.Basic);
win.Text = "EFL Life";
win.Autohide = true;
// when the user clicks "close" on a window there is a request to hide
win.HideEvt += QuitEvt;
eina.Size2D sz;
sz.W = (int)(10 * LifeBoard.Width * win.GetScale());
sz.H = (int)(10 * LifeBoard.Height * win.GetScale());
((Efl.Gfx.IEntity)win).VisibilityChangedEvent += QuitEvent;
lifeBoard = new LifeBoard();
lifeRender = new LifeRender(win, lifeBoard);
lifeRender.Refresh(win);
win.ResizeEvt += ResizeEvt;
win.PointerDownEvt += TouchEvt;
win.KeyDownEvt += KeyDownEvt;
((Efl.Gfx.IEntity)win).SizeChangedEvent += ResizeEvent;
((Efl.Input.IInterface)win).PointerDownEvent += TouchEvent;
((Efl.Input.IInterface)win).KeyDownEvent += KeyDownEvent;
win.SetSize(sz);
win.Size = new Eina.Size2D((int)(10 * LifeBoard.Width * win.Scale),
(int)(10 * LifeBoard.Height * win.Scale));
lifeBoard.Run(win);
}
protected override void OnPause() {
if (win != null) {
lifeBoard.TogglePause(win);
}
}
protected override void OnResume() {
if (win != null) {
lifeBoard.TogglePause(win);
}
}
protected override void OnTerminate() {
Console.WriteLine("Goodbye.");
}
}
public class Example
{
public static void Main()
{
efl.All.Init(efl.Components.Ui);
var lifeWin = new LifeWindow();
// start the mainloop
efl.ui.Config.Run();
efl.All.Shutdown();
lifeWin.Launch();
}
}

View File

@ -2,34 +2,34 @@ using System;
public class LifeRender
{
private efl.canvas.IRectangle[] lifeCells;
private Efl.Canvas.Rectangle[] lifeCells;
private LifeBoard lifeBoard;
public LifeRender(efl.ui.IWin win, LifeBoard board)
public LifeRender(Efl.Ui.Win win, LifeBoard board)
{
lifeBoard = board;
lifeBoard.SetRender(this);
lifeCells = new efl.canvas.Rectangle[LifeBoard.Height * LifeBoard.Width];
lifeCells = new Efl.Canvas.Rectangle[LifeBoard.Height * LifeBoard.Width];
for (int y = 0; y < LifeBoard.Height; ++y)
for (int x = 0; x < LifeBoard.Width; ++x)
lifeCells[LifeBoard.IndexForPosition(x, y)] = new efl.canvas.Rectangle(win);
lifeCells[LifeBoard.IndexForPosition(x, y)] = new Efl.Canvas.Rectangle(win);
RenderLayout(win);
}
public void CellForCoords(efl.ui.IWin win, eina.Position2D coord, out int x, out int y)
public void CellForCoords(Efl.Ui.Win win, Eina.Position2D coord, out int x, out int y)
{
eina.Size2D size = win.GetSize();
Eina.Size2D size = win.Size;
x = coord.X * LifeBoard.Width / size.W;
y = coord.Y * LifeBoard.Height / size.H;
}
public void RenderLayout(efl.ui.IWin win)
public void RenderLayout(Efl.Ui.Win win)
{
eina.Size2D size = win.GetSize();
Eina.Size2D size = win.Size;
double cw = (double) size.W / LifeBoard.Width;
double ch = (double) size.H / LifeBoard.Height;
@ -39,30 +39,24 @@ public class LifeRender
var rect = lifeCells[LifeBoard.IndexForPosition(x, y)];
// the little +1 here will avoid tearing as we layout non-multiple sizes
eina.Size2D sz;
sz.W = (int)(cw + 1);
sz.H = (int)(ch + 1);
rect.SetSize(sz);
rect.Size = new Eina.Size2D((int)(cw + 1), (int)(ch + 1));
eina.Position2D pos;
pos.X = (int)(x * cw);
pos.Y = (int)(y * ch);
rect.SetPosition(pos);
rect.Position = new Eina.Position2D((int)(x * cw), (int)(y * ch));
}
}
public void RenderCell(efl.ui.IWin win, int x, int y)
public void RenderCell(Efl.Ui.Win win, int x, int y)
{
int i = LifeBoard.IndexForPosition(x, y);
var rect = lifeCells[i];
if (lifeBoard.Cells[i])
rect.SetColor(0, 0, 0, 255);
rect.Color = (0, 0, 0, 255);
else
rect.SetColor(255, 255, 255, 255);
rect.Color = (255, 255, 255, 255);
}
public void Refresh(efl.ui.IWin win)
public void Refresh(Efl.Ui.Win win)
{
for (int y = 0; y < LifeBoard.Height; ++y)
for (int x = 0; x < LifeBoard.Width; ++x)

View File

@ -0,0 +1,10 @@
project(
'efl-example-mvvm', 'cs',
version : '0.0.1',
meson_version : '>= 0.49.0')
efl_mono = dependency('efl-mono', version : '>=1.23.99')
efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
subdir('src')

View File

@ -0,0 +1,12 @@
src = files([
'mvvm_basic.cs',
])
deps = [efl_mono]
executable('efl_example_mvvm', src,
dependencies : deps,
cs_args : efl_mono_libs,
install : true
)

View File

@ -0,0 +1,69 @@
using System;
class WeatherStation
{
public String Nick { get; set; }
public float Temperature { get; set; }
public static Efl.UserModel<WeatherStation> CreateModel(Efl.Loop loop)
{
Efl.UserModel<WeatherStation> stations = new Efl.UserModel<WeatherStation>(loop);
stations.Add (new WeatherStation{ Nick="FLN", Temperature=20 });
stations.Add (new WeatherStation{ Nick="SAO", Temperature=25 });
stations.Add (new WeatherStation{ Nick="RIO", Temperature=35 });
stations.Add (new WeatherStation{ Nick="BSB", Temperature=30 });
return stations;
}
}
class WeatherServer
{
}
class Application : Efl.Csharp.Application
{
private Efl.Ui.Win win;
protected override void OnInitialize(string[] args)
{
win = new Efl.Ui.Win(parent: null, winName: "MVVM Example",
winType: Efl.Ui.WinType.Basic);
win.Text = "EFL Life";
win.Autohide = true;
win.VisibilityChangedEvent += QuitEvt;
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(win);
// Text property is temporarily excluded from the extension method generation
// due to conflicts with the text classes.
factory.BindProperty("text", "Nick");
var model = WeatherStation.CreateModel(Efl.App.AppMain);
var manager = new Efl.Ui.PositionManager.List(win);
var list = new Efl.Ui.CollectionView(win);
list.PositionManager = manager;
list.Model = model;
list.Factory = factory;
win.SetContent(list);
win.Size = new Eina.Size2D(640, 480);
win.Visible = true;
}
void QuitEvt(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
{
if (ev.Arg == false)
{
Efl.App.AppMain.Quit(0);
}
}
public static void Main()
{
var app = new Application();
app.Launch();
}
}

View File

@ -17,35 +17,36 @@
using System;
public class TextEditor
public class TextEditor : Efl.Csharp.Application
{
private efl.ui.IWin win; // The main window
private efl.ui.IText editorTextBox; // The main text entry
private efl.ui.IButton toolbarButtonNew; // The "New" button in the toolbar
private efl.ui.IButton toolbarButtonSave; // The "Save" button in the toolbar
private efl.ui.IButton toolbarButtonLoad; // The "Load" button in the toolbar
private Efl.Ui.Win win; // The main window
private Efl.Ui.Textbox editorTextBox; // The main text entry
private Efl.Ui.Button toolbarButtonNew; // The "New" button in the toolbar
private Efl.Ui.Button toolbarButtonSave; // The "Save" button in the toolbar
private Efl.Ui.Button toolbarButtonLoad; // The "Load" button in the toolbar
private bool edited = false; // Document was edited since last save
private bool edited = false; // Document was edited since last save
// File to load and save is fixed since we do not use a file selection dialog
private readonly string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(),
"texteditor_example.txt");
// Quits the application
private void GUIQuitCb(object sender, EventArgs ea)
private void GUIQuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ea)
{
efl.ui.Config.Exit();
if (ea.Arg == false)
Efl.App.AppMain.Quit(0);
}
// Enables or disables buttons on the toolbar as required
private void GUIToolbarRefresh()
{
// "New" is enabled if there is text in the text box
toolbarButtonNew.SetDisabled(string.IsNullOrEmpty(editorTextBox.GetText()));
toolbarButtonNew.Disabled = string.IsNullOrEmpty(editorTextBox.Text);
// "Save" is enabled if the text has been modified since last save or load
toolbarButtonSave.SetDisabled(!edited);
toolbarButtonSave.Disabled = !edited;
// "Load" is enabled if there is a file to load
toolbarButtonLoad.SetDisabled(!System.IO.File.Exists(filename));
toolbarButtonLoad.Disabled = !System.IO.File.Exists(filename);
}
// Called when the text in the editor has changed
@ -58,65 +59,61 @@ public class TextEditor
// Shows a modal message popup with an "OK" button
private void ShowMessage(string message)
{
new efl.ui.Popup_Alert_Text (win, (efl.ui.IPopup_Alert_Text epopup) => {
epopup.SetText(message);
epopup.SetExpandable(new eina.Size2D(200,200));
epopup.SetButton(efl.ui.Popup_Alert_Button.Positive, "OK", null);
epopup.ButtonClickedEvt +=
(object sender, efl.ui.Popup_Alert.ButtonClickedEvt_Args ea) => {
// Dismiss popup when the button is clicked
((efl.ui.IPopup_Alert_Text)sender).SetParent(null);
};
});
var popup = new Efl.Ui.AlertPopup (win);
popup.ScrollableText = message;
popup.HintSizeMax = new Eina.Size2D(200, 200);
popup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null);
popup.ButtonClickedEvent +=
(object sender, Efl.Ui.AlertPopupButtonClickedEventArgs ea) => {
// Dismiss popup when the button is clicked
((Efl.Ui.AlertPopup)sender).Del();
};
}
// Adds a button to the toolbar, with the given text, icon and click event handler
private efl.ui.IButton GUIToolbarButtonAdd(efl.ui.IBox toolbar, string name,
string iconName, EventHandler func)
private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name,
string iconName, EventHandler<Efl.Input.ClickableClickedEventArgs> func)
{
return new efl.ui.Button(toolbar, (efl.ui.IButton ebutton) => {
ebutton.SetText(name);
ebutton.ClickedEvt += func;
ebutton.SetHintWeight(0, 1);
toolbar.DoPack(ebutton);
var button = new Efl.Ui.Button(toolbar);
button.Text = name;
button.ClickedEvent += func;
button.HintWeight = (0, 1);
// Set the content of the button
efl.Content.static_cast(ebutton.GetPart("efl.content")).SetContent(
// Which is an image
new efl.ui.Image(toolbar, (efl.ui.IImage eimage) => {
eimage.SetIcon(iconName);
})
);
});
// Set the content of the button, which is an image
var image = new Efl.Ui.Image(toolbar);
image.SetIcon(iconName);
button.SetContent(image);
toolbar.Pack(button);
return button;
}
// Creates a new toolbar, with all its buttons
private void GUIToolbarSetup(efl.ui.IBox parent)
private void GUIToolbarSetup(Efl.Ui.Box parent)
{
// Create a horizontal box container for the buttons
efl.ui.IBox bar = new efl.ui.Box(parent, (efl.ui.IBox ebox) => {
// 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
// space will be given to the other object in the parent container.
ebox.SetHintWeight(1, 0);
ebox.SetDirection(efl.ui.Dir.Horizontal);
parent.DoPack(ebox);
});
var bar = new Efl.Ui.Box(parent);
// 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
// space will be given to the other object in the parent container.
bar.HintWeight = (1, 0);
bar.Orientation = Efl.Ui.LayoutOrientation.Horizontal;
parent.Pack(bar);
// "New" button
toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new",
(object sender, EventArgs ea) => {
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
// When this button is clicked, remove content and refresh toolbar
editorTextBox.SetText("");
editorTextBox.Text = "";
GUIToolbarRefresh();
});
// "Save" button
toolbarButtonSave = GUIToolbarButtonAdd(bar, "Save", "document-save",
(object sender, EventArgs ea) => {
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
// When this button is clicked, try to save content and refresh toolbar
try {
System.IO.File.WriteAllText(filename, editorTextBox.GetText());
System.IO.File.WriteAllText(filename, editorTextBox.Text);
edited = false;
GUIToolbarRefresh();
ShowMessage("Saved!");
@ -128,10 +125,10 @@ public class TextEditor
// "Load" button
toolbarButtonLoad = GUIToolbarButtonAdd(bar, "Load", "document-open",
(object sender, EventArgs ea) => {
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
// When this button is clicked, try to load content and refresh toolbar
try {
editorTextBox.SetText(System.IO.File.ReadAllText(filename));
editorTextBox.Text = System.IO.File.ReadAllText(filename);
edited = false;
GUIToolbarRefresh();
ShowMessage("Loaded!");
@ -146,52 +143,44 @@ public class TextEditor
// a horizontal weight of 0).
// As a result, it pushes the "Quit" button to the right margin and
// the rest to the left.
efl.ui.IBox box = new efl.ui.Box(parent);
bar.DoPack(box);
Efl.Ui.Box box = new Efl.Ui.Box(parent);
bar.Pack(box);
// "Quit" button
GUIToolbarButtonAdd(bar, "Quit", "application-exit", GUIQuitCb);
GUIToolbarButtonAdd(bar, "Quit", "application-exit", (object sender, Efl.Input.ClickableClickedEventArgs e) => { Efl.Ui.Config.Exit(); } );
}
// Builds the user interface for the text editor
public TextEditor()
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => {
ewin.SetText("Text Editor");
ewin.SetAutohide(true);
ewin.HideEvt += GUIQuitCb;
});
win = new Efl.Ui.Win(parent: Efl.App.AppMain);
win.Text = "Text Editor";
win.Autohide = true;
win.VisibilityChangedEvent += GUIQuitCb;
// Create a vertical box container
efl.ui.IBox box = new efl.ui.Box(win);
Efl.Ui.Box box = new Efl.Ui.Box(win);
win.SetContent(box);
// Create the toolbar and add it to the box
GUIToolbarSetup(box);
// Create the main text entry
editorTextBox = new efl.ui.Text(box, (efl.ui.IText etext) => {
etext.SetFont("Mono", 14);
etext.SetMultiline(true);
etext.SetEditable(true);
etext.SetScrollable(true);
etext.SetHintMin(new eina.Size2D(360, 240));
etext.ChangedEvt += EditorChangedCb;
etext.ChangedUserEvt += EditorChangedCb;
box.DoPack(etext);
});
editorTextBox = new Efl.Ui.Textbox(box);
editorTextBox.FontFamily = "Mono";
editorTextBox.FontSize = 14;
editorTextBox.Multiline = true;
editorTextBox.Editable = true;
editorTextBox.Scrollable = true;
editorTextBox.HintSizeMin = new Eina.Size2D(360, 240);
editorTextBox.ChangedEvent += EditorChangedCb;
editorTextBox.ChangedUserEvent += EditorChangedCb;
box.Pack(editorTextBox);
// Initial refresh of the toolbar buttons
GUIToolbarRefresh();
}
// This method won't return until the application quits
public void Run()
{
// Start the EFL main loop
efl.ui.Config.Run();
}
}
public class Example
@ -201,14 +190,8 @@ public class Example
#endif
public static void Main()
{
// Initialize EFL and all UI components
efl.All.Init(efl.Components.Ui);
var textEditor = new TextEditor();
textEditor.Run();
// Shutdown EFL
efl.All.Shutdown();
TextEditor editor = new TextEditor();
editor.Launch();
}
}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -69,7 +68,7 @@ _events_freeze(Efl_Loop *mainloop)
efl_add(EFL_LOOP_TIMER_CLASS, mainloop,
efl_name_set(efl_added, "timer2"),
efl_loop_timer_interval_set(efl_added, .1),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _freezethaw_cb, mainloop));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _freezethaw_cb, mainloop));
}
static void
@ -90,7 +89,7 @@ _timer_cb(void *data EINA_UNUSED, const Efl_Event *event)
}
EFL_CALLBACKS_ARRAY_DEFINE(_callback_array,
{ EFL_LOOP_TIMER_EVENT_TICK, _timer_cb },
{ EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_cb },
{ EFL_EVENT_DEL, _del_obj_cb })
static void

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -60,7 +59,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 0.0005),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_cb, NULL));
}
EFL_MAIN()

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -22,7 +21,7 @@ _io_write(const char *filename)
Efl_Io_File *file;
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
efl_file_set(efl_added, filename), // mandatory
efl_io_file_flags_set(efl_added, O_WRONLY | O_CREAT), // write and create - default is read
efl_io_file_mode_set(efl_added, 0644), // neccessary if we use O_CREAT
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
@ -51,7 +50,7 @@ _io_read(const char *filename)
Efl_Io_File *file;
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename, NULL), // mandatory
efl_file_set(efl_added, filename), // mandatory
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -64,7 +63,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 30),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_cb, NULL));
}
EFL_MAIN()

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -103,7 +102,7 @@ _test1_simple_future(Efl_Loop *loop)
// simulate a delayed promise resolve.
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 1),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK,
_test1_resolve, promise));
}
@ -154,7 +153,7 @@ _test2_failed_future(Efl_Loop *loop)
// simulate a delayed promise rejection.
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 1),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK,
_test2_reject, promise));
}
@ -278,7 +277,7 @@ _test4_chained_future(Efl_Loop *loop)
// simulate a delayed promise resolve.
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 1),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK,
_test4_resolve, promise));
}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -197,7 +196,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
/* The TCP client to use to send/receive network data */
_dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, loop,
efl_name_set(efl_added, "dialer"),
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL));
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_DIALER_CONNECTED, _dialer_connected, NULL));
if (!_dialer)
{
fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n");

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -138,7 +137,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
/* The TCP client to use to send/receive network data */
_dialer = efl_add(EFL_NET_DIALER_TCP_CLASS, loop,
efl_name_set(efl_added, "dialer"),
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL));
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_DIALER_CONNECTED, _dialer_connected, NULL));
if (!_dialer)
{
fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n");

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -134,7 +133,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
// Wait for 10 seconds before exiting this example
efl_add(EFL_LOOP_TIMER_CLASS, loop,
efl_loop_timer_interval_set(efl_added, 10.0),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK,
_quit_cb, NULL));
}
EFL_MAIN()

View File

@ -1,7 +1,5 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
@ -31,7 +29,7 @@ _gui_setup()
Eo *win, *box, *hbox, *about;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_event_callback_add(efl_added,
EFL_UI_WIN_EVENT_DELETE_REQUEST,
@ -40,9 +38,9 @@ _gui_setup()
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_add(EFL_UI_TEXT_CLASS, box,
efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_text_set(efl_added, "Label"),
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
@ -50,8 +48,8 @@ _gui_setup()
efl_pack(box, efl_added));
hbox = efl_add(EFL_UI_BOX_CLASS, box,
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
efl_gfx_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added));
about = efl_add(EFL_UI_BUTTON_CLASS, hbox,
@ -59,7 +57,7 @@ _gui_setup()
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_about_clicked_cb, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, hbox,
@ -67,10 +65,10 @@ _gui_setup()
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about);
efl_ui_focus_util_focus(about);
}
EAPI_MAIN void

View File

@ -1,12 +1,10 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
/*
* Efl.UI container exmaples.
* Efl.UI container examples.
*
* Load and pack a selection of containers.
* Each has it's own unique layout and methods which are demonstrated below.
@ -17,7 +15,6 @@
* TODO - still ELM Conformant
* TODO - still ELM Mapbuf
* TODO - still ELM Scroller
* TODO - still ELM Table
*/
// quit the app, called if the user clicks the Quit button or the window is deleted
@ -37,7 +34,7 @@ _ui_table_setup(Efl_Ui_Win *win)
table = efl_add(EFL_UI_TABLE_CLASS, win);
efl_pack_table_columns_set(table, 2);
efl_pack_table_direction_set(table, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN);
efl_ui_layout_orientation_set(table, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Long Button"),
@ -62,7 +59,7 @@ _ui_boxes_setup(Efl_Ui_Win *win)
int i;
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_pack_padding_set(efl_added, 5, 0, EINA_TRUE));
efl_gfx_arrangement_content_padding_set(efl_added, 5, 0));
for (i = 1; i <= 4; i++)
{
@ -71,7 +68,7 @@ _ui_boxes_setup(Efl_Ui_Win *win)
efl_pack(box, efl_added));
if (i == 2)
efl_gfx_size_hint_max_set(button, EINA_SIZE2D(100, 50));
efl_gfx_hint_size_max_set(button, EINA_SIZE2D(100, 50));
}
return box;
@ -90,15 +87,15 @@ _ui_panes_setup(Efl_Ui_Win *win)
horiz_split = efl_add(EFL_UI_PANES_CLASS, win,
efl_content_set(efl_part(split, "second"), efl_added),
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
efl_ui_panes_split_ratio_set(efl_added, 0.85));
efl_content_set(efl_part(horiz_split, "first"), _ui_table_setup(win));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Quit"),
efl_gfx_size_hint_max_set(efl_added, EINA_SIZE2D(150, 30)),
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(150, 30)),
efl_content_set(efl_part(horiz_split, "second"), efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_quit_cb, efl_added));
}
@ -108,7 +105,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
Eo *win;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -28,7 +27,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
Efl_Ui_Win *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Size Control"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -45,12 +44,12 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Small"),
efl_pack_end(box, efl_added),
efl_gfx_size_hint_max_set(efl_added, EINA_SIZE2D(50, 50)));
efl_gfx_hint_size_max_set(efl_added, EINA_SIZE2D(50, 50)));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Big Button"),
efl_pack_end(box, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)));
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)));
efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));
}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -34,7 +33,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
Efl_Ui_Win *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Translations"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -45,18 +44,18 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
efl_content_set(win, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_ui_translatable_text_set(efl_added, "Translations", _TEXT_DOMAIN),
efl_ui_l10n_text_set(efl_added, "Translations", _TEXT_DOMAIN),
efl_pack_end(box, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_ui_translatable_text_set(efl_added, "Help", _TEXT_DOMAIN),
efl_ui_l10n_text_set(efl_added, "Help", _TEXT_DOMAIN),
efl_pack_end(box, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN),
efl_ui_l10n_text_set(efl_added, "Quit", _TEXT_DOMAIN),
efl_pack_end(box, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_quit_cb, efl_added));
efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));

View File

@ -7,12 +7,55 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
// Polling callback
private static void PollCb(object sender, EventArgs e)
{
Console.WriteLine(" Poll from {0}", ((efl.IObject)sender).GetName());
Console.WriteLine(" Poll from {0}", ((Efl.Object)sender).Name);
}
protected override void OnInitialize(string[] args)
{
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
mainloop.Name = "Mainloop";
// This event gets triggered continuously
mainloop.PollHighEvent += PollCb;
// This timer will control events fired by the main loop
var timer = new Efl.LoopTimer(mainloop, 0.1);
timer.Name = "Timer";
// To count number of timer triggers
int tick_count = 0;
timer.TimerTickEvent += (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).Name);
tick_count++;
};
Console.WriteLine("Waiting for Timer to call back...");
}
protected override void OnTerminate()
{
Console.WriteLine("Application is over");
}
#if WIN32
@ -20,54 +63,8 @@ public class Example
#endif
public static void Main()
{
// Initialize EFL and all UI components
efl.All.Init();
// Retrieve the application's main loop
var mainloop = efl.App.GetLoopMain();
mainloop.SetName("Mainloop");
// This event gets triggered continuously
mainloop.PollHighEvt += PollCb;
// This timer will control events fired by the main loop
new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
etimer.SetName("Timer");
// Trigger every 100ms
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.IObject)sender).GetName());
tick_count++;
};
});
Console.WriteLine("Waiting for Timer to call back...");
// Start the EFL main loop (and the experiment)
mainloop.Begin();
// Shutdown EFL
efl.All.Shutdown();
Console.WriteLine("Application is over");
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -9,44 +9,38 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
protected override void OnInitialize(string[] args)
{
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
// Register to all Idle events
mainloop.IdleEnterEvent += (object sender, EventArgs e) => {
Console.WriteLine("IDLE ENTER: Entering idle state.");
};
mainloop.IdleEvent += (object sender, EventArgs e) => {
Console.WriteLine("IDLE: Executing idler callback while in idle state.");
};
mainloop.IdleExitEvent += (object sender, EventArgs e) => {
Console.WriteLine("IDLE EXIT: Leaving idle state.");
};
// Use a timer to exit the application
var timer = new Efl.LoopTimer(mainloop, 0.02);
timer.TimerTickEvent += (object sender, EventArgs e) => {
Console.WriteLine("TIMER: timer callback called, exiting.");
mainloop.Quit(0);
};
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
// Initialize EFL and all UI components
efl.All.Init();
// Retrieve the application's main loop
var mainloop = efl.App.GetLoopMain();
// Register to all Idle events
mainloop.IdleEnterEvt += (object sender, EventArgs e) => {
Console.WriteLine("IDLE ENTER: Entering idle state.");
};
mainloop.IdleEvt += (object sender, EventArgs e) => {
Console.WriteLine("IDLE: Executing idler callback while in idle state.");
};
mainloop.IdleExitEvt += (object sender, EventArgs e) => {
Console.WriteLine("IDLE EXIT: Leaving idle state.");
};
// Use a timer to exit the application
new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
// Trigger after 10ms
etimer.SetInterval(0.01);
etimer.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)
mainloop.Begin();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -8,44 +8,38 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
protected override void OnInitialize(string[] args)
{
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
// Register to all Poll events
mainloop.PollLowEvent += (object sender, EventArgs e) => {
Console.Write("L");
};
mainloop.PollMediumEvent += (object sender, EventArgs e) => {
Console.Write("M");
};
mainloop.PollHighEvent += (object sender, EventArgs e) => {
Console.Write(".");
};
// Use a timer to exit the application
var timer = new Efl.LoopTimer(mainloop, 30);
timer.TimerTickEvent += (object sender, EventArgs e) => {
Console.WriteLine("\nTIMER: timer callback called, exiting.");
mainloop.Quit(0);
};
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
// Initialize EFL and all UI components
efl.All.Init();
// Retrieve the application's main loop
var mainloop = efl.App.GetLoopMain();
// Register to all Poll events
mainloop.PollLowEvt += (object sender, EventArgs e) => {
Console.Write("L");
};
mainloop.PollMediumEvt += (object sender, EventArgs e) => {
Console.Write("M");
};
mainloop.PollHighEvt += (object sender, EventArgs e) => {
Console.Write(".");
};
// Use a timer to exit the application
new efl.Loop_Timer(mainloop, (efl.ILoop_Timer etimer) => {
// Trigger after 30s
etimer.SetInterval(30);
etimer.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)
mainloop.Begin();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,18 +1,18 @@
/*
* Eina Array examples.
* Eina.Array examples.
*
* These examples demonstrate how to work with eina_array data and methods.
* We use a simple array of strings to initialise our eina_array before
* These examples demonstrate how to work with Eina.Array data and methods.
* We use a simple array of strings to initialise our Eina.Array before
* performing various mutations and printing the results.
*/
using System;
public class Example
public class Example : Efl.Csharp.Application
{
static eina.Array<string> CreateArray()
static Eina.Array<string> CreateArray()
{
// some content to populate our array
// Some content to populate our array
string[] names =
{
"helo", "hera", "starbuck", "kat", "boomer",
@ -21,8 +21,8 @@ public class Example
"skulls", "bulldog", "flat top", "hammerhead", "gonzo"
};
// set up an array with a growth step to give a little headroom
var array = new eina.Array<string>(25u);
// Set up an array with a growth step to give a little headroom
var array = new Eina.Array<string>(25u);
foreach (string name in names)
array.Push(name);
@ -32,44 +32,51 @@ public class Example
static bool ItemRemoveCb(string name)
{
// let's keep any strings that are no more than 7 characters long
// Let's keep any strings that are no more than 7 characters long
if (name.Length <= 7)
return false;
return true;
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
var array = CreateArray();
// show the contents of our array
Console.WriteLine("Array count: {0}", array.Count());
// Show the contents of our array
Console.WriteLine("Array count: {0}", array.Count);
Console.WriteLine("Array contents:");
foreach(string name in array)
{
// content is strings so we simply print the data
// Content is strings so we simply print the data
Console.WriteLine(" {0}", name);
}
// access a specific item in the array
// Access a specific item in the array
Console.WriteLine("Top gun: {0}", array[2]);
// update a single item in the array
// Update a single item in the array
array[17] = "flattop";
// update the array removing items that match the ItemRemoveCb criteria
// Update the array removing items that match the ItemRemoveCb criteria
// array.RemoveAll(ItemRemoveCb); // TODO: FIXME
// print the new contents of our array
Console.WriteLine("New array count: {0}", array.Length);
// Print the new contents of our array
Console.WriteLine("New array count: {0}", array.Count);
Console.WriteLine("New array contents:");
foreach(string name in array)
Console.WriteLine(" {0}", name);
array.Dispose();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,7 +1,7 @@
/*
* Eina Hash examples.
* Eina.Hash examples.
*
* These examples demonstrate how to work with eina_hash data and methods.
* These examples demonstrate how to work with Eina.Hash data and methods.
*
* We have two main hash objects here, firstly an int keyed hash with some
* dummy content.
@ -12,12 +12,12 @@
using System;
using System.Collections.Generic;
public class Example
public class Example : Efl.Csharp.Application
{
static eina.Hash<Int32, string> CreateHash()
static Eina.Hash<Int32, string> CreateHash()
{
// let's create a simple hash with integers as keys
var hash = new eina.Hash<Int32, string>();
// Let's create a simple hash with integers as keys
var hash = new Eina.Hash<Int32, string>();
// Add initial entries to our hash
for (int i = 0; i < 10; ++i)
@ -30,13 +30,13 @@ public class Example
{
var hash = CreateHash();
// get an iterator of the keys so we can print a line per entry
// Get an iterator of the keys so we can print a line per entry
var iter = hash.Keys();
Console.WriteLine("Print contents of int hash");
foreach (int key in iter)
{
// look up the value for the key so we can print both
// Look up the value for the key so we can print both
string value = hash.Find(key);
Console.WriteLine($" Item found with id {key} has value {value}");
}
@ -46,26 +46,26 @@ public class Example
hash.Dispose();
}
// here we begin the phone book example
// Here we begin the phone book example
static void PrintPhonebookEntry(string key, string data)
{
Console.WriteLine($" Name: {key}\tNumber {data}\n");
}
static void PrintPhonebook(eina.Hash<string, string> book)
static void PrintPhonebook(Eina.Hash<string, string> book)
{
int count = book.Population();
Console.WriteLine($"Complete phone book ({count}):");
// as an enumerator, iterate over the key and value for each entry
// As an enumerator, iterate over the key and value for each entry
foreach (KeyValuePair<string, string> kvp in book)
PrintPhonebookEntry(kvp.Key, kvp.Value);
Console.WriteLine("");
}
static eina.Hash<string, string> CreatePhonebook()
static Eina.Hash<string, string> CreatePhonebook()
{
string[] names =
{
@ -78,8 +78,8 @@ public class Example
"+23 45 678-91012", "+34 56 789-10123"
};
// create hash of strings to strings
var hash = new eina.Hash<string, string>();
// Create hash of strings to strings
var hash = new Eina.Hash<string, string>();
// Add initial entries to our hash
for (int i = 0; i < 4; ++i)
@ -117,13 +117,20 @@ public class Example
phone_book.Dispose();
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
HashDemo();
PhonebookDemo();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,18 +1,18 @@
/*
* Eina Iterator examples.
* Eina.Iterator examples.
*
* These examples demonstrate how to work with eina_iterator methods.
* Both an eina_list and an eina_array are created and an iterator obtained
* These examples demonstrate how to work with Eina.Iterator methods.
* Both an Eina.List and an Eina.Array are created and an iterator obtained
* for both. You can see how we can use iterators irrespective of the source
* and also that there are different ways to work with iterating content.
*/
using System;
public class Example
public class Example : Efl.Csharp.Application
{
static void PrintIterator(eina.Iterator<string> it)
static void PrintIterator(Eina.Iterator<string> it)
{
Console.WriteLine("--iterator start--");
foreach(string s in it)
@ -20,7 +20,7 @@ public class Example
Console.WriteLine("-- iterator end --");
}
static eina.Array<string> CreateArray()
static Eina.Array<string> CreateArray()
{
string[] strings =
{
@ -30,7 +30,7 @@ public class Example
"boomer"
};
var array = new eina.Array<string>(4u);
var array = new Eina.Array<string>(4u);
foreach (string s in strings)
array.Push(s);
@ -38,7 +38,7 @@ public class Example
return array;
}
static eina.List<string> CreateList()
static Eina.List<string> CreateList()
{
string[] more_strings = {
"sentence strings",
@ -47,7 +47,7 @@ public class Example
"then grab your gun and bring the cat in"
};
var list = new eina.List<string>();
var list = new Eina.List<string>();
foreach (string s in more_strings)
list.Append(s);
@ -55,24 +55,31 @@ public class Example
return list;
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
// create an eina.Array and iterate through it's contents
// Create an Eina.Array and iterate through its contents
var array = CreateArray();
var it = array.GetIterator();
PrintIterator(it);
it.Dispose();
array.Dispose();
// perform the same iteration with an eina.List
// Perform the same iteration with an Eina.List
var list = CreateList();
it = list.GetIterator();
PrintIterator(it);
it.Dispose();
list.Dispose();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,8 +1,8 @@
/*
* Eina List examples.
* Eina.List examples.
*
* These examples demonstrate how to work with eina_list data and methods.
* These examples demonstrate how to work with Eina.List data and methods.
* We create a simple list of names by appending strings to an empty list
* and then run various mutations and print each result.
*/
@ -10,11 +10,11 @@
using System;
using System.Linq;
public class Example
public class Example : Efl.Csharp.Application
{
static eina.List<string> CreateList()
static Eina.List<string> CreateList()
{
var list = new eina.List<string>();
var list = new Eina.List<string>();
list.Append("Adama");
list.Append("Baltar");
@ -23,19 +23,17 @@ public class Example
return list;
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
var list = CreateList();
// print our list with a simple foreach
// Print our list with a simple foreach
Console.WriteLine("List size: {0}", list.Count());
Console.WriteLine("List content:");
foreach(string item in list)
Console.WriteLine(" {0}", item);
// insert some more elements
// Insert some more elements
list.Prepend("Cain");
// list.PrependRelative("Tigh", "Baltar"); // TODO: missing
@ -43,7 +41,7 @@ public class Example
foreach(string item in list)
Console.WriteLine(" {0}", item);
// promote an item to the top of the list
// Promote an item to the top of the list
// TODO: implement ?
// list.PromoteList(list.NthList(1));
// list.Remove("Cain");
@ -52,20 +50,26 @@ public class Example
// foreach(string item in list)
// Console.WriteLine(" {0}", item);
// we can sort the list with any callback
// We can sort the list with any callback
// list.Sort((string strA, string strB) => { return strA.Compare(strB); }); // TODO: FIXME custom sort
list.Sort();
Console.WriteLine("List content sorted:");
foreach(string item in list)
Console.WriteLine(" {0}", item);
// and foreach can be in reverse too
// And foreach can be in reverse too
Console.WriteLine("List content reverse sorted:");
foreach(string item in list.Reverse())
Console.WriteLine(" {0}", item);
list.Dispose();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,6 +1,6 @@
/*
* Efl Core Log examples.
* Eina.Log examples.
*
* This demo shows how to log at various levels and to change what log is shown.
* You can also use a custom log printer in your app as shown in _log_custom.
@ -8,19 +8,19 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
static double Divide(int num, int denom)
{
if (denom == 0)
eina.Log.Critical("Attempt to divide by 0\n");
Eina.Log.Critical("Attempt to divide by 0\n");
else
{
if (denom < 0)
eina.Log.Warning("Possible undesirable effect, divide by negative number");
Eina.Log.Warning("Possible undesirable effect, divide by negative number");
double ret = ((double) num / denom);
eina.Log.Info($"{num} / {denom} = {ret}\n");
Eina.Log.Info($"{num} / {denom} = {ret}\n");
return ret;
}
@ -39,24 +39,31 @@ public class Example
Console.WriteLine("Executing with default logging");
Divides();
eina.Log.GlobalLevelSet(eina.Log.Level.Warning);
Console.WriteLine("Executing with Warning level"); // same as EINA_LOG_LEVEL = 2
Eina.Log.GlobalLevelSet(Eina.Log.Level.Warning);
Console.WriteLine("Executing with Warning level"); // Same as EINA_LOG_LEVEL = 2
Divides();
eina.Log.GlobalLevelSet(eina.Log.Level.Info);
Console.WriteLine("Executing with Info on"); // same as EINA_LOG_LEVEL = 3
Eina.Log.GlobalLevelSet(Eina.Log.Level.Info);
Console.WriteLine("Executing with Info on"); // Same as EINA_LOG_LEVEL = 3
Divides();
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
LogLevels();
// TODO: missing
//LogCustom();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,25 +1,21 @@
/*
* Eina Value examples.
* Eina.Value examples.
*
* These examples demonstrate how to work with eina_value data and methods.
* Eina_Value is a way to represent and pass data of varying types and to
* These examples demonstrate how to work with Eina.Value data and methods.
* Eina.Value is a way to represent and pass data of varying types and to
* convert efficiently between them.
* Eina_Value can even define structs for managing more complex requirements.
* Eina.Value can even define structs for managing more complex requirements.
*/
using System;
public class Example
public class Example : Efl.Csharp.Application
{
static void ValueInt()
{
int i;
// Setting up an integer value type
var int_val = new eina.Value(eina.ValueType.Int32);
int_val.Set(123);
int_val.Get(out i);
Console.WriteLine("int_val value is {0}", i);
Eina.Value int_val = 123;
Console.WriteLine("int_val value is {0}", int_val);
// It can easily be converted to a string
string str = int_val.ToString();
@ -28,13 +24,9 @@ public class Example
static void ValueString()
{
string str;
// Setting up an string value type
var str_val = new eina.Value(eina.ValueType.String);
str_val.Set("My string");
str_val.Get(out str);
Console.WriteLine("str_val value is \"{0}\"", str);
Eina.Value str_val = "My string";
Console.WriteLine("str_val value is \"{0}\"", str_val);
// To string should have the same content
string newstr = str_val.ToString();
@ -43,33 +35,20 @@ public class Example
static void ValueConvert()
{
// Set up string and int types to convert between
var str_val = new eina.Value(eina.ValueType.String);
var int_val = new eina.Value(eina.ValueType.Int32);
// Convert from int to string:
int i1;
string str1;
int_val.Set(123);
int_val.Get(out i1);
Eina.Value int_val = 123;
Eina.Value str_val = new Eina.Value(Eina.ValueType.String);
int_val.ConvertTo(str_val);
str_val.Get(out str1);
Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", i1, str1);
Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", int_val, str_val);
// And the other way around!
int i2;
string str2;
str_val.Set("33");
str_val.Get(out str2);
str_val = "33.000";
str_val.ConvertTo(int_val);
int_val.Get(out i2);
Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str2, i2);
Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val);
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init();
ValueInt();
Console.WriteLine("");
@ -79,6 +58,15 @@ public class Example
ValueConvert();
Console.WriteLine("");
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -0,0 +1,17 @@
Efl.Ui.AlertPopup alertPopup = new Efl.Ui.AlertPopup(parent);
alertPopup.SetButton(Efl.Ui.AlertPopupButton.Positive, "Accept", null);
alertPopup.SetButton(Efl.Ui.AlertPopupButton.Negative, "Reject", null);
alertPopup.ButtonClickedEvent += (sender, args) =>
{
if (args.arg.Button_type.Equals(Efl.Ui.AlertPopupButton.Positive))
Console.WriteLine("Positive action invoked");
else if (args.arg.Button_type.Equals(Efl.Ui.AlertPopupButton.Negative))
Console.WriteLine("Negative action invoked");
};
alertPopup.BackwallClickedEvent += (s, e) =>
{
Console.WriteLine("Backwall clicked");
};

View File

@ -0,0 +1,6 @@
Efl.Ui.Bg bg = new Efl.Ui.Bg(parent);
bg.Color = (66, 162, 206, 255);
bg.SetFile(image_path + "background.png");
bg.Load();

View File

@ -0,0 +1,10 @@
Efl.Ui.Box box = new Efl.Ui.Box(parent);
//Creating content which we will pack into the box
//It can be any widget, for example, buttons
Efl.Ui.Button button1 = new Efl.Ui.Button(box);
Efl.Ui.Button button2 = new Efl.Ui.Button(box);
//Packing the content to the box, one after another
box.Pack(button1);
box.Pack(button2);

View File

@ -0,0 +1,9 @@
Efl.Ui.Button button = new Efl.Ui.Button(parent);
button.Text = "Test Button";
button.ClickedEvent += (sender, args) =>
{
Efl.Ui.Button btn = (Efl.Ui.Button)sender;
btn.Text = "Clicked";
};

View File

@ -0,0 +1,12 @@
Efl.Ui.Check check = new Efl.Ui.Check(parent);
check.Text = "Test Check";
check.SetSelected(true);
check.SelectedChangedEvent += (sender, args) =>
{
if (check.Selected)
Console.WriteLine("Check is selected");
else
Console.WriteLine("Check is not selected");
};

View File

@ -0,0 +1,11 @@
Efl.Ui.Datepicker datepicker = new Efl.Ui.Datepicker(parent);
datepicker.SetDateMin(2000, 1, 1);
datepicker.SetDateMax(2030, 1, 1);
datepicker.SetDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
datepicker.DateChangedEvent += (sender, args) =>
{
datepicker.GetDate(out int year, out int month, out int day);
Console.WriteLine("Date has been changed! Current date: " + year + "-" + month + "-" + day);
};

View File

@ -0,0 +1,4 @@
Efl.Ui.Image image = new Efl.Ui.Image(parent);
image.SetFile(image_path + "icon.png");
image.Load();

View File

@ -0,0 +1,12 @@
Efl.Ui.Popup popup = new Efl.Ui.Popup(parent);
Efl.Ui.Button button = new Efl.Ui.Button(parent);
button.Text = "Click to hide the popup";
button.ClickedEvent += (sender, args) =>
{
popup.SetVisible(false);
};
popup.SetContent(button);

View File

@ -0,0 +1,11 @@
Efl.Ui.Progressbar progressbar = new Efl.Ui.Progressbar(parent);
// You can choose the range limits according to your needs.
// It can be percentage, but it can be also different value (e.g. number of files to be copied)
progressbar.SetRangeLimits(0.0, 100.0);
// Setting initial progress value
progressbar.RangeValue = 0;
// When progress is made you should modify the RangeValue:
progressbar.RangeValue = 33;

View File

@ -0,0 +1,14 @@
Efl.Ui.RadioBox radioBox = new Efl.Ui.RadioBox(parent);
for (int i = 1; i <= 3; i++)
{
Efl.Ui.Radio radio = new Efl.Ui.Radio(radioBox);
radio.Text = "Choice no. " + i;
radio.SetStateValue(i);
radioBox.Pack(radio);
}
radioBox.ValueChangedEvent += (sender, args) =>
{
System.Console.WriteLine("RadioBox value changed! Current choice value: " + args.arg);
};

View File

@ -0,0 +1,10 @@
Efl.Ui.Scroller scroller = new Efl.Ui.Scroller(parent);
// Create a large image to put it inside the scroller
Efl.Ui.Image image = new Efl.Ui.Image(scroller);
image.HintSizeMin = new Eina.Size2D(1000, 1000);
image.SetFile(image_path + "image.png");
image.Load();
scroller.SetContent(image);

View File

@ -0,0 +1,16 @@
Efl.Ui.Slider slider = new Efl.Ui.Slider(parent);
slider.SetRangeLimits(0, 100);
slider.SetRangeValue(50);
// You get this event every time the slider moves
slider.ChangedEvent += (sender, args) =>
{
Console.WriteLine("Current slider value is: " + slider.GetRangeValue());
};
// You only get this event once the slider is stable
slider.SteadyEvent += (sender, args) =>
{
Console.WriteLine("STEADY slider value is: " + slider.GetRangeValue());
};

View File

@ -0,0 +1,13 @@
Efl.Ui.SpinButton spinButton = new Efl.Ui.SpinButton(parent);
spinButton.Orientation = Efl.Ui.LayoutOrientation.Vertical;
spinButton.SetRangeLimits(0, 100);
spinButton.SetRangeStep(2);
spinButton.SetRangeValue(50);
spinButton.ChangedEvent += (sender, args) =>
{
Efl.Ui.SpinButton spnBtn = (Efl.Ui.SpinButton)sender;
Console.WriteLine("Range value changed to: " + spnBtn.RangeValue);
};

View File

@ -0,0 +1,10 @@
Efl.Ui.Table table = new Efl.Ui.Table(parent);
table.SetTableSize(2, 2);
Efl.Ui.Button button1 = new Efl.Ui.Button(table);
Efl.Ui.Button button2 = new Efl.Ui.Button(table);
// The first column and row have indexes = 0.
table.PackTable(button1, 0, 0, 1, 1);
table.PackTable(button2, 1, 1, 1, 1);

View File

@ -0,0 +1,3 @@
var win = new Efl.Ui.Win(Efl.App.AppMain);
win.FocusHighlightEnabled = true;

View File

@ -0,0 +1,8 @@
var win = new Efl.Ui.Win(Efl.App.AppMain);
win.SetWinType(Efl.Ui.WinType.Basic);
win.Text = "Hello World";
win.Autohide = true;
win.VisibilityChangedEvent +=
(sender, args) => { };

View File

@ -0,0 +1,9 @@
Place code snippets in this folder.
If the file name matches a class name (like Efl.Ui.Win) or a property name (like Efl.Ui.Win.FocusHighlightEnabled)
the mono documentation generator (DocFX) will pick up the content of the file and embed it.
Two file formats are supported:
- Plain code (files with .cs extension): Code snippets are copied into the documentation inside <example> and <code>
tags.
- XML text (files with .xml extension): This allows including explanatory text besides the code snippets, but the file
must include the ESCAPED \<example\> and \<code\> tags. Escaping is accomplished by adding a backslash in front of
angle brackets. Quotes must be escaped too: \"

View File

@ -0,0 +1,9 @@
project(
'snippets', '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')

View File

@ -1,10 +1,70 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
public static void FocusChangedCb(object sender, EventArgs e)
{
Console.WriteLine($"Focus for object {((efl.IText)sender).GetText()} changed to {((efl.ui.IWidget)sender).GetFocus()}");
Console.WriteLine($"Focus for object {((Efl.IText)sender).Text} changed to {((Efl.Ui.Widget)sender).Focus}");
}
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
var win = new Efl.Ui.Win(null, winType: Efl.Ui.WinType.Basic);
win.Text = "Focus example";
win.Autohide = true;
win.VisibilityChangedEvent += (object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e) => {
// Exit the EFL main loop
if (e.Arg == false)
Efl.Ui.Config.Exit();
};
// Create the main box container
var vbox = new Efl.Ui.Box(win);
vbox.HintSizeMin = new Eina.Size2D(360, 240);
win.Content = vbox;
// Create some check boxes
Efl.Ui.Check first_checkbox = null;
for (int i = 0; i< 5; i++) {
var checkbox = new Efl.Ui.Check(vbox);
checkbox.Text = "Check " + i;
checkbox.HintFill = (false, false);
checkbox.HintAlign = ((Efl.Gfx.Align)0.5, (Efl.Gfx.Align)0.5);
checkbox.FocusChangedEvent += FocusChangedCb;
vbox.Pack(checkbox);
if (i == 0) first_checkbox = checkbox;
};
// Create an horizontal box to contain the two buttons
var hbox = new Efl.Ui.Box(vbox);
hbox.Orientation = Efl.Ui.LayoutOrientation.Horizontal;
vbox.Pack(hbox);
// Create a "Focus Mover" button
var button = new Efl.Ui.Button(hbox);
button.Text = "Focus mover";
button.FocusChangedEvent += FocusChangedCb;
button.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => {
Console.WriteLine("Clicked Focus Mover");
// Manually transfer focus to the first check box
Efl.Ui.Focus.Util.Focus(first_checkbox);
};
hbox.Pack(button);
// Create a Quit button
button = new Efl.Ui.Button(hbox);
button.Text = "Quit";
button.FocusChangedEvent += FocusChangedCb;
button.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => {
Console.WriteLine("Clicked Quit");
Efl.Ui.Config.Exit();
};
hbox.Pack(button);
// Show the focus highlight
win.FocusHighlightEnabled = true;
}
#if WIN32
@ -12,75 +72,8 @@ public class Example
#endif
public static void Main()
{
// Initialize EFL and all UI components
efl.All.Init(efl.Components.Ui);
// Create a window and initialize it
var win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
ewin.SetWinType(efl.ui.Win_Type.Basic);
ewin.SetText("Focus example");
ewin.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop
efl.ui.Config.Exit();
};
});
// Create the main box container
var vbox = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
ebox.SetHintMin(new eina.Size2D(360, 240));
win.SetContent(ebox);
});
// Create some check boxes
efl.ui.ICheck first_checkbox = null;
for (int i = 0; i< 5; i++) {
var checkbox = new efl.ui.Check(vbox, (efl.ui.ICheck echeck) => {
echeck.SetText("Check " + i);
echeck.SetHintAlign(0.5, 0.5);
echeck.FocusChangedEvt += FocusChangedCb;
vbox.DoPack(echeck);
});
if (i == 0) first_checkbox = checkbox;
};
// Create an horizontal box to contain the two buttons
var hbox = new efl.ui.Box(vbox, (efl.ui.IBox ebox) => {
ebox.SetDirection(efl.ui.Dir.Horizontal);
vbox.DoPack(ebox);
});
// Create a "Focus Mover" button
new efl.ui.Button(hbox, (efl.ui.IButton ebutton) => {
ebutton.SetText("Focus mover");
ebutton.FocusChangedEvt += FocusChangedCb;
ebutton.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Focus Mover");
// Manually transfer focus to the first check box
efl.ui.focus.Util.Focus(first_checkbox);
};
hbox.DoPack(ebutton);
});
// Create a Quit button
new efl.ui.Button(hbox, (efl.ui.IButton ebutton) => {
ebutton.SetText("Quit");
ebutton.FocusChangedEvt += FocusChangedCb;
ebutton.ClickedEvt += (object sender, EventArgs e) => {
Console.WriteLine("Clicked Quit");
efl.ui.Config.Exit();
};
hbox.DoPack(ebutton);
});
// Show the focus highlight
win.SetFocusHighlightEnabled(true);
// Start the EFL main loop
efl.ui.Config.Run();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch();
}
}

View File

@ -20,3 +20,10 @@ executable('efl_reference_ui_focus',
cs_args : efl_mono_libs,
install : true
)
executable('efl_reference_ui_custom_widget',
files(['ui_custom_widget.cs']),
dependencies : deps,
cs_args : efl_mono_libs,
install : true
)

View File

@ -7,122 +7,111 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
// Create a box container full of buttons
static efl.ui.IBox CreateBox(efl.ui.IWin win)
static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
{
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
// Set distance between contained elements
ebox.SetPackPadding(5, 0, true);
});
Efl.Ui.Box box = new Efl.Ui.Box(win);
// Set distance between contained elements
box.ContentPadding = (5, 0);
for (int i = 1; i <= 4; ++i)
{
// 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));
}
box.DoPack(ebutton);
});
var button = new Efl.Ui.Button(win);
button.Text = $"Boxed {i}";
if (i == 2)
{
// Button 2 has its maximum size limited, so it will be smaller
button.HintSizeMax = new Eina.Size2D(100,50);
}
box.Pack(button);
}
return box;
}
// Create a simple table layout
static efl.ui.ITable CreateTable(efl.ui.IWin win)
static Efl.Ui.Table CreateTable(Efl.Ui.Win 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
etable.SetTableColumns(2);
etable.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
});
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.TableColumns = 2;
table.Orientation = Efl.Ui.LayoutOrientation.Horizontal;
Efl.Ui.Button button;
for (int i = 1; i <= 4; ++i)
{
// Add 4 buttons, following the defined table flow
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText($"Table {i}");
table.DoPack(ebutton);
});
button = new Efl.Ui.Button(win);
button.Text = $"Table {i}";
table.Pack(button);
}
// Last button spans two table cells
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText("Long Button");
table.PackTable(ebutton, 0, 2, 2, 1);
});
button = new Efl.Ui.Button(win);
button.Text = "Long Button";
table.PackTable(button, 0, 2, 2, 1);
return table;
}
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(null, winType: Efl.Ui.WinType.Basic);
win.Text = "Container demo";
win.Autohide = true;
win.VisibilityChangedEvent += (object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e) => {
// Exit the EFL main loop
if (e.Arg == false)
Efl.Ui.Config.Exit();
};
// Give the window an initial size so there is room to resize the panes.
// Otherwise, all widgets are tightly packed
win.Size = new Eina.Size2D(350,250);
// Create a vertically-split panes container
Efl.Ui.Panes vsplit = new Efl.Ui.Panes(win);
vsplit.SplitRatio = 0.75;
win.Content = vsplit;
// Create some boxes and set them as the content of the first pane of the container
var box = CreateBox(win);
vsplit.FirstPart.Content = box;
// Create a second, horizontally-split panes container and set it as the content of
// the second pane of the first container
Efl.Ui.Panes hsplit = new Efl.Ui.Panes(win);
hsplit.Orientation = Efl.Ui.LayoutOrientation.Horizontal;
hsplit.SplitRatio = 0.85;
vsplit.SecondPart.SetContent(hsplit);
// Create a table and set it as the content of the first pane of the horizontal
// container
var table = CreateTable(win);
hsplit.FirstPart.SetContent(table);
// Create a button and set it as the content of the second pane of the horizontal
// container
Efl.Ui.Button quit_btn = new Efl.Ui.Button(win);
quit_btn.Text = "Quit";
quit_btn.HintSizeMax = new Eina.Size2D(150, 30);
quit_btn.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => {
// Exit the EFL main loop
Efl.Ui.Config.Exit();
};
hsplit.SecondPart.SetContent(quit_btn);
}
#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) => {
ewin.SetWinType(efl.ui.Win_Type.Basic);
ewin.SetText("Container demo");
ewin.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop
efl.ui.Config.Exit();
};
});
// Give the window an initial size so there is room to resize the panes.
// Otherwise, all widgets are tightly packed
win.SetSize(new eina.Size2D(350,250));
// Create a vertically-split panes container
efl.ui.IPanes vsplit = new efl.ui.Panes(win, (efl.ui.IPanes epanes) => {
epanes.SetSplitRatio(0.75);
win.SetContent(epanes);
});
// Create some boxes and set them as the content of the first pane of the container
var box = 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
// the second pane of the first container
efl.ui.IPanes hsplit = new efl.ui.Panes(win, (efl.ui.IPanes epanes) => {
epanes.SetDirection(efl.ui.Dir.Horizontal);
epanes.SetSplitRatio(0.85);
});
efl.Content.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
// Create a table and set it as the content of the first pane of the horizontal
// container
var table = 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
// container
efl.ui.IButton quit_btn = new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText("Quit");
ebutton.SetHintMax(new eina.Size2D(150, 30));
ebutton.ClickedEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop
efl.ui.Config.Exit();
};
});
efl.Content.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
// Start the EFL main loop
efl.ui.Config.Run();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch();
}
}

View File

@ -0,0 +1,64 @@
/*
* Efl.UI custom widget examples.
*
* Inherit from an EFL C# class and customize it
*/
using System;
// This is our own button with customized text functions
public class MyButton : Efl.Ui.Button
{
// This id shows how our data is preserved when overriden methods
// are called from native code
private int button_id;
// Constructor sets an initial text
public MyButton(Efl.Object parent, int id = 0) :
base(parent)
{
button_id = id;
base.Text = "Base text for button id " + id;
}
// This calls the parent's SetText() method with a modified string
public override string Text
{
set {
base.Text = "Overriden text for button id " + button_id + ": " + value;
}
}
}
public class Example : Efl.Csharp.Application
{
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(null, winType: Efl.Ui.WinType.Basic);
win.Text = "Custom widget demo";
win.Autohide = true;
win.VisibilityChangedEvent += (object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e) => {
// Exit the EFL main loop when the window is closed
if (e.Arg == false)
Efl.Ui.Config.Exit();
};
// Give the window an initial size
win.Size = new Eina.Size2D(350,250);
// Instantiate our custom button widget
MyButton btn = new MyButton(win, 99);
btn.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => {
// When the button is clicked, change its text
MyButton b = (MyButton)sender;
b.Text = "Hello!";
};
win.SetContent(btn);
}
public static void Main()
{
var example = new Example();
example.Launch();
}
}

View File

@ -8,57 +8,49 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(null, winType: Efl.Ui.WinType.Basic);
win.Text = "Size Control";
win.Autohide = true;
win.VisibilityChangedEvent += (object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e) => {
// Exit the EFL main loop
if (e.Arg == false)
Efl.Ui.Config.Exit();
};
// Create a box container
Efl.Ui.Box box = new Efl.Ui.Box(win);
win.SetContent(box);
// Create a regular button (without size hints)
var button = new Efl.Ui.Button(win);
button.Text = "Button";
box.Pack(button);
// Create a small button (max size is limited)
button = new Efl.Ui.Button(win);
button.Text = "Small";
button.HintSizeMax = new Eina.Size2D(50,50);
box.Pack(button);
// Create a big button (min size is limited)
button = new Efl.Ui.Button(win);
button.Text = "Big button";
button.HintSizeMin = new Eina.Size2D(100,100);
box.Pack(button);
}
#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) => {
ewin.SetWinType(efl.ui.Win_Type.Basic);
ewin.SetText("Size Control");
ewin.SetAutohide(true);
ewin.HideEvt += (object sender, EventArgs e) => {
// Exit the EFL main loop
efl.ui.Config.Exit();
};
});
// Create a box container
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
win.SetContent(ebox);
});
// Create a regular button (without size hints)
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText("Button");
box.DoPack(ebutton);
});
// Create a small button (max size is limited)
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText("Small");
ebutton.SetHintMax(new eina.Size2D(50,50));
box.DoPack(ebutton);
});
// Create a big button (min size is limited)
new efl.ui.Button(win, (efl.ui.IButton ebutton) => {
ebutton.SetText("Big button");
ebutton.SetHintMin(new eina.Size2D(100,100));
box.DoPack(ebutton);
});
// Start the EFL main loop
efl.ui.Config.Run();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch();
}
}

View File

@ -1,12 +1,22 @@
#!/usr/bin/python3
import os
import subprocess
from string import Template
supported_languages = ["c", "csharp", "cxx"]
supported_languages = ["c"]
directories = ["apps", "reference", "tutorial"] # "examples", "legacy-examples"
goals = []
subprojects = []
if subprocess.call("pkg-config --exists efl-mono", shell=True) == 0:
supported_languages += ["csharp"]
else:
print("Disable c# bindings")
if subprocess.call("pkg-config --exists eina-cxx", shell=True) == 0:
supported_languages += ["cxx"]
else:
print("Disable c++ bindings")
class SubProjectGoal:
def __init__(self, language, path):
self.language = language

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>

View File

@ -1,4 +1,4 @@
class Example.Rectangle (Efl.Object) {
class Example.Rectangle extends Efl.Object {
methods {
@property width {
set {

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>

View File

@ -1,5 +1,8 @@
class Example.Rectangle (Efl.Object) {
[[A rectangle shape object]]
class Example.Rectangle extends Efl.Object {
[[A rectangle shape object
@since 1.00
]]
methods {
@property width {
[[The width of this rectangle]]

View File

@ -1,5 +1,8 @@
class Example.Square (Example.Rectangle) {
[[A square shape object]]
class Example.Square extends Example.Rectangle {
[[A square shape object
@since 1.00
]]
implements {
Example.Rectangle.width {set;}
Example.Rectangle.height {set;}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
@ -13,15 +12,15 @@ static void
_obj_create()
{
// First create a root element
_root = efl_new(EFL_MODEL_ITEM_CLASS,
_root = efl_new(EFL_GENERIC_MODEL_CLASS,
efl_name_set(efl_added, "Root"));
// Create the first child element
_child1 = efl_add(EFL_MODEL_ITEM_CLASS, _root,
_child1 = efl_add(EFL_GENERIC_MODEL_CLASS, _root,
efl_name_set(efl_added, "Child1"));
// Create the second child element, this time, with an extra reference
_child2 = efl_add_ref(EFL_MODEL_ITEM_CLASS, _root,
_child2 = efl_add_ref(EFL_GENERIC_MODEL_CLASS, _root,
efl_name_set(efl_added, "Child2"));
}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>

View File

@ -1,5 +1,8 @@
class Example.Circle (Efl.Object, Example.Shape) {
[[A circle shape object]]
class Example.Circle extends Efl.Object implements Example.Shape {
[[A circle shape object
@since 1.00
]]
methods {
@property radius {
[[The radius of this circle]]

View File

@ -1,5 +1,8 @@
mixin Example.Colored {
[[A mixin for providing APIs for managing colour properties]]
[[A mixin for providing APIs for managing colour properties
@since 1.00
]]
methods {
@property color {
[[The colour to associate with the class we are coloring.

View File

@ -1,5 +1,8 @@
class Example.Rectangle (Efl.Object, Example.Shape, Example.Colored) {
[[A rectangle shape object]]
class Example.Rectangle extends Efl.Object implements Example.Shape, Example.Colored {
[[A rectangle shape object
@since 1.00
]]
methods {
@property width {
[[The width of this rectangle]]

View File

@ -1,5 +1,8 @@
interface Example.Shape {
[[A generic shape object]]
[[A generic shape object
@since 1.00
]]
methods {
area {
[[Calculate the area of the shape.]]

View File

@ -1,5 +1,8 @@
class Example.Square (Example.Rectangle) {
[[A square shape object]]
class Example.Square extends Example.Rectangle {
[[A square shape object
@since 1.00
]]
implements {
Example.Rectangle.width {set;}
Example.Rectangle.height {set;}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
@ -52,7 +51,7 @@ static void
_obj_create()
{
// First create a root element
_root = efl_new(EFL_MODEL_ITEM_CLASS,
_root = efl_new(EFL_GENERIC_MODEL_CLASS,
efl_name_set(efl_added, "Root"));
// Add a weak reference so we can keep track of its state
efl_wref_add(_root, &_root_ref);
@ -60,7 +59,7 @@ _obj_create()
efl_event_callback_add(_root, EFL_EVENT_DEL, _obj_del_cb, NULL);
// Create the first child element
_child1 = efl_add(EFL_MODEL_ITEM_CLASS, _root,
_child1 = efl_add(EFL_GENERIC_MODEL_CLASS, _root,
efl_name_set(efl_added, "Child1"));
// Add a weak reference so we can keep track of its state
efl_wref_add(_child1, &_child1_ref);
@ -68,7 +67,7 @@ _obj_create()
efl_event_callback_add(_child1, EFL_EVENT_DEL, _obj_del_cb, NULL);
// Create the second child element, this time, with an extra reference
_child2 = efl_add_ref(EFL_MODEL_ITEM_CLASS, _root,
_child2 = efl_add_ref(EFL_GENERIC_MODEL_CLASS, _root,
efl_name_set(efl_added, "Child2"));
// Add a weak reference so we can keep track of its state
efl_wref_add(_child2, &_child2_ref);

View File

@ -1,6 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Efl_Core.h>

View File

@ -1,7 +1,5 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
@ -17,7 +15,7 @@ _gui_setup()
Eo *win, *box;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -26,20 +24,23 @@ _gui_setup()
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_add(EFL_UI_TEXT_CLASS, box,
efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_text_markup_set(efl_added, "Hello World.<br>This is an <b>Efl.Ui</b> application!"),
efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.9),
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
efl_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_gfx_hint_weight_set(efl_added, 1.0, 0.9),
efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
efl_gfx_hint_fill_set(efl_added, EINA_FALSE, EINA_FALSE),
efl_text_multiline_set(efl_added,EINA_TRUE),
efl_pack(box, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, box,
efl_text_set(efl_added, "Quit"),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_gfx_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_quit_cb, efl_added));
}

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <check.h>

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
@ -61,7 +60,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
// The timer function will trigger the chain of simulated events to show
// how an app could respond to system lifecycle events.
efl_add(EFL_LOOP_TIMER_CLASS, ev->object,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _lifecycle_simulation, ev->object),
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TIMER_TICK, _lifecycle_simulation, ev->object),
efl_loop_timer_interval_set(efl_added, 1.0));
}
EFL_MAIN_EX()

View File

@ -1,4 +1,3 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
@ -17,15 +16,15 @@ _gui_setup()
Eo *win;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
efl_ui_win_name_set(efl_added, "Lifecycle Example"),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Quit"),
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)),
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
}

View File

@ -1,26 +1,23 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
static efl.IModel_Item root, child2;
static Efl.GenericModel root, child2;
// Create our test hierarchy
static void ObjCreate()
{
// First create a root element
root = new efl.Model_Item(null, (efl.IModel_Item eroot) => {
eroot.SetName("Root");
});
root = new Efl.GenericModel(null);
root.Name = "Root";
// Create the first child element
new efl.Model_Item(root, (efl.IModel_Item eroot) => {
eroot.SetName("Child1");
});
var child = new Efl.GenericModel(root);
child.Name = "Child1";
// Create the second child element, this time, with an extra reference
child2 = new efl.Model_Item(root, (efl.IModel_Item eroot) => {
eroot.SetName("Child2");
});
child2 = new Efl.GenericModel(root);
child2.Name = "Child2";
}
// Destroy the test hierarchy
@ -35,16 +32,23 @@ public class Example
child2.Dispose();
}
public static void Main()
protected override void OnInitialize(string[] args)
{
efl.All.Init(efl.Components.Ui);
// Create all objects
ObjCreate();
// Destroy all objects
ObjDestroy();
efl.All.Shutdown();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
}
}

View File

@ -1,12 +1,56 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
// Callback to quit the application
public static void QuitCb(object sender, EventArgs e)
public static void QuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e)
{
// Exit the EFL main loop
efl.ui.Config.Exit();
if (e.Arg == false)
Efl.App.AppMain.Quit(0);
}
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
// Set the window's title
win.Text = "Hello World";
// Request that the window is automatically hidden when the "close"
// button is pressed
win.Autohide = true;
// Hook to the Hide event
win.VisibilityChangedEvent += QuitCb;
// Create a box container
var box = new Efl.Ui.Box(win);
// Set its minimum size
box.HintSizeMin = 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);
// Create a text label widget
var label = new Efl.Ui.Textbox(box);
// Set its content and customize it
label.Text = "Hello World. This is an Efl.Ui application!";
label.Editable = false;
label.SelectionAllowed = false;
label.HintWeight = (1.0, 0.9);
label.HintFill = (false, false);
label.HintAlign = ((Efl.Gfx.Align)0.5, (Efl.Gfx.Align)0.5);
// Add the text to the box container
box.Pack(label);
// Create a button widget
var button = new Efl.Ui.Button(box);
// Customize it
button.Text = "Quit";
button.HintWeight = (1.0, 0.1);
// Set the method to be called when the button is pressed
button.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => { Efl.App.AppMain.Quit(0); };
// Add the button to the box container
box.Pack(button);
}
#if WIN32
@ -14,56 +58,8 @@ public class Example
#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(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;
});
// Create a box container
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
// Set its minimum size
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(ebox);
});
// Create a text label widget
new efl.ui.Text(box, (efl.ui.IText etext) => {
// Set its content and customize it
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(etext);
});
// Create a button widget
new efl.ui.Button(box, (efl.ui.IButton ebutton) => {
// Customize it
ebutton.SetText("Quit");
ebutton.SetHintWeight(1.0, 0.1);
// Set the method to be called when the button is pressed
ebutton.ClickedEvt += QuitCb;
// Add the button to the box container
box.DoPack(ebutton);
});
// Start the EFL main loop
efl.ui.Config.Run();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch();
}
}

View File

@ -1,31 +1,36 @@
using System;
public class Example
public class Example : Efl.Csharp.Application
{
// Callback to quit the application
public static void QuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e)
{
// Exit the EFL main loop
if (e.Arg == false)
Efl.App.AppMain.Quit(0);
}
protected override void OnInitialize(string[] args)
{
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
// Set the window's title
win.Text = "Hello World";
// Request that the window is automatically hidden when the "close"
// button is pressed
win.Autohide = true;
// Window size must be explicitly set, otherwise it will be invisible
// due to its lack of content.
win.Size = new Eina.Size2D(360, 240);
win.VisibilityChangedEvent += QuitCb;
}
#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(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);
});
// Window size must be explicitly set, otherwise it will be invisible
// due to its lack of content.
win.SetSize(new eina.Size2D(360, 240));
// Start the EFL main loop
efl.ui.Config.Run();
// Shutdown EFL
efl.All.Shutdown();
var example = new Example();
example.Launch();
}
}

Some files were not shown because too many files have changed in this diff Show More