Compare commits
84 Commits
devs/xarti
...
master
Author | SHA1 | Date |
---|---|---|
Xavi Artigas | df21c3770e | |
Xavi Artigas | f835d45622 | |
Xavi Artigas | 5f1be675ee | |
Xavi Artigas | 6e77c4aae2 | |
Xavi Artigas | f3076c6d19 | |
Xavi Artigas | ac5879e3e5 | |
Xavi Artigas | b694a830af | |
Xavi Artigas | 6a470840d9 | |
Xavi Artigas | dfa678e9dc | |
Xavi Artigas | 4b6740b258 | |
Ali Alzyod | 870cda6730 | |
Xavi Artigas | be0ade4350 | |
Xavi Artigas | 6f183d62c2 | |
Xavi Artigas | cba451e99b | |
Xavi Artigas | aeaba83065 | |
Xavi Artigas | 868ed77548 | |
Xavi Artigas | d57c8e2d28 | |
Xavi Artigas | f9486b6bfd | |
Xavi Artigas | 8caeaaf071 | |
Xavi Artigas | 95c373e8e3 | |
Lauro Moura | b8f57276ef | |
Xavi Artigas | b8fd0c3b74 | |
Xavi Artigas | 0a23c904cb | |
Xavi Artigas | 6dfa4bac1d | |
Lukasz Oleksak | 9f0eebb54f | |
Lukasz Oleksak | 670a6bc902 | |
Mike Blumenkrantz | fea913d1e1 | |
Xavi Artigas | fd32510f35 | |
Bruno da Silva Belo | 242ed076f3 | |
Xavi Artigas | f161620f9f | |
Lauro Moura | 3aecb39a18 | |
Xavi Artigas | 5a4c817d16 | |
Xavi Artigas | 40801d9285 | |
Xavi Artigas | 5472a77fb3 | |
Ali Alzyod | 17609ba6bf | |
Xavi Artigas | 93120a13f5 | |
Bruno da Silva Belo | fa93b9f7c0 | |
Xavi Artigas | e8245fe5dd | |
Xavi Artigas | 4c2c569c7e | |
Lauro Moura | 9ed9d94501 | |
Xavi Artigas | a49641d9b4 | |
Xavi Artigas | b2c7e2c2dd | |
Xavi Artigas | d325da2119 | |
Xavi Artigas | 21567fcccf | |
Xavi Artigas | af73959386 | |
Xavi Artigas | 836a9edf73 | |
Xavi Artigas | 05d9b74e19 | |
Xavi Artigas | 6cb115480e | |
Xavi Artigas | fdeb87bb75 | |
Xavi Artigas | b2c41e4e01 | |
Lauro Moura | 595be4aa12 | |
Xavi Artigas | f47f1f3672 | |
Xavi Artigas | d4e81b7b65 | |
Xavi Artigas | 5f436d2874 | |
Xavi Artigas | 169f569af6 | |
Xavi Artigas | b55e5150c9 | |
Xavi Artigas | 871add6fe5 | |
Lauro Moura | 735b848660 | |
Ali Alzyod | 82dd23ba02 | |
Xavi Artigas | 43bb6e3896 | |
Xavi Artigas | 679c89d98d | |
Xavi Artigas | aad5b641c8 | |
Xavi Artigas | 3e1aefa7ea | |
Mike Blumenkrantz | d16b7e48bc | |
Lauro Moura | 780ebf91c5 | |
Lauro Moura | 09416b5ccf | |
Felipe Magno de Almeida | 1d5a5322df | |
Xavi Artigas | 500049f1eb | |
Lauro Moura | e674ff0d97 | |
Xavi Artigas | af8036ab17 | |
Xavi Artigas | 9751e2ed82 | |
Xavi Artigas | a5c08814d8 | |
Xavi Artigas | e06157c1f6 | |
Marcel Hollerbach | a7c5ff510e | |
Xavi Artigas | d74a4df994 | |
Marcel Hollerbach | 656b746be7 | |
Marcel Hollerbach | d8ea961985 | |
Xavi Artigas | e6aa5e6aa0 | |
Marcel Hollerbach | 3052374b49 | |
Marcel Hollerbach | 5b36c351e3 | |
Lauro Moura | c2e4308dd1 | |
Marcel Hollerbach | 8a4df21de8 | |
Marcel Hollerbach | ddb06ddc1b | |
Xavi Artigas | a040529352 |
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"project_id" : "examples",
|
||||
"projects" : "examples",
|
||||
"conduit_uri" : "https://phab.enlightenment.org/",
|
||||
"phabricator.uri" : "https://phab.enlightenment.org/",
|
||||
"repository.callsign" : "examples"
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
build
|
||||
*.pot
|
||||
|
||||
.*.swp
|
||||
subprojects
|
||||
/meson.build
|
||||
|
|
17
README
17
README
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
@ -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()
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
src = files([
|
||||
'calculator.c',
|
||||
])
|
||||
|
||||
deps = [eina, efl, elm]
|
||||
|
||||
executable('efl_example_calculator', src,
|
||||
dependencies : deps,
|
||||
include_directories : inc,
|
||||
install : true
|
||||
)
|
||||
|
|
@ -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.
|
@ -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()
|
|
@ -0,0 +1,11 @@
|
|||
src = files([
|
||||
'homescreen.c',
|
||||
])
|
||||
|
||||
deps = [eina, efl, elm]
|
||||
|
||||
executable('efl_example_homescreen', src,
|
||||
dependencies : deps,
|
||||
include_directories : inc,
|
||||
install : true
|
||||
)
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef LIFE_PRIVATE_H_
|
||||
# define LIFE_PRIVATE_H_
|
||||
|
||||
#include <Elementary.h>
|
||||
#include <Efl_Ui.h>
|
||||
|
||||
#define LIFE_BOARD_WIDTH 47
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
project(
|
||||
'efl-reference-net', 'c',
|
||||
'efl-example-calculator', 'cs',
|
||||
version : '0.0.1',
|
||||
meson_version : '>= 0.38.0')
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -1,142 +1,197 @@
|
|||
/* Simple text editor with a main text box and a toolbar on top:
|
||||
+vbox----------------------------------------+
|
||||
| +hbox------------------------------------+ |
|
||||
| | +btn-+ +btn-+ +btn-+ +box-----+ +btn-+ | |
|
||||
| | |NEW | |SAVE| |LOAD| | spacer | |QUIT| | |
|
||||
| | +----+ +----+ +----+ +--------+ +----+ | |
|
||||
| +----------------------------------------+ |
|
||||
| +text------------------------------------+ |
|
||||
| | | |
|
||||
| | | |
|
||||
| | Main text box | |
|
||||
| | | |
|
||||
| | | |
|
||||
| +----------------------------------------+ |
|
||||
+--------------------------------------------+
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class TextEditor : IDisposable
|
||||
public class TextEditor : Efl.Csharp.Application
|
||||
{
|
||||
private efl.ui.IWin win;
|
||||
private efl.ui.IText editor;
|
||||
private efl.ui.IButton toolbarNew;
|
||||
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;
|
||||
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");
|
||||
|
||||
private void GUIQuitCb(object sender, EventArgs ea)
|
||||
// Quits the application
|
||||
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.Disabled = string.IsNullOrEmpty(editorTextBox.Text);
|
||||
// "Save" is enabled if the text has been modified since last save or load
|
||||
toolbarButtonSave.Disabled = !edited;
|
||||
// "Load" is enabled if there is a file to load
|
||||
toolbarButtonLoad.Disabled = !System.IO.File.Exists(filename);
|
||||
}
|
||||
|
||||
// Called when the text in the editor has changed
|
||||
private void EditorChangedCb(object sender, EventArgs ea)
|
||||
{
|
||||
edited = true;
|
||||
GUIToolbarRefresh();
|
||||
}
|
||||
|
||||
private efl.ui.IButton GUIToolbarButtonAdd(efl.ui.IBox toolbar, string name, string iconName, EventHandler func)
|
||||
// Shows a modal message popup with an "OK" button
|
||||
private void ShowMessage(string message)
|
||||
{
|
||||
efl.ui.IButton button = new efl.ui.Button(toolbar);
|
||||
button.SetText(name);
|
||||
button.ClickedEvt += func;
|
||||
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();
|
||||
};
|
||||
}
|
||||
|
||||
toolbar.DoPack(button);
|
||||
// Adds a button to the toolbar, with the given text, icon and click event handler
|
||||
private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name,
|
||||
string iconName, EventHandler<Efl.Input.ClickableClickedEventArgs> func)
|
||||
{
|
||||
var button = new Efl.Ui.Button(toolbar);
|
||||
button.Text = name;
|
||||
button.ClickedEvent += func;
|
||||
button.HintWeight = (0, 1);
|
||||
|
||||
efl.ui.IImage img = new efl.ui.Image(toolbar);
|
||||
img.SetIcon(iconName);
|
||||
|
||||
efl.Content.static_cast(button.GetPart("efl.content")).SetContent(img);
|
||||
// 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;
|
||||
}
|
||||
|
||||
private void GUIToolbarSetup(efl.ui.IBox parent)
|
||||
// Creates a new toolbar, with all its buttons
|
||||
private void GUIToolbarSetup(Efl.Ui.Box parent)
|
||||
{
|
||||
efl.ui.IBox bar = new efl.ui.Box(parent);
|
||||
bar.SetHintWeight(1, 0);
|
||||
bar.SetDirection(efl.ui.Dir.Horizontal);
|
||||
parent.DoPack(bar);
|
||||
// Create a horizontal box container for the buttons
|
||||
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);
|
||||
|
||||
toolbarNew = GUIToolbarButtonAdd(bar, "New", "document-new",
|
||||
(object sender, EventArgs ea) =>
|
||||
{
|
||||
editor.SetText("");
|
||||
edited = false;
|
||||
// "New" button
|
||||
toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new",
|
||||
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
|
||||
// When this button is clicked, remove content and refresh toolbar
|
||||
editorTextBox.Text = "";
|
||||
GUIToolbarRefresh();
|
||||
});
|
||||
});
|
||||
|
||||
// spacer box
|
||||
efl.ui.IBox box = new efl.ui.Box(parent);
|
||||
box.SetHintWeight(10, 0);
|
||||
bar.DoPack(box);
|
||||
// "Save" button
|
||||
toolbarButtonSave = GUIToolbarButtonAdd(bar, "Save", "document-save",
|
||||
(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.Text);
|
||||
edited = false;
|
||||
GUIToolbarRefresh();
|
||||
ShowMessage("Saved!");
|
||||
} catch (Exception e) {
|
||||
// If something fails, show the error message
|
||||
ShowMessage(e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
GUIToolbarButtonAdd(bar, "Quit", "application-exit", GUIQuitCb);
|
||||
// "Load" button
|
||||
toolbarButtonLoad = GUIToolbarButtonAdd(bar, "Load", "document-open",
|
||||
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
|
||||
// When this button is clicked, try to load content and refresh toolbar
|
||||
try {
|
||||
editorTextBox.Text = System.IO.File.ReadAllText(filename);
|
||||
edited = false;
|
||||
GUIToolbarRefresh();
|
||||
ShowMessage("Loaded!");
|
||||
} catch (Exception e) {
|
||||
// If something fails, show the error message
|
||||
ShowMessage(e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
GUIToolbarRefresh();
|
||||
// Spacer box to use all available space not required by buttons
|
||||
// (It has a default horizontal weight of 1, whereas all buttons have
|
||||
// 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.Box box = new Efl.Ui.Box(parent);
|
||||
bar.Pack(box);
|
||||
|
||||
// "Quit" button
|
||||
GUIToolbarButtonAdd(bar, "Quit", "application-exit", (object sender, Efl.Input.ClickableClickedEventArgs e) => { Efl.Ui.Config.Exit(); } );
|
||||
}
|
||||
|
||||
private void GUIToolbarRefresh()
|
||||
// Builds the user interface for the text editor
|
||||
protected override void OnInitialize(string[] args)
|
||||
{
|
||||
toolbarNew.SetDisabled(!edited);
|
||||
}
|
||||
|
||||
public TextEditor()
|
||||
{
|
||||
win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
|
||||
ewin.SetWinType(efl.ui.Win_Type.Basic);
|
||||
ewin.SetText("Text Editor");
|
||||
ewin.SetAutohide(true);
|
||||
});
|
||||
|
||||
// when the user clicks "close" on a window there is a request to hide
|
||||
win.HideEvt += GUIQuitCb;
|
||||
|
||||
efl.ui.IBox box = new efl.ui.Box(win);
|
||||
eina.Size2D sz;
|
||||
sz.W = 360;
|
||||
sz.H = 240;
|
||||
box.SetHintMin(sz);
|
||||
// Create a window and initialize it
|
||||
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.Box box = new Efl.Ui.Box(win);
|
||||
win.SetContent(box);
|
||||
|
||||
// Create the toolbar and add it to the box
|
||||
GUIToolbarSetup(box);
|
||||
|
||||
editor = new efl.ui.Text(box);
|
||||
editor.SetFont("Mono", 14);
|
||||
editor.SetMultiline(true);
|
||||
editor.SetEditable(true);
|
||||
editor.SetScrollable(true);
|
||||
editor.SetScrollable(true);
|
||||
editor.ChangedEvt += EditorChangedCb;
|
||||
editor.ChangedUserEvt += EditorChangedCb;
|
||||
// Create the main text entry
|
||||
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);
|
||||
|
||||
box.DoPack(editor);
|
||||
}
|
||||
|
||||
~TextEditor()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
editor.Dispose();
|
||||
toolbarNew.Dispose();
|
||||
win.Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
// start main loop
|
||||
efl.ui.Config.Run();
|
||||
// Initial refresh of the toolbar buttons
|
||||
GUIToolbarRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
public class Example
|
||||
{
|
||||
#if WIN32
|
||||
[STAThreadAttribute()]
|
||||
#endif
|
||||
public static void Main()
|
||||
{
|
||||
efl.All.Init(efl.Components.Ui);
|
||||
|
||||
var textEditor = new TextEditor();
|
||||
textEditor.Run();
|
||||
|
||||
// dispose after quit
|
||||
textEditor.Dispose();
|
||||
|
||||
efl.All.Shutdown();
|
||||
TextEditor editor = new TextEditor();
|
||||
editor.Launch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
project('efl-examples',
|
||||
'c',
|
||||
version: '1.0'
|
||||
)
|
||||
|
||||
subprojects = $subprojects
|
||||
|
||||
foreach subp : subprojects
|
||||
subproject(subp)
|
||||
endforeach
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
deps = [efl_mono]
|
||||
|
||||
executable('efl_reference_net_io',
|
||||
files(['net_io.cs']),
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
||||
executable('efl_reference_net_io_buffered',
|
||||
files(['net_io_buffered.cs']),
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
||||
|
||||
executable('efl_reference_net_session',
|
||||
files(['net_session.cs']),
|
||||
dependencies : deps,
|
||||
cs_args : efl_mono_libs,
|
||||
install : true
|
||||
)
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* Efl.Net input/output examples.
|
||||
*
|
||||
* This example builds on the core_io example by connecting to a remote server
|
||||
* using a dialer and a command queue. The response is printed to stdout.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class ExampleRunner
|
||||
{
|
||||
private eina.List<efl.io.Copier> waiting = null;
|
||||
private eina.List<string> commands = null;
|
||||
private eina.Slice delimiter;
|
||||
private efl.net.dialer.Tcp dialer = null;
|
||||
private efl.io.Copier sender = null;
|
||||
private efl.io.Copier receiver = null;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
efl.ui.Config.Run();
|
||||
}
|
||||
|
||||
// call this method to cleanly shut down our example
|
||||
public void Quit()
|
||||
{
|
||||
if (waiting != null)
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: {0} operations were waiting!", waiting.Length);
|
||||
waiting.Dispose();
|
||||
waiting = null;
|
||||
}
|
||||
|
||||
if (receiver != null)
|
||||
{
|
||||
receiver.Close();
|
||||
receiver.GetDestination().Dispose();
|
||||
receiver.Dispose();
|
||||
receiver = null;
|
||||
}
|
||||
|
||||
if (sender)
|
||||
{
|
||||
sender.Close();
|
||||
sender.GetSource().Dispose();
|
||||
source.Dispose();
|
||||
}
|
||||
|
||||
if (dialer)
|
||||
dialer.Dispose();
|
||||
|
||||
// efl_exit(retval); // TODO missing
|
||||
efl.ui.Config.Exit();
|
||||
}
|
||||
|
||||
// iterate through the commands to send through the dialler
|
||||
public void CommandNext()
|
||||
{
|
||||
efl.io.Reader send_queue = sender.GetSource();
|
||||
if (commands != null)
|
||||
{
|
||||
send_queue.EosMark();
|
||||
return;
|
||||
}
|
||||
|
||||
string cmd = commands[0];
|
||||
// commands.RemoveAt(0); // TODO missing
|
||||
|
||||
eina.Slice slice;
|
||||
// slice = (Eina_Slice)EINA_SLICE_STR(cmd); // TODO missing
|
||||
send_queue.Write(slice, null);
|
||||
// Console.WriteLine("INFO: sent '{0}'", EINA_SLICE_STR_PRINT(slice)); // TODO missing
|
||||
|
||||
// don't use delimiter directly, 'Len' may be changed!
|
||||
slice = delimiter;
|
||||
send_queue.Write(slice, null);
|
||||
}
|
||||
|
||||
void ReceiverData(efl.io.Queue sender, EventArgs e)
|
||||
{
|
||||
eina.Slice slice = sender.GetSlice();
|
||||
|
||||
// Can be caused when we issue efl.io.Queue.Clear()
|
||||
if (slice.Len == 0) return;
|
||||
|
||||
// If the server didn't send us the line terminator and closed the
|
||||
// connection (ie: efl_io_reader_eos_get() == true) or if the buffer
|
||||
// limit was reached then we may have a line without a trailing delimiter.
|
||||
|
||||
// if (slice.EndsWith(delimiter)) // TODO missing
|
||||
// slice.Len -= delimiter.Len;
|
||||
|
||||
// Console.WriteLine("INFO: received '{0}'", EINA_SLICE_STR_PRINT(slice)); // TODO missing
|
||||
|
||||
sender.Clear();
|
||||
CommandNext();
|
||||
}
|
||||
|
||||
void DialerConnected(efl.net.dialer.Tcp sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("INFO: connected to {0} ({1})", sender.GetAddressDial(), sender.GetAddressRemote());
|
||||
|
||||
CommandNext();
|
||||
}
|
||||
|
||||
void CopierDone(efl.io.Copier sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("INFO: {0} done", sender.GetName());
|
||||
|
||||
// waiting.Remove(sender); // TODO missing
|
||||
if (waiting.Empty())
|
||||
Quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void CopierError(efl.io.Copier sender, eina.Error perr)
|
||||
{
|
||||
Console.Error.WriteLine(stderr, "INFO: {0} error: #{1} '{2}'", sender.GetName(), perr, perr.Message);
|
||||
|
||||
Quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
private static void SetCopierCbs(efl.io.Copier copier)
|
||||
{
|
||||
copier.DONE += CopierDone;
|
||||
copier.ERROR += CopierError;
|
||||
}
|
||||
|
||||
|
||||
public ExampleRunner()
|
||||
{
|
||||
string address = "example.com:80";
|
||||
ulong buffer_limit = 128;
|
||||
efl.io.Queue send_queue, receive_queue;
|
||||
|
||||
commands = new eina.List<string>();
|
||||
commands.Append("HEAD / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n");
|
||||
// delimiter = (Eina_Slice)EINA_SLICE_STR("\r\n"); // TODO missing
|
||||
|
||||
// Without a send_queue we'd have to manually implement an
|
||||
// efl.io.Reader object that would provide partial data when
|
||||
// efl.io.Reader.read() is called by efl.io.Copier. This is
|
||||
// cumbersome... we just want to write a full command and have the
|
||||
// queue to handle that for us.
|
||||
//
|
||||
// Our example's usage is to write each command at once followed by
|
||||
// the line delimiter, then wait for a reply from the server, then
|
||||
// write another.
|
||||
|
||||
try
|
||||
{
|
||||
send_queue = new efl.io.QueueConcrete(null, (efl.io.Queue equeue) => {
|
||||
equeue.SetName("send_queue");
|
||||
equeue.SetLimit(buffer_limit);
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create efl.io.Queue (send)");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
// Without a receive_queue we'd have to manually implement an
|
||||
// efl.io.Writer object that would handle write of partial data
|
||||
// with efl.io.Writer.write() is called by efl.io.Copier.
|
||||
//
|
||||
// For output we could have another solution as well: use null
|
||||
// destination and handle "line" or "data" events manually,
|
||||
// stealing the buffer so it doesn't grow.
|
||||
//
|
||||
// Our example's usage is to peek its data with GetSlice() then
|
||||
// Clear().
|
||||
try
|
||||
{
|
||||
receive_queue = new efl.io.QueueConcrete(null, (efl.io.Queue equeue) => {
|
||||
equeue.SetName("receive_queue");
|
||||
equeue.SetLimit(buffer_limit);
|
||||
});
|
||||
receive_queue.SLICE_CHANGED += ReceiverData;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create efl.io.Queue (receive)");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
// some objects such as the Efl.Io.Copier and Efl.Net.Dialer.Tcp
|
||||
// depend on main loop, thus their parent must be a loop
|
||||
// provider. We use the loop passed to our main method.
|
||||
// efl.Loop loop = ev->object; // TODO missing
|
||||
|
||||
// The TCP client to use to send/receive network data
|
||||
try
|
||||
{
|
||||
dialer = new efl.net.dialer.TcpConcrete(loop, (efl.net.dialer.Tcp edialer) => {
|
||||
edialer.SetName("dialer");
|
||||
});
|
||||
dialer.CONNECTED += DialerConnected;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create efl.net.dialer.Tcp");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
// sender: send_queue->network
|
||||
try
|
||||
{
|
||||
sender = new efl.io.CopierConcrete(loop, (efl.io.Copier esender) => {
|
||||
esender.SetName("sender");
|
||||
esender.SetLineDelimiter(delimiter);
|
||||
esender.SetSource(send_queue);
|
||||
esender.SetDestination(dialer);
|
||||
});
|
||||
SetCopierCbs(sender);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create efl.io.Copier (sender)");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
// receiver: network->receive_queue
|
||||
try
|
||||
{
|
||||
receiver = new efl.io.CopierConcrete(loop, (efl.io.Copier ereceiver) => {
|
||||
ereceiver.SetName("receiver");
|
||||
ereceiver.SetLineDelimiter(delimiter);
|
||||
ereceiver.SetSource(dialer);
|
||||
ereceiver.SetDestination(send_queue);
|
||||
});
|
||||
SetCopierCbs(receiver);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create Efl_Io_Copier (receiver)");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
eina.Error err = dialer.Dial(address);
|
||||
if (err != eina.Error.NO_ERROR)
|
||||
{
|
||||
var msg = $"ERROR: could not dial {address}: {err.Message}";
|
||||
Console.Error.WriteLine(msg);
|
||||
Quit(EXIT_FAILURE);
|
||||
throw new SEHException(msg);
|
||||
}
|
||||
|
||||
waiting.Append(sender);
|
||||
waiting.Append(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Example
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
efl.All.Init(efl.Components.Basic);
|
||||
|
||||
var exr = new ExampleRunner();
|
||||
exr.Run();
|
||||
|
||||
efl.All.Shutdown();
|
||||
}
|
||||
}
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* Efl.Net buffered input/output examples.
|
||||
*
|
||||
* This example builds on the net_io example by using a buffered_stream to
|
||||
* simplify the logic. This helpfully provides the input and output queues
|
||||
* and a copier internally. They can be accessed from the buffered stream
|
||||
* if required but as demonstrated here that is likely not necessary.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class ExampleRunner
|
||||
{
|
||||
private eina.List<string> commands = null;
|
||||
private eina.Slice delimiter;
|
||||
private efl.net.dialer.Tcp dialer = null;
|
||||
private efl.io.buffered.Stream stream = null;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
efl.ui.Config.Run();
|
||||
}
|
||||
|
||||
public void Quit(int retval)
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
stream.Close();
|
||||
stream.Dispose();
|
||||
stream = null;
|
||||
}
|
||||
|
||||
if (dialer != null)
|
||||
{
|
||||
dialer.Dispose();
|
||||
dialer = null;
|
||||
}
|
||||
|
||||
// efl_exit(retval); TODO missing
|
||||
efl.ui.Config.Exit();
|
||||
}
|
||||
|
||||
public void CommandNext()
|
||||
{
|
||||
if (commands.Empty())
|
||||
{
|
||||
stream.EosMark();
|
||||
return;
|
||||
}
|
||||
|
||||
string cmd = commands[0];
|
||||
// commands.RemoveAt(0); // TODO missing
|
||||
|
||||
// eina.Slice slice = (Eina_Slice)EINA_SLICE_STR(cmd); // TODO missing
|
||||
stream.Write(slice, null);
|
||||
// Console.Error.WriteLine("INFO: sent '{0}'", EINA_SLICE_STR_PRINT(slice)); // TODO missing
|
||||
|
||||
// don't use delimiter directly, 'Len' may be changed!
|
||||
slice = delimiter;
|
||||
stream.Write(slice, null);
|
||||
}
|
||||
|
||||
void StreamLine(efl.io.buffered.Stream sender, EventArgs e)
|
||||
{
|
||||
eina.Slice slice = sender.GetSlice();
|
||||
|
||||
// Can be caused when we issue efl.io.buffered.Stream.Clear()
|
||||
if (slice.Len == 0) return;
|
||||
|
||||
// If the server didn't send us the line terminator and closed the
|
||||
// connection (ie: efl_io_reader_eos_get() == true) or if the buffer
|
||||
// limit was reached then we may have a line without a trailing delimiter.
|
||||
// if (slice.EndsWith(delimiter)) // TODO missing
|
||||
// slice.Len -= delimiter.Len;
|
||||
|
||||
// Console.WriteLine("INFO: received '{0}'", EINA_SLICE_STR_PRINT(slice)); // TODO missing
|
||||
|
||||
sender.Clear();
|
||||
CommandNext();
|
||||
}
|
||||
|
||||
void DialerConnected(efl.net.dialer.Tcp sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("INFO: connected to {0} ({1})", sender.GetAddressDial(), sender.GetAddressRemote());
|
||||
|
||||
CommandNext();
|
||||
}
|
||||
|
||||
void StreamDone(efl.io.buffered.Stream sender, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("INFO: {0} done", sender.GetName());
|
||||
|
||||
Quit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void StreamError(efl.io.buffered.Stream sender, eina.Error err)
|
||||
{
|
||||
Console.Error.WriteLine("INFO: {0} error: #{1} '{2}'", sender;GetName(), err, err.Message);
|
||||
|
||||
Quit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
private static void SetStreamCbs(efl.io.buffered.Stream s)
|
||||
{
|
||||
s.LINE += StreamLine;
|
||||
s.EOS += StreamDone;
|
||||
s.ERROR += StreamError;
|
||||
}
|
||||
|
||||
public ExampleRunner()
|
||||
{
|
||||
string address = "example.com:80";
|
||||
ulong bufferLimit = 128;
|
||||
|
||||
commands = new eina.List<string>();
|
||||
commands.Append("HEAD / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n");
|
||||
// delimiter = (Eina_Slice)EINA_SLICE_STR("\r\n"); // TODO missing
|
||||
|
||||
// some objects such as the Efl.Io.Copier and Efl.Net.Dialer.Tcp
|
||||
// depend on main loop, thus their parent must be a loop
|
||||
// provider. We use the loop passed to our main method.
|
||||
// efl.Loop loop = ev->object; // TODO missing
|
||||
|
||||
// The TCP client to use to send/receive network data
|
||||
try
|
||||
{
|
||||
dialer = new efl.net.dialer.TcpConcrete(loop, (efl.net.dialer.Tcp edialer) => {
|
||||
edialer.SetName("dialer");
|
||||
});
|
||||
dialer.CONNECTED += DialerConnected;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("ERROR: could not create efl.net.dialer.Tcp");
|
||||
Quit(EXIT_FAILURE);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
// Without the buffered stream we'd have to create two Efl.Io.Queue
|
||||
// ourselves, as well as two Efl.Io.Copier to link them with the
|
||||
// dialer.
|
||||
//
|
||||
// Our example's usage is to write each command at once followed by
|
||||
// the line delimiter, then wait for a reply from the server, then
|
||||
// write another.
|
||||
//
|
||||
// On incoming data we peek at it with GetSlice() and then Clear().
|
||||
|
||||
stream = new efl.io.buffered.StreamConcrete(loop, (efl.io.buffered.Stream estream) => {
|
||||
estream.SetName("stream");
|
||||
estream.SetInnerIo(dialer);
|
||||
estream.SetDelimiter(delimiter);
|
||||
estream.SetMaxQueueSizeInput(bufferLimit);
|
||||
estream.SetMaxQueueSizeOutput(bufferLimit);
|
||||
});
|
||||
SetStreamCbs(stream);
|
||||
|
||||
eina.Error err = dialer.Dial(address);
|
||||
if (err != eina.Error.NO_ERROR)
|
||||
{
|
||||
var msg = $"ERROR: could not dial {address}: {err.Message}";
|
||||
Console.Error.WriteLine(msg);
|
||||
Quit(EXIT_FAILURE);
|
||||
throw new SEHException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Example
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
efl.All.Init(efl.Components.Basic);
|
||||
|
||||
var exr = new ExampleRunner();
|
||||
exr.Run();
|
||||
|
||||
efl.All.Shutdown();
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* Efl.Net session/connectivity examples.
|
||||
*
|
||||
* NOTE: This example currently requires the Connman backend to be running.
|
||||
*
|
||||
* This example uses the Efl.Net.Session APIs to get connectivity information
|
||||
* about the current networking setup. It then sets up a callback for network
|
||||
* changes and will print the details on any change.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
public class Example
|
||||
{
|
||||
// Convert a session state to a string for printing.
|
||||
public static string StateName(efl.net.session.State state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case efl.net.session.State.Offline:
|
||||
return "offline";
|
||||
case efl.net.session.State.Local:
|
||||
return "local";
|
||||
case efl.net.session.State.Online:
|
||||
return "online";
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<efl.net.session.Technology, string> names =
|
||||
new Dictionary<efl.net.session.Technology, string> {
|
||||
{ efl.net.session.Technology.Unknown, "unknown" },
|
||||
{ efl.net.session.Technology.Ethernet, "ethernet" },
|
||||
{ efl.net.session.Technology.Wifi, "wifi" },
|
||||
{ efl.net.session.Technology.Bluetooth, "bluetooth" },
|
||||
{ efl.net.session.Technology.Cellular, "cellular" },
|
||||
{ efl.net.session.Technology.Vpn, "vpn" },
|
||||
{ efl.net.session.Technology.Gadget, "gadget" }
|
||||
};
|
||||
|
||||
// Convert a session technology to a string for printing.
|
||||
public static string TechnologyName(efl.net.session.Technology tech)
|
||||
{
|
||||
string name;
|
||||
if (!names.TryGetValue(tech, out name))
|
||||
return "???";
|
||||
return name;
|
||||
}
|
||||
|
||||
// Tthe callback that indicates some connectivity changed within the session.
|
||||
// Print information about the session to the console.
|
||||
static void SessionChanged(efl.net.Session session, EventArgs e)
|
||||
{
|
||||
Console.WriteLine("Session changed:");
|
||||
Console.WriteLine(" name: '{0}'", session.GetName());
|
||||
Console.WriteLine(" state: {0}", StateName(session.GetState()));
|
||||
Console.WriteLine(" technology: {0}", TechnologyName(session.GetTechnology()));
|
||||
Console.WriteLine(" interface: '{0}'", session.GetInterface());
|
||||
|
||||
// print out additional information if we have an IPv4 session
|
||||
string ip, netmask, gateway;
|
||||
session.GetIpv4(out ip, out netmask, out gateway);
|
||||
if (ip != null)
|
||||
{
|
||||
Console.WriteLine($" IPv4: {ip}, gateway={gateway}, netmask={netmask}");
|
||||
}
|
||||
|
||||
// print out additional information if we have an IPv6 session
|
||||
byte prefix;
|
||||
session.GetIpv6(out ip, out prefix, out netmask, out gateway);
|
||||
if (ip != null)
|
||||
{
|
||||
Console.WriteLine($" IPv6: {ip}/{prefix}, gateway={gateway}, netmask={netmask}");
|
||||
}
|
||||
}
|
||||
|
||||
// Quit the app after a timer tick.
|
||||
static void QuitCb(object sender, EventArgs e)
|
||||
{
|
||||
// efl_exit(0); // TODO missing
|
||||
efl.ui.Config.Exit();
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
bool doConnect = true;
|
||||
bool requireOnline = false;
|
||||
|
||||
efl.All.Init(efl.Components.Basic);
|
||||
|
||||
// efl.Loop loop = ev->object; // TODO missing
|
||||
|
||||
// create a session that watches specifically for ethernet, wifi and bluetooth
|
||||
int technologies = efl.net.session.Technology.Ethernet |
|
||||
efl.net.session.Technology.Wifi | efl.net.session.Technology.Bluetooth;
|
||||
|
||||
try
|
||||
{
|
||||
efl.net.Session session = new efl.net.SessionConcrete(loop, (efl.net.Session esession) => {
|
||||
esession.SetName("Example Session");
|
||||
// register the change callback for network state
|
||||
esession.CHANGED += SessionChanged;
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
eina.Log.Error("Could not create Efl.Net.Session object.\n");
|
||||
// efl_exit(EXIT_FAILURE); // TODO missing
|
||||
efl.ui.Config.Exit();
|
||||
throw;
|
||||
}
|
||||
|
||||
if (doConnect)
|
||||
{
|
||||
Console.WriteLine("Requesting a {0} connection.", requireOnline ? "online" : "local");
|
||||
session.Connect(requireOnline, technologies);
|
||||
}
|
||||
|
||||
Console.WriteLine("The session will remain active while this application runs.");
|
||||
Console.WriteLine("Use ^C (Control + C) to close it");
|
||||
|
||||
// Wait for 10 seconds before exiting this example
|
||||
new efl.loop.TimerConcrete(loop, (efl.loop.Timer etimer) => {
|
||||
etimer.SetInterval(10.0);
|
||||
etimer.TICK += QuitCb;
|
||||
});
|
||||
|
||||
// start the main loop
|
||||
efl.ui.Config.Run();
|
||||
|
||||
efl.All.Shutdown();
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
};
|
|
@ -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();
|
|
@ -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);
|
|
@ -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";
|
||||
};
|
|
@ -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");
|
||||
};
|
|
@ -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);
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
Efl.Ui.Image image = new Efl.Ui.Image(parent);
|
||||
|
||||
image.SetFile(image_path + "icon.png");
|
||||
image.Load();
|
|
@ -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);
|
|
@ -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;
|
|
@ -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);
|
||||
};
|
|
@ -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);
|
|
@ -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());
|
||||
};
|
|
@ -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);
|
||||
};
|
|
@ -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);
|
|
@ -0,0 +1,3 @@
|
|||
var win = new Efl.Ui.Win(Efl.App.AppMain);
|
||||
win.FocusHighlightEnabled = true;
|
||||
|
|
@ -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) => { };
|
|
@ -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: \"
|
|
@ -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')
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/python3
|
||||
import os
|
||||
import subprocess
|
||||
from string import Template
|
||||
|
||||
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
|
||||
self.path = path
|
||||
|
||||
def verify(self):
|
||||
assert os.path.isdir(self.path)
|
||||
assert os.path.isfile(os.path.join(self.path, 'meson.build'))
|
||||
|
||||
def flush(self):
|
||||
os.symlink(os.path.join('..', self.path), os.path.realpath(os.path.join('subprojects', self.link_file_name())))
|
||||
|
||||
def link_file_name(self):
|
||||
return self.language+'-'+os.path.basename(self.path)
|
||||
|
||||
for directory in directories:
|
||||
for lang in supported_languages:
|
||||
explore_dir = os.path.join(directory, lang)
|
||||
if os.path.isdir(explore_dir):
|
||||
meson_build_file = os.path.join(explore_dir, "meson.build")
|
||||
if os.path.isfile(meson_build_file):
|
||||
goals.append(SubProjectGoal(lang, explore_dir))
|
||||
else:
|
||||
for content in os.listdir(explore_dir):
|
||||
sub = os.path.join(explore_dir, content)
|
||||
if os.path.isdir(sub):
|
||||
goals.append(SubProjectGoal(lang, sub))
|
||||
|
||||
if not os.path.isdir('./subprojects'):
|
||||
os.mkdir('./subprojects')
|
||||
else:
|
||||
for content in os.listdir('./subprojects'):
|
||||
os.unlink(os.path.join('subprojects', content))
|
||||
|
||||
for subproject in goals:
|
||||
subproject.verify()
|
||||
subproject.flush()
|
||||
subprojects.append(subproject.link_file_name())
|
||||
|
||||
content = { 'subprojects' : '[\''+'\',\''.join(subprojects)+'\']'}
|
||||
|
||||
meson_in = open('meson.build.in')
|
||||
meson_temp = Template(meson_in.read())
|
||||
content = meson_temp.substitute(content)
|
||||
|
||||
if os.path.isfile('meson.build'):
|
||||
os.unlink('meson.build')
|
||||
|
||||
meson_out = open('meson.build', 'a')
|
||||
meson_out.write(content)
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <Eina.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Example.Rectangle (Efl.Object) {
|
||||
class Example.Rectangle extends Efl.Object {
|
||||
methods {
|
||||
@property width {
|
||||
set {
|
||||
|
|
|
@ -8,7 +8,7 @@ foreach eo : eo_src
|
|||
eo_file = eo + '.eo'
|
||||
eo_csrc += eo + '.c'
|
||||
|
||||
eo_gen += custom_target('eolian_gen_' + eo_file,
|
||||
eo_gen += custom_target('eolian_gen_eo_classes' + eo_file,
|
||||
input : eo_file,
|
||||
output : [eo_file + '.h'],
|
||||
command : [eolian_gen, '-I', meson.current_source_dir(),
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <Eina.h>
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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;}
|
||||
|
|
|
@ -8,7 +8,7 @@ foreach eo : eo_src
|
|||
eo_file = eo + '.eo'
|
||||
eo_csrc += eo + '.c'
|
||||
|
||||
eo_gen += custom_target('eolian_gen_' + eo_file,
|
||||
eo_gen += custom_target('eolian_gen_eo_inherit' + eo_file,
|
||||
input : eo_file,
|
||||
output : [eo_file + '.h'],
|
||||
command : [eolian_gen, '-I', meson.current_source_dir(),
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define EFL_EO_API_SUPPORT 1
|
||||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <Eina.h>
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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.]]
|
||||
|
|
|
@ -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;}
|
||||
|
|
|
@ -9,7 +9,7 @@ foreach eo : eo_src
|
|||
eo_file = eo + '.eo'
|
||||
eo_csrc += eo + '.c'
|
||||
|
||||
eo_gen += custom_target('eolian_gen_' + eo_file,
|
||||
eo_gen += custom_target('eolian_gen_eo_multiinherit' + eo_file,
|
||||
input : eo_file,
|
||||
output : [eo_file + '.h'],
|
||||
command : [eolian_gen, '-I', meson.current_source_dir(),
|
||||
|
|
|
@ -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);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue