Compare commits

..

1 Commits

Author SHA1 Message Date
Marcel Hollerbach 0cdc2deae9 csharp: update API
loop_main has been renamed to app_main.
2018-12-20 16:28:15 +01:00
169 changed files with 935 additions and 1963 deletions

View File

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

3
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

View File

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

View File

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

View File

@ -1,5 +1,7 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Elementary.h>
#include <Efl_Ui.h>
#include "life_private.h"
@ -65,7 +67,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_TIMER_TICK, _life_tick, win);
efl_event_callback_add(_life_timer, EFL_LOOP_TIMER_EVENT_TICK, _life_tick, win);
}
int

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,9 +60,11 @@ public class LifeBoard
public void Run(Efl.Ui.Win win)
{
lifeTimer = new Efl.LoopTimer(win, 0.1);
lifeTimer = new Efl.LoopTimer(win, (Efl.LoopTimer etimer) => {
etimer.SetInterval(0.1);
});
lifeTimer.TimerTickEvent += (object sender, EventArgs ev) => {
lifeTimer.TickEvt += (object sender, EventArgs ev) => {
Nextgen();
if (this.lifeRender != null)
this.lifeRender.Refresh(win);
@ -143,7 +145,8 @@ public class LifeBoard
{
if (lifeTimer != null)
{
lifeTimer.Del();
lifeTimer.SetParent(null);
lifeTimer.Dispose();
lifeTimer = null;
}
else

View File

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

View File

@ -21,7 +21,7 @@ public class LifeRender
public void CellForCoords(Efl.Ui.Win win, Eina.Position2D coord, out int x, out int y)
{
Eina.Size2D size = win.Size;
Eina.Size2D size = win.GetSize();
x = coord.X * LifeBoard.Width / size.W;
y = coord.Y * LifeBoard.Height / size.H;
@ -29,7 +29,7 @@ public class LifeRender
public void RenderLayout(Efl.Ui.Win win)
{
Eina.Size2D size = win.Size;
Eina.Size2D size = win.GetSize();
double cw = (double) size.W / LifeBoard.Width;
double ch = (double) size.H / LifeBoard.Height;
@ -39,9 +39,15 @@ public class LifeRender
var rect = lifeCells[LifeBoard.IndexForPosition(x, y)];
// the little +1 here will avoid tearing as we layout non-multiple sizes
rect.Size = new Eina.Size2D((int)(cw + 1), (int)(ch + 1));
Eina.Size2D sz;
sz.W = (int)(cw + 1);
sz.H = (int)(ch + 1);
rect.SetSize(sz);
rect.Position = new Eina.Position2D((int)(x * cw), (int)(y * ch));
Eina.Position2D pos;
pos.X = (int)(x * cw);
pos.Y = (int)(y * ch);
rect.SetPosition(pos);
}
}
@ -51,9 +57,9 @@ public class LifeRender
var rect = lifeCells[i];
if (lifeBoard.Cells[i])
rect.Color = (0, 0, 0, 255);
rect.SetColor(0, 0, 0, 255);
else
rect.Color = (255, 255, 255, 255);
rect.SetColor(255, 255, 255, 255);
}
public void Refresh(Efl.Ui.Win win)

View File

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

View File

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

View File

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

View File

@ -17,36 +17,35 @@
using System;
public class TextEditor : Efl.Csharp.Application
public class TextEditor
{
private Efl.Ui.Win win; // The main window
private Efl.Ui.Textbox editorTextBox; // The main text entry
private Efl.Ui.Text editorTextBox; // The main text entry
private Efl.Ui.Button toolbarButtonNew; // The "New" button in the toolbar
private Efl.Ui.Button toolbarButtonSave; // The "Save" button in the toolbar
private Efl.Ui.Button toolbarButtonLoad; // The "Load" button in the toolbar
private bool edited = false; // Document was edited since last save
private bool edited = false; // Document was edited since last save
// File to load and save is fixed since we do not use a file selection dialog
private readonly string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(),
"texteditor_example.txt");
// Quits the application
private void GUIQuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ea)
private void GUIQuitCb(object sender, EventArgs ea)
{
if (ea.Arg == false)
Efl.App.AppMain.Quit(0);
Efl.Ui.Config.Exit();
}
// 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);
toolbarButtonNew.SetDisabled(string.IsNullOrEmpty(editorTextBox.GetText()));
// "Save" is enabled if the text has been modified since last save or load
toolbarButtonSave.Disabled = !edited;
toolbarButtonSave.SetDisabled(!edited);
// "Load" is enabled if there is a file to load
toolbarButtonLoad.Disabled = !System.IO.File.Exists(filename);
toolbarButtonLoad.SetDisabled(!System.IO.File.Exists(filename));
}
// Called when the text in the editor has changed
@ -59,61 +58,65 @@ public class TextEditor : Efl.Csharp.Application
// Shows a modal message popup with an "OK" button
private void ShowMessage(string message)
{
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();
};
new Efl.Ui.TextAlertPopup (win, (Efl.Ui.TextAlertPopup epopup) => {
epopup.SetText(message);
epopup.SetExpandable(new Eina.Size2D(200,200));
epopup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null);
epopup.ButtonClickedEvt +=
(object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args ea) => {
// Dismiss popup when the button is clicked
((Efl.Ui.TextAlertPopup)sender).SetParent(null);
};
});
}
// 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)
string iconName, EventHandler func)
{
var button = new Efl.Ui.Button(toolbar);
button.Text = name;
button.ClickedEvent += func;
button.HintWeight = (0, 1);
return new Efl.Ui.Button(toolbar, (Efl.Ui.Button ebutton) => {
ebutton.SetText(name);
ebutton.ClickedEvt += func;
ebutton.SetHintWeight(0, 1);
toolbar.DoPack(ebutton);
// 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;
// Set the content of the button
ebutton.SetContent(
// Which is an image
new Efl.Ui.Image(toolbar, (Efl.Ui.Image eimage) => {
eimage.SetIcon(iconName);
})
);
});
}
// Creates a new toolbar, with all its buttons
private void GUIToolbarSetup(Efl.Ui.Box parent)
{
// 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);
Efl.Ui.Box bar = new Efl.Ui.Box(parent, (Efl.Ui.Box ebox) => {
// 0 vertical weight means that the toolbar will have the minimum height
// to accommodate all its buttons and not a pixel more. The rest of the
// space will be given to the other object in the parent container.
ebox.SetHintWeight(1, 0);
ebox.SetDirection(Efl.Ui.Dir.Horizontal);
parent.DoPack(ebox);
});
// "New" button
toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new",
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
(object sender, EventArgs ea) => {
// When this button is clicked, remove content and refresh toolbar
editorTextBox.Text = "";
editorTextBox.SetText("");
GUIToolbarRefresh();
});
// "Save" button
toolbarButtonSave = GUIToolbarButtonAdd(bar, "Save", "document-save",
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
(object sender, EventArgs ea) => {
// When this button is clicked, try to save content and refresh toolbar
try {
System.IO.File.WriteAllText(filename, editorTextBox.Text);
System.IO.File.WriteAllText(filename, editorTextBox.GetText());
edited = false;
GUIToolbarRefresh();
ShowMessage("Saved!");
@ -125,10 +128,10 @@ public class TextEditor : Efl.Csharp.Application
// "Load" button
toolbarButtonLoad = GUIToolbarButtonAdd(bar, "Load", "document-open",
(object sender, Efl.Input.ClickableClickedEventArgs ea) => {
(object sender, EventArgs ea) => {
// When this button is clicked, try to load content and refresh toolbar
try {
editorTextBox.Text = System.IO.File.ReadAllText(filename);
editorTextBox.SetText(System.IO.File.ReadAllText(filename));
edited = false;
GUIToolbarRefresh();
ShowMessage("Loaded!");
@ -144,20 +147,21 @@ public class TextEditor : Efl.Csharp.Application
// 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);
bar.DoPack(box);
// "Quit" button
GUIToolbarButtonAdd(bar, "Quit", "application-exit", (object sender, Efl.Input.ClickableClickedEventArgs e) => { Efl.Ui.Config.Exit(); } );
GUIToolbarButtonAdd(bar, "Quit", "application-exit", GUIQuitCb);
}
// Builds the user interface for the text editor
protected override void OnInitialize(string[] args)
public TextEditor()
{
// 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;
win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => {
ewin.SetText("Text Editor");
ewin.SetAutohide(true);
ewin.HideEvt += GUIQuitCb;
});
// Create a vertical box container
Efl.Ui.Box box = new Efl.Ui.Box(win);
@ -167,20 +171,27 @@ public class TextEditor : Efl.Csharp.Application
GUIToolbarSetup(box);
// 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);
editorTextBox = new Efl.Ui.Text(box, (Efl.Ui.Text etext) => {
etext.SetFont("Mono", 14);
etext.SetMultiline(true);
etext.SetEditable(true);
etext.SetScrollable(true);
etext.SetHintMin(new Eina.Size2D(360, 240));
etext.ChangedEvt += EditorChangedCb;
etext.ChangedUserEvt += EditorChangedCb;
box.DoPack(etext);
});
// Initial refresh of the toolbar buttons
GUIToolbarRefresh();
}
// This method won't return until the application quits
public void Run()
{
// Start the EFL main loop
Efl.Ui.Config.Run();
}
}
public class Example
@ -190,8 +201,14 @@ public class Example
#endif
public static void Main()
{
TextEditor editor = new TextEditor();
editor.Launch();
// Initialize EFL and all UI components
Efl.All.Init(Efl.Components.Ui);
var textEditor = new TextEditor();
textEditor.Run();
// Shutdown EFL
Efl.All.Shutdown();
}
}

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -68,7 +69,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_TIMER_TICK, _freezethaw_cb, mainloop));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _freezethaw_cb, mainloop));
}
static void
@ -89,7 +90,7 @@ _timer_cb(void *data EINA_UNUSED, const Efl_Event *event)
}
EFL_CALLBACKS_ARRAY_DEFINE(_callback_array,
{ EFL_LOOP_TIMER_EVENT_TIMER_TICK, _timer_cb },
{ EFL_LOOP_TIMER_EVENT_TICK, _timer_cb },
{ EFL_EVENT_DEL, _del_obj_cb })
static void

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -59,7 +60,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_TIMER_TICK, _timer_cb, NULL));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
}
EFL_MAIN()

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -21,7 +22,7 @@ _io_write(const char *filename)
Efl_Io_File *file;
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename), // mandatory
efl_file_set(efl_added, filename, NULL), // 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
@ -50,7 +51,7 @@ _io_read(const char *filename)
Efl_Io_File *file;
file = efl_new(EFL_IO_FILE_CLASS,
efl_file_set(efl_added, filename), // mandatory
efl_file_set(efl_added, filename, NULL), // mandatory
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE)); // recommended
if (!file)

