Simplify focus example and add Meson

devs/vitorsousa/csharp
Xavi Artigas 5 years ago
parent 11091214f7
commit 2c0fb1cb00
  1. 13
      tutorial/c/focus/meson.build
  2. 81
      tutorial/c/focus/src/focus_main.c
  3. 12
      tutorial/c/focus/src/meson.build
  4. 89
      tutorial/c/focus/using_focus.c

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

@ -0,0 +1,81 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
static void
_gui_about_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Clicked About\n");
}
static void
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Clicked Quit\n");
efl_exit(0);
}
static void
_focus_changed(void *data EINA_UNUSED, const Efl_Event *event)
{
printf("Focus for object '%s' changed to %d\n",
efl_text_get(event->object), efl_ui_focus_object_focus_get(event->object));
}
static void
_gui_setup()
{
Eo *win, *box, *hbox, *about;
win = efl_add(EFL_UI_WIN_CLASS, NULL,
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,
_gui_quit_clicked_cb, NULL),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_set(efl_added, "Label"),
efl_ui_text_interactive_editable_set(efl_added, EINA_FALSE),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL),
efl_pack(box, efl_added));
hbox = efl_add(EFL_UI_BOX_CLASS, box,
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added));
about = efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "About"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_about_clicked_cb, efl_added));
efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "Quit"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about);
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
_gui_setup();
}
EFL_MAIN()

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

@ -1,89 +0,0 @@
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Elementary.h>
#include <Efl_Ui.h>
static void
_gui_editor_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *editor = data;
printf("Change recorded: %s\n", efl_text_get(editor));
}
static void
_gui_about_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *button = data;
printf("Clicked About\n");
}
static void
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
efl_exit(0);
}
static void
_focus_changed(void *data EINA_UNUSED, const Efl_Event *event)
{
printf("Focus changed to %hhu!\n", efl_ui_focus_object_focus_get(event->object));
}
static void
_gui_setup()
{
Eo *win, *box, *hbox, *editor, *button;
// TODO can we have nicer methods like efl_ui_win_add?
win = efl_add(EFL_UI_WIN_CLASS, NULL,
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));
box = efl_add(EFL_UI_BOX_CLASS, win,
efl_content_set(win, efl_added),
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
editor = efl_add(EFL_UI_TEXT_CLASS, box,
efl_text_set(efl_added, "Edit me"),
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
efl_ui_text_scrollable_set(efl_added, EINA_TRUE),
efl_pack(box, efl_added));
efl_event_callback_add(editor, EFL_UI_TEXT_EVENT_CHANGED_USER,
_gui_editor_changed_cb, editor);
efl_event_callback_add(editor, EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED,
_focus_changed, NULL);
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, editor);
hbox = efl_add(EFL_UI_BOX_CLASS, box,
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
efl_pack(box, efl_added));
button = efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "About"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_about_clicked_cb, efl_added));
efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, button);
button = efl_add(EFL_UI_BUTTON_CLASS, hbox,
efl_text_set(efl_added, "Quit"),
efl_pack(hbox, efl_added),
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
_gui_quit_clicked_cb, efl_added));
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
// TODO this to a efl_ui_policy method
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
_gui_setup();
}
EFL_MAIN()
Loading…
Cancel
Save