Add Efl.Ui.Relative_Layout example
This commit is contained in:
parent
868ed77548
commit
f93274d9e1
|
@ -28,3 +28,9 @@ executable('efl_reference_ui_focus',
|
|||
install : true
|
||||
)
|
||||
|
||||
executable('efl_reference_ui_relative_layout',
|
||||
files(['ui_relative_layout.c']),
|
||||
dependencies : deps,
|
||||
include_directories : inc,
|
||||
install : true
|
||||
)
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
#define EFL_BETA_API_SUPPORT 1
|
||||
|
||||
#include <Elementary.h>
|
||||
#include <Efl_Ui.h>
|
||||
// Temporary workaround until Unified Text stops using Legacy classes internally
|
||||
#include <efl_ui_text.eo.h>
|
||||
|
||||
/*
|
||||
* Efl.UI container examples.
|
||||
*
|
||||
* 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 Scroller
|
||||
*/
|
||||
|
||||
// quit the app, called if the user clicks the Quit button or the window is deleted
|
||||
static void
|
||||
_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
||||
{
|
||||
efl_exit(0);
|
||||
}
|
||||
|
||||
// Load a vertical and horizontal split into the window
|
||||
static void
|
||||
_ui_layout_setup(Efl_Ui_Win *win)
|
||||
{
|
||||
Efl_Ui_Relative_Layout *layout;
|
||||
Efl_Ui_Button *button1;
|
||||
|
||||
layout = efl_add(EFL_UI_RELATIVE_LAYOUT_CLASS, win,
|
||||
efl_content_set(win, efl_added));
|
||||
|
||||
button1 = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||
efl_text_set(efl_added, "Button 1"),
|
||||
efl_pack(layout, efl_added),
|
||||
efl_ui_relative_layout_relation_right_set(layout, efl_added, NULL, 0.5),
|
||||
efl_ui_relative_layout_relation_bottom_set(layout, efl_added, NULL, 0.5));
|
||||
|
||||
efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||
efl_text_set(efl_added, "Button 1A"),
|
||||
efl_pack(layout, efl_added),
|
||||
efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0),
|
||||
efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 0.33));
|
||||
efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||
efl_text_set(efl_added, "Button 1B"),
|
||||
efl_pack(layout, efl_added),
|
||||
efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0),
|
||||
efl_ui_relative_layout_relation_top_set(layout, efl_added, button1, 0.33),
|
||||
efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 0.66));
|
||||
efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||
efl_text_set(efl_added, "Button 1C"),
|
||||
efl_pack(layout, efl_added),
|
||||
efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0),
|
||||
efl_ui_relative_layout_relation_top_set(layout, efl_added, button1, 0.66),
|
||||
efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 1.0));
|
||||
efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||
efl_text_set(efl_added, "Quit"),
|
||||
efl_pack(layout, efl_added),
|
||||
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _gui_quit_cb, NULL),
|
||||
efl_ui_relative_layout_relation_left_set(layout, efl_added, NULL, 0.25),
|
||||
efl_ui_relative_layout_relation_top_set(layout, efl_added, NULL, 0.8),
|
||||
efl_ui_relative_layout_relation_right_set(layout, efl_added, NULL, 0.75));
|
||||
}
|
||||
|
||||
EAPI_MAIN void
|
||||
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_text_set(efl_added, "UI Relative Layout"),
|
||||
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
||||
efl_gfx_entity_size_set(win, EINA_SIZE2D(350, 250));
|
||||
|
||||
// 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);
|
||||
|
||||
_ui_layout_setup(win);
|
||||
}
|
||||
EFL_MAIN()
|
||||
|
Loading…
Reference in New Issue