View File

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

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -63,7 +64,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_TIMER_TICK, _timer_cb, NULL));
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
}
EFL_MAIN()

View File

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

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -102,7 +103,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_TIMER_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
_test1_resolve, promise));
}
@ -153,7 +154,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_TIMER_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
_test2_reject, promise));
}
@ -277,7 +278,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_TIMER_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
_test4_resolve, promise));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -196,7 +197,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_DIALER_CONNECTED, _dialer_connected, NULL));
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL));
if (!_dialer)
{
fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n");

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -137,7 +138,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_DIALER_CONNECTED, _dialer_connected, NULL));
efl_event_callback_add(efl_added, EFL_NET_DIALER_EVENT_CONNECTED, _dialer_connected, NULL));
if (!_dialer)
{
fprintf(stderr, "ERROR: could not create Efl_Net_Dialer_Tcp\n");

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -133,7 +134,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_TIMER_TICK,
efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK,
_quit_cb, NULL));
}
EFL_MAIN()

View File

@ -1,5 +1,7 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
@ -29,7 +31,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_TYPE_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_event_callback_add(efl_added,
EFL_UI_WIN_EVENT_DELETE_REQUEST,
@ -38,9 +40,9 @@ _gui_setup()
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_add(EFL_UI_TEXTBOX_CLASS, box,
efl_add(EFL_UI_TEXT_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,
@ -48,8 +50,8 @@ _gui_setup()
efl_pack(box, efl_added));
hbox = efl_add(EFL_UI_BOX_CLASS, box,
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
efl_gfx_hint_weight_set(efl_added, 1.0, 0.1),
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added));
about = efl_add(EFL_UI_BUTTON_CLASS, hbox,
@ -57,7 +59,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_INPUT_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_about_clicked_cb, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, hbox,
@ -65,10 +67,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_INPUT_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
efl_ui_focus_util_focus(about);
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about);
}
EAPI_MAIN void

