Merge branch 'master' into devs/xartigas/tutorials
This commit is contained in:
commit
c41c0cc319
|
@ -0,0 +1,12 @@
|
||||||
|
project(
|
||||||
|
'efl-reference-ui', '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')
|
||||||
|
|
||||||
|
inc = include_directories('.')
|
||||||
|
subdir('src')
|
||||||
|
|
|
@ -6,3 +6,10 @@ executable('efl_reference_ui_sizing',
|
||||||
include_directories : inc,
|
include_directories : inc,
|
||||||
install : true
|
install : true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
executable('efl_reference_ui_container',
|
||||||
|
files(['ui_container.c']),
|
||||||
|
dependencies : deps,
|
||||||
|
include_directories : inc,
|
||||||
|
install : true
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
#define EFL_EO_API_SUPPORT 1
|
||||||
|
#define EFL_BETA_API_SUPPORT 1
|
||||||
|
|
||||||
|
#include <Eina.h>
|
||||||
|
#include <Elementary.h>
|
||||||
|
#include <Efl_Ui.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Efl.UI container exmaples.
|
||||||
|
*
|
||||||
|
* Load and pack a selection of containers.
|
||||||
|
* Each has it's own unique layout and methods which are demonstrated below.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO Layout
|
||||||
|
* TODO - still ELM Conformant
|
||||||
|
* TODO - still ELM Mapbuf
|
||||||
|
* TODO - still ELM Naviframe
|
||||||
|
* TODO - still ELM Scroller
|
||||||
|
* TODO - still ELM Table
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Load a simple grid layout into the window
|
||||||
|
static Efl_Ui_Grid *
|
||||||
|
_ui_grid_setup(Efl_Ui_Win *win)
|
||||||
|
{
|
||||||
|
Efl_Ui_Grid *grid;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
grid = efl_add(EFL_UI_GRID_CLASS, win);
|
||||||
|
|
||||||
|
efl_pack_grid_columns_set(grid, 2);
|
||||||
|
efl_pack_grid_direction_set(grid, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN);
|
||||||
|
|
||||||
|
efl_add(EFL_UI_BUTTON_CLASS, win,
|
||||||
|
efl_text_set(efl_added, "Long Button"),
|
||||||
|
efl_pack_grid(grid, efl_added, 0, 2, 2, 1));
|
||||||
|
|
||||||
|
for (i = 1; i <= 4; i++)
|
||||||
|
{
|
||||||
|
efl_add(EFL_UI_BUTTON_CLASS, win,
|
||||||
|
efl_text_set(efl_added, eina_slstr_printf("Grid %d", i)),
|
||||||
|
efl_pack(grid, efl_added));
|
||||||
|
}
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load some boxes - a horizontal one for the window layout and a vertical
|
||||||
|
// one to contain a flow
|
||||||
|
static void
|
||||||
|
_ui_boxes_setup(Efl_Ui_Win *win)
|
||||||
|
{
|
||||||
|
Efl_Ui_Box *hbox, *box, *button;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
hbox = efl_add(EFL_UI_BOX_CLASS, win,
|
||||||
|
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
|
||||||
|
efl_pack_padding_set(efl_added, 5, 0, EINA_TRUE),
|
||||||
|
efl_content_set(win, efl_added));
|
||||||
|
|
||||||
|
box = efl_add(EFL_UI_BOX_CLASS, win,
|
||||||
|
efl_pack(hbox, efl_added));
|
||||||
|
efl_pack(hbox, _ui_grid_setup(win));
|
||||||
|
|
||||||
|
for (i = 1; i <= 4; i++)
|
||||||
|
{
|
||||||
|
button = efl_add(EFL_UI_BUTTON_CLASS, win,
|
||||||
|
efl_text_set(efl_added, eina_slstr_printf("Boxed %d", i)),
|
||||||
|
efl_pack(box, efl_added));
|
||||||
|
|
||||||
|
if (i == 2)
|
||||||
|
efl_gfx_size_hint_max_set(button, EINA_SIZE2D(100, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load a vertical and horizontal split into the window
|
||||||
|
// TODO re-enable this when it actually works in EFL
|
||||||
|
static void
|
||||||
|
_ui_panes_setup(Efl_Ui_Win *win)
|
||||||
|
{
|
||||||
|
Efl_Ui_Panes *split, *horiz_split;
|
||||||
|
|
||||||
|
split = efl_add(EFL_UI_PANES_CLASS, win,
|
||||||
|
efl_content_set(win, efl_added),
|
||||||
|
efl_ui_panes_split_ratio_set(efl_added, 0.75));
|
||||||
|
|
||||||
|
efl_add(EFL_UI_BOX_CLASS, win,
|
||||||
|
efl_content_set(efl_part(split, "first"), efl_added));
|
||||||
|
|
||||||
|
horiz_split = efl_add(EFL_UI_PANES_CLASS, win,
|
||||||
|
efl_content_set(efl_part(split, "second"), efl_added),
|
||||||
|
efl_ui_panes_split_ratio_set(efl_added, 0.85));
|
||||||
|
|
||||||
|
efl_add(EFL_UI_BOX_CLASS, win,
|
||||||
|
efl_content_set(efl_part(horiz_split, "first"), efl_added));
|
||||||
|
|
||||||
|
efl_add(EFL_UI_BUTTON_CLASS, win,
|
||||||
|
efl_text_set(efl_added, "Quit"),
|
||||||
|
efl_content_set(efl_part(horiz_split, "second"), efl_added));
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI_MAIN void
|
||||||
|
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Eo *win;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
// _ui_panes_setup(win);
|
||||||
|
_ui_boxes_setup(win);
|
||||||
|
|
||||||
|
efl_gfx_size_set(win, EINA_SIZE2D(350, 250));
|
||||||
|
}
|
||||||
|
EFL_MAIN()
|
||||||
|
|
|
@ -13,14 +13,6 @@ _gui_editor_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
||||||
printf("Change recorded: %s\n", efl_text_get(editor));
|
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
|
static void
|
||||||
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
_gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -30,9 +22,8 @@ _gui_quit_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
||||||
static void
|
static void
|
||||||
_gui_setup()
|
_gui_setup()
|
||||||
{
|
{
|
||||||
Eo *win, *box, *hbox, *editor, *button;
|
Eo *win, *box, *editor;
|
||||||
|
|
||||||
// TODO can we have nicer methods like efl_ui_win_add?
|
|
||||||
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
||||||
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
|
efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
|
||||||
efl_text_set(efl_added, "Hello World"),
|
efl_text_set(efl_added, "Hello World"),
|
||||||
|
@ -42,6 +33,18 @@ _gui_setup()
|
||||||
efl_content_set(win, efl_added),
|
efl_content_set(win, efl_added),
|
||||||
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
|
efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
|
||||||
|
|
||||||
|
// TODO make this a single label with anewline in it
|
||||||
|
efl_add(EFL_UI_TEXT_CLASS, box,
|
||||||
|
efl_text_set(efl_added, "Hello World."),
|
||||||
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
|
||||||
|
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
|
||||||
|
efl_pack(box, efl_added));
|
||||||
|
efl_add(EFL_UI_TEXT_CLASS, box,
|
||||||
|
efl_text_set(efl_added, "You can edit the text below to generate change events..."),
|
||||||
|
efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
|
||||||
|
efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
|
||||||
|
efl_pack(box, efl_added));
|
||||||
|
|
||||||
editor = efl_add(EFL_UI_TEXT_CLASS, box,
|
editor = efl_add(EFL_UI_TEXT_CLASS, box,
|
||||||
efl_text_set(efl_added, "Edit me"),
|
efl_text_set(efl_added, "Edit me"),
|
||||||
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
|
efl_ui_text_interactive_editable_set(efl_added, EINA_TRUE),
|
||||||
|
@ -50,20 +53,12 @@ _gui_setup()
|
||||||
efl_event_callback_add(editor, EFL_UI_TEXT_EVENT_CHANGED_USER,
|
efl_event_callback_add(editor, EFL_UI_TEXT_EVENT_CHANGED_USER,
|
||||||
_gui_editor_changed_cb, editor);
|
_gui_editor_changed_cb, editor);
|
||||||
|
|
||||||
hbox = efl_add(EFL_UI_BOX_CLASS, box,
|
efl_add(EFL_UI_BUTTON_CLASS, box,
|
||||||
efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
|
efl_text_set(efl_added, "Quit"),
|
||||||
efl_gfx_size_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_pack(box, efl_added),
|
||||||
button = efl_add(EFL_UI_BUTTON_CLASS, hbox,
|
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
|
||||||
efl_text_set(efl_added, "About"),
|
_gui_quit_clicked_cb, efl_added));
|
||||||
efl_pack(hbox, efl_added),
|
|
||||||
efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
|
|
||||||
_gui_about_clicked_cb, efl_added));
|
|
||||||
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
|
EAPI_MAIN void
|
||||||
|
|
Loading…
Reference in New Issue