diff options
author | Xavi Artigas <xavierartigas@yahoo.es> | 2019-10-28 10:39:12 +0100 |
---|---|---|
committer | Xavi Artigas <xavierartigas@yahoo.es> | 2019-10-28 10:39:12 +0100 |
commit | f93274d9e143d11cdfdeffc40b7a95e60dc48928 (patch) | |
tree | 8c29bd1bc5fe361b1231089a35c2910a294b0af7 | |
parent | 868ed775486f927a2608f6bf04172a968aaaa9a2 (diff) |
Add Efl.Ui.Relative_Layout exampledevs/xartigas/efl_ui_relative_layout
-rw-r--r-- | reference/c/ui/src/meson.build | 6 | ||||
-rw-r--r-- | reference/c/ui/src/ui_relative_layout.c | 88 |
2 files changed, 94 insertions, 0 deletions
diff --git a/reference/c/ui/src/meson.build b/reference/c/ui/src/meson.build index f575a6a8..51231bbc 100644 --- a/reference/c/ui/src/meson.build +++ b/reference/c/ui/src/meson.build | |||
@@ -28,3 +28,9 @@ executable('efl_reference_ui_focus', | |||
28 | install : true | 28 | install : true |
29 | ) | 29 | ) |
30 | 30 | ||
31 | executable('efl_reference_ui_relative_layout', | ||
32 | files(['ui_relative_layout.c']), | ||
33 | dependencies : deps, | ||
34 | include_directories : inc, | ||
35 | install : true | ||
36 | ) | ||
diff --git a/reference/c/ui/src/ui_relative_layout.c b/reference/c/ui/src/ui_relative_layout.c new file mode 100644 index 00000000..0b8447c8 --- /dev/null +++ b/reference/c/ui/src/ui_relative_layout.c | |||
@@ -0,0 +1,88 @@ | |||
1 | #define EFL_BETA_API_SUPPORT 1 | ||
2 | |||
3 | #include <Elementary.h> | ||
4 | #include <Efl_Ui.h> | ||
5 | // Temporary workaround until Unified Text stops using Legacy classes internally | ||
6 | #include <efl_ui_text.eo.h> | ||
7 | |||
8 | /* | ||
9 | * Efl.UI container examples. | ||
10 | * | ||
11 | * Load and pack a selection of containers. | ||
12 | * Each has it's own unique layout and methods which are demonstrated below. | ||
13 | */ | ||
14 | |||
15 | /* | ||
16 | * TODO Layout | ||
17 | * TODO - still ELM Conformant | ||
18 | * TODO - still ELM Mapbuf | ||
19 | * TODO - still ELM Scroller | ||
20 | */ | ||
21 | |||
22 | // quit the app, called if the user clicks the Quit button or the window is deleted | ||
23 | static void | ||
24 | _gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED) | ||
25 | { | ||
26 | efl_exit(0); | ||
27 | } | ||
28 | |||
29 | // Load a vertical and horizontal split into the window | ||
30 | static void | ||
31 | _ui_layout_setup(Efl_Ui_Win *win) | ||
32 | { | ||
33 | Efl_Ui_Relative_Layout *layout; | ||
34 | Efl_Ui_Button *button1; | ||
35 | |||
36 | layout = efl_add(EFL_UI_RELATIVE_LAYOUT_CLASS, win, | ||
37 | efl_content_set(win, efl_added)); | ||
38 | |||
39 | button1 = efl_add(EFL_UI_BUTTON_CLASS, layout, | ||
40 | efl_text_set(efl_added, "Button 1"), | ||
41 | efl_pack(layout, efl_added), | ||
42 | efl_ui_relative_layout_relation_right_set(layout, efl_added, NULL, 0.5), | ||
43 | efl_ui_relative_layout_relation_bottom_set(layout, efl_added, NULL, 0.5)); | ||
44 | |||
45 | efl_add(EFL_UI_BUTTON_CLASS, layout, | ||
46 | efl_text_set(efl_added, "Button 1A"), | ||
47 | efl_pack(layout, efl_added), | ||
48 | efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0), | ||
49 | efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 0.33)); | ||
50 | efl_add(EFL_UI_BUTTON_CLASS, layout, | ||
51 | efl_text_set(efl_added, "Button 1B"), | ||
52 | efl_pack(layout, efl_added), | ||
53 | efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0), | ||
54 | efl_ui_relative_layout_relation_top_set(layout, efl_added, button1, 0.33), | ||
55 | efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 0.66)); | ||
56 | efl_add(EFL_UI_BUTTON_CLASS, layout, | ||
57 | efl_text_set(efl_added, "Button 1C"), | ||
58 | efl_pack(layout, efl_added), | ||
59 | efl_ui_relative_layout_relation_left_set(layout, efl_added, button1, 1.0), | ||
60 | efl_ui_relative_layout_relation_top_set(layout, efl_added, button1, 0.66), | ||
61 | efl_ui_relative_layout_relation_bottom_set(layout, efl_added, button1, 1.0)); | ||
62 | efl_add(EFL_UI_BUTTON_CLASS, layout, | ||
63 | efl_text_set(efl_added, "Quit"), | ||
64 | efl_pack(layout, efl_added), | ||
65 | efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _gui_quit_cb, NULL), | ||
66 | efl_ui_relative_layout_relation_left_set(layout, efl_added, NULL, 0.25), | ||
67 | efl_ui_relative_layout_relation_top_set(layout, efl_added, NULL, 0.8), | ||
68 | efl_ui_relative_layout_relation_right_set(layout, efl_added, NULL, 0.75)); | ||
69 | } | ||
70 | |||
71 | EAPI_MAIN void | ||
72 | efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) | ||
73 | { | ||
74 | Eo *win; | ||
75 | |||
76 | win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), | ||
77 | efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC), | ||
78 | efl_text_set(efl_added, "UI Relative Layout"), | ||
79 | efl_ui_win_autodel_set(efl_added, EINA_TRUE)); | ||
80 | efl_gfx_entity_size_set(win, EINA_SIZE2D(350, 250)); | ||
81 | |||
82 | // when the user clicks "close" on a window there is a request to delete | ||
83 | efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL); | ||
84 | |||
85 | _ui_layout_setup(win); | ||
86 | } | ||
87 | EFL_MAIN() | ||
88 | |||