View File

@ -1,10 +1,12 @@
#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 examples.
* Efl.UI container exmaples.
*
* Load and pack a selection of containers.
* Each has it's own unique layout and methods which are demonstrated below.
@ -15,6 +17,7 @@
* 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
@ -34,7 +37,7 @@ _ui_table_setup(Efl_Ui_Win *win)
table = efl_add(EFL_UI_TABLE_CLASS, win);
efl_pack_table_columns_set(table, 2);
efl_ui_layout_orientation_set(table, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
efl_pack_table_direction_set(table, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN);
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_text_set(efl_added, "Long Button"),
@ -59,7 +62,7 @@ _ui_boxes_setup(Efl_Ui_Win *win)
int i;
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_gfx_arrangement_content_padding_set(efl_added, 5, 0));
efl_pack_padding_set(efl_added, 5, 0, EINA_TRUE));
for (i = 1; i <= 4; i++)
{
@ -68,7 +71,7 @@ _ui_boxes_setup(Efl_Ui_Win *win)
efl_pack(box, efl_added));
if (i == 2)
efl_gfx_hint_size_max_set(button, EINA_SIZE2D(100, 50));
efl_gfx_size_hint_max_set(button, EINA_SIZE2D(100, 50));
}
return box;
@ -87,15 +90,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_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
efl_ui_direction_set(efl_added, EFL_UI_DIR_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_hint_size_max_set(efl_added, EINA_SIZE2D(150, 30)),
efl_gfx_size_hint_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_INPUT_EVENT_CLICKED,
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_cb, efl_added));
}
@ -105,7 +108,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_TYPE_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Hello World"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -27,7 +28,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_TYPE_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Size Control"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -44,12 +45,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_hint_size_max_set(efl_added, EINA_SIZE2D(50, 50)));
efl_gfx_size_hint_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_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)));
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)));
efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));
}

View File

@ -1,3 +1,4 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <stdio.h>
@ -33,7 +34,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_TYPE_BASIC),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
efl_text_set(efl_added, "Translations"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
@ -44,18 +45,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_l10n_text_set(efl_added, "Translations", _TEXT_DOMAIN),
efl_ui_translatable_text_set(efl_added, "Translations", _TEXT_DOMAIN),
efl_pack_end(box, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_ui_l10n_text_set(efl_added, "Help", _TEXT_DOMAIN),
efl_ui_translatable_text_set(efl_added, "Help", _TEXT_DOMAIN),
efl_pack_end(box, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, win,
efl_ui_l10n_text_set(efl_added, "Quit", _TEXT_DOMAIN),
efl_ui_translatable_text_set(efl_added, "Quit", _TEXT_DOMAIN),
efl_pack_end(box, efl_added),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_cb, efl_added));
efl_gfx_entity_size_set(win, EINA_SIZE2D(320, 320));

View File

@ -7,55 +7,12 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
// Polling callback
private static void PollCb(object sender, EventArgs e)
{
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");
Console.WriteLine(" Poll from {0}", ((Efl.Object)sender).GetName());
}
#if WIN32
@ -63,8 +20,54 @@ public class Example : Efl.Csharp.Application
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
// Initialize EFL and all UI components
Efl.All.Init();
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
mainloop.SetName("Mainloop");
// This event gets triggered continuously
mainloop.PollHighEvt += PollCb;
// This timer will control events fired by the main loop
new Efl.LoopTimer(mainloop, (Efl.LoopTimer 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.Object)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");
}
}

View File

@ -9,38 +9,44 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
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()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
// Initialize EFL and all UI components
Efl.All.Init();
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
// 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.LoopTimer(mainloop, (Efl.LoopTimer 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();
}
}

View File

@ -8,38 +8,44 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
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()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
// Initialize EFL and all UI components
Efl.All.Init();
// Retrieve the application's main loop
var mainloop = Efl.App.AppMain;
// 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.LoopTimer(mainloop, (Efl.LoopTimer 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();
}
}

View File

@ -1,18 +1,18 @@
/*
* Eina.Array examples.
* Eina Array examples.
*
* These examples demonstrate how to work with Eina.Array data and methods.
* We use a simple array of strings to initialise our Eina.Array before
* These examples demonstrate how to work with Eina_array data and methods.
* We use a simple array of strings to initialise our Eina_array before
* performing various mutations and printing the results.
*/
using System;
public class Example : Efl.Csharp.Application
public class Example
{
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,7 +21,7 @@ public class Example : Efl.Csharp.Application
"skulls", "bulldog", "flat top", "hammerhead", "gonzo"
};
// Set up an array with a growth step to give a little headroom
// 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)
@ -32,51 +32,44 @@ public class Example : Efl.Csharp.Application
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;
}
protected override void OnInitialize(string[] args)
public static void Main()
{
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.Count);
// print the new contents of our array
Console.WriteLine("New array count: {0}", array.Length);
Console.WriteLine("New array contents:");
foreach(string name in array)
Console.WriteLine(" {0}", name);
array.Dispose();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

@ -1,7 +1,7 @@
/*
* Eina.Hash examples.
* Eina Hash examples.
*
* These examples demonstrate how to work with Eina.Hash data and methods.
* These examples demonstrate how to work with Eina_hash data and methods.
*
* We have two main hash objects here, firstly an int keyed hash with some
* dummy content.
@ -12,11 +12,11 @@
using System;
using System.Collections.Generic;
public class Example : Efl.Csharp.Application
public class Example
{
static Eina.Hash<Int32, string> CreateHash()
{
// Let's create a simple hash with integers as keys
// let's create a simple hash with integers as keys
var hash = new Eina.Hash<Int32, string>();
// Add initial entries to our hash
@ -30,13 +30,13 @@ public class Example : Efl.Csharp.Application
{
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,7 +46,7 @@ public class Example : Efl.Csharp.Application
hash.Dispose();
}
// Here we begin the phone book example
// here we begin the phone book example
static void PrintPhonebookEntry(string key, string data)
{
@ -58,7 +58,7 @@ public class Example : Efl.Csharp.Application
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);
@ -78,7 +78,7 @@ public class Example : Efl.Csharp.Application
"+23 45 678-91012", "+34 56 789-10123"
};
// Create hash of strings to strings
// create hash of strings to strings
var hash = new Eina.Hash<string, string>();
// Add initial entries to our hash
@ -117,20 +117,13 @@ public class Example : Efl.Csharp.Application
phone_book.Dispose();
}
protected override void OnInitialize(string[] args)
public static void Main()
{
Efl.All.Init();
HashDemo();
PhonebookDemo();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

@ -1,16 +1,16 @@
/*
* 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 : Efl.Csharp.Application
public class Example
{
static void PrintIterator(Eina.Iterator<string> it)
{
@ -55,31 +55,24 @@ public class Example : Efl.Csharp.Application
return list;
}
protected override void OnInitialize(string[] args)
public static void Main()
{
// Create an Eina.Array and iterate through its contents
Efl.All.Init();
// create an Eina.Array and iterate through it's 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.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

@ -1,8 +1,8 @@
/*
* Eina.List examples.
* Eina List examples.
*
* These examples demonstrate how to work with Eina.List data and methods.
* These examples demonstrate how to work with Eina_list data and methods.
* We create a simple list of names by appending strings to an empty list
* and then run various mutations and print each result.
*/
@ -10,7 +10,7 @@
using System;
using System.Linq;
public class Example : Efl.Csharp.Application
public class Example
{
static Eina.List<string> CreateList()
{
@ -23,17 +23,19 @@ public class Example : Efl.Csharp.Application
return list;
}
protected override void OnInitialize(string[] args)
public static void Main()
{
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
@ -41,7 +43,7 @@ public class Example : Efl.Csharp.Application
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");
@ -50,26 +52,20 @@ public class Example : Efl.Csharp.Application
// 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.App.AppMain.Quit(0);
}
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

@ -1,6 +1,6 @@
/*
* Eina.Log examples.
* Efl Core 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,7 +8,7 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
static double Divide(int num, int denom)
{
@ -40,30 +40,23 @@ public class Example : Efl.Csharp.Application
Divides();
Eina.Log.GlobalLevelSet(Eina.Log.Level.Warning);
Console.WriteLine("Executing with Warning level"); // Same as EINA_LOG_LEVEL = 2
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
Console.WriteLine("Executing with Info on"); // same as EINA_LOG_LEVEL = 3
Divides();
}
protected override void OnInitialize(string[] args)
public static void Main()
{
Efl.All.Init();
LogLevels();
// TODO: missing
//LogCustom();
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

@ -1,21 +1,25 @@
/*
* 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 : Efl.Csharp.Application
public class Example
{
static void ValueInt()
{
int i;
// Setting up an integer value type
Eina.Value int_val = 123;
Console.WriteLine("int_val value is {0}", int_val);
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);
// It can easily be converted to a string
string str = int_val.ToString();
@ -24,9 +28,13 @@ public class Example : Efl.Csharp.Application
static void ValueString()
{
string str;
// Setting up an string value type
Eina.Value str_val = "My string";
Console.WriteLine("str_val value is \"{0}\"", str_val);
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);
// To string should have the same content
string newstr = str_val.ToString();
@ -35,20 +43,33 @@ public class Example : Efl.Csharp.Application
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:
Eina.Value int_val = 123;
Eina.Value str_val = new Eina.Value(Eina.ValueType.String);
int i1;
string str1;
int_val.Set(123);
int_val.Get(out i1);
int_val.ConvertTo(str_val);
Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", int_val, str_val);
str_val.Get(out str1);
Console.WriteLine("int_val was {0}, converted to string is \"{1}\"", i1, str1);
// And the other way around!
str_val = "33.000";
int i2;
string str2;
str_val.Set("33");
str_val.Get(out str2);
str_val.ConvertTo(int_val);
Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val);
int_val.Get(out i2);
Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str2, i2);
}
protected override void OnInitialize(string[] args)
public static void Main()
{
Efl.All.Init();
ValueInt();
Console.WriteLine("");
@ -58,15 +79,6 @@ public class Example : Efl.Csharp.Application
ValueConvert();
Console.WriteLine("");
Efl.App.AppMain.Quit(0);
}
#if WIN32
[STAThreadAttribute()]
#endif
public static void Main()
{
var example = new Example();
example.Launch(Efl.Csharp.Components.Basic);
Efl.All.Shutdown();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +0,0 @@
project(
'snippets', 'cs',
version : '0.0.1',
meson_version : '>= 0.38.0')
efl_mono = dependency('efl-mono', version : '>=1.20.99')
efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')

View File

@ -1,70 +1,10 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
public static void FocusChangedCb(object sender, EventArgs e)
{
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;
Console.WriteLine($"Focus for object {((Efl.Text)sender).GetText()} changed to {((Efl.Ui.Widget)sender).GetFocus()}");
}
#if WIN32
@ -72,8 +12,75 @@ public class Example : Efl.Csharp.Application
#endif
public static void Main()
{
var example = new Example();
example.Launch();
// 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.Win ewin) => {
ewin.SetWinType(Efl.Ui.WinType.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.Box ebox) => {
ebox.SetHintMin(new Eina.Size2D(360, 240));
win.SetContent(ebox);
});
// Create some check boxes
Efl.Ui.Check first_checkbox = null;
for (int i = 0; i< 5; i++) {
var checkbox = new Efl.Ui.Check(vbox, (Efl.Ui.Check 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.Box ebox) => {
ebox.SetDirection(Efl.Ui.Dir.Horizontal);
vbox.DoPack(ebox);
});
// Create a "Focus Mover" button
new Efl.Ui.Button(hbox, (Efl.Ui.Button 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.Button 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();
}
}

View File

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

View File

@ -7,26 +7,28 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
// Create a box container full of buttons
static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
{
Efl.Ui.Box box = new Efl.Ui.Box(win);
// Set distance between contained elements
box.ContentPadding = (5, 0);
Efl.Ui.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
// Set distance between contained elements
ebox.SetPackPadding(5, 0, true);
});
for (int i = 1; i <= 4; ++i)
{
// Add 4 buttons, one below the other
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);
new Efl.Ui.Button(win, (Efl.Ui.Button 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);
});
}
return box;
@ -35,83 +37,92 @@ public class Example : Efl.Csharp.Application
// Create a simple table layout
static Efl.Ui.Table CreateTable(Efl.Ui.Win win)
{
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;
Efl.Ui.Table table = new Efl.Ui.Table(win, (Efl.Ui.Table 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);
});
for (int i = 1; i <= 4; ++i)
{
// Add 4 buttons, following the defined table flow
button = new Efl.Ui.Button(win);
button.Text = $"Table {i}";
table.Pack(button);
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
ebutton.SetText($"Table {i}");
table.DoPack(ebutton);
});
}
// Last button spans two table cells
button = new Efl.Ui.Button(win);
button.Text = "Long Button";
table.PackTable(button, 0, 2, 2, 1);
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
ebutton.SetText("Long Button");
table.PackTable(ebutton, 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()
{
var example = new Example();
example.Launch();
// Initialize EFL and all UI components
Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
ewin.SetWinType(Efl.Ui.WinType.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.Panes vsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes 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.ContentConcrete.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.Panes hsplit = new Efl.Ui.Panes(win, (Efl.Ui.Panes epanes) => {
epanes.SetDirection(Efl.Ui.Dir.Horizontal);
epanes.SetSplitRatio(0.85);
});
Efl.ContentConcrete.static_cast(vsplit.GetPart("second")).SetContent(hsplit);
// Create a table and set it as the content of the first pane of the horizontal
// container
var table = CreateTable(win);
Efl.ContentConcrete.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.Button quit_btn = new Efl.Ui.Button(win, (Efl.Ui.Button 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.ContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
// Start the EFL main loop
Efl.Ui.Config.Run();
// Shutdown EFL
Efl.All.Shutdown();
}
}

View File

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

View File

@ -8,49 +8,57 @@
using System;
public class Example : Efl.Csharp.Application
public class Example
{
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()
{
var example = new Example();
example.Launch();
// Initialize EFL and all UI components
Efl.All.Init(Efl.Components.Ui);
// Create a window and initialize it
Efl.Ui.Win win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => {
ewin.SetWinType(Efl.Ui.WinType.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.Box box = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => {
win.SetContent(ebox);
});
// Create a regular button (without size hints)
new Efl.Ui.Button(win, (Efl.Ui.Button ebutton) => {
ebutton.SetText("Button");
box.DoPack(ebutton);
});
// Create a small button (max size is limited)
new Efl.Ui.Button(win, (Efl.Ui.Button 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.Button 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();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define EFL_EO_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif

View File

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

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