summaryrefslogtreecommitdiff
path: root/reference/c/ui/src/ui_container.c
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-11-27 13:18:42 +0000
committerAndy Williams <andy@andywilliams.me>2017-11-27 13:18:42 +0000
commitd4beab80130f0fa51fdae85c13254da9a4e50109 (patch)
treeee014bc192bf280c724b3eb0188e6388df417b9d /reference/c/ui/src/ui_container.c
parent597ba6d98c6648b0b06ec0df041124b496ea29fa (diff)
ui: Add containers reference
Diffstat (limited to 'reference/c/ui/src/ui_container.c')
-rw-r--r--reference/c/ui/src/ui_container.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/reference/c/ui/src/ui_container.c b/reference/c/ui/src/ui_container.c
new file mode 100644
index 00000000..8ded077b
--- /dev/null
+++ b/reference/c/ui/src/ui_container.c
@@ -0,0 +1,121 @@
1#define EFL_EO_API_SUPPORT 1
2#define EFL_BETA_API_SUPPORT 1
3
4#include <Eina.h>
5#include <Elementary.h>
6#include <Efl_Ui.h>
7
8/*
9 * Efl.UI container exmaples.
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 Naviframe
20 * TODO - still ELM Scroller
21 * TODO - still ELM Table
22 */
23
24// Load a simple grid layout into the window
25static Efl_Ui_Grid *
26_ui_grid_setup(Efl_Ui_Win *win)
27{
28 Efl_Ui_Grid *grid;
29 int i;
30
31 grid = efl_add(EFL_UI_GRID_CLASS, win);
32
33 efl_pack_grid_columns_set(grid, 2);
34 efl_pack_grid_direction_set(grid, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN);
35
36 efl_add(EFL_UI_BUTTON_CLASS, win,
37 efl_text_set(efl_added, "Long Button"),
38 efl_pack_grid(grid, efl_added, 0, 2, 2, 1));
39
40 for (i = 1; i <= 4; i++)
41 {
42 efl_add(EFL_UI_BUTTON_CLASS, win,
43 efl_text_set(efl_added, eina_slstr_printf("Grid %d", i)),
44 efl_pack(grid, efl_added));
45 }
46
47 return grid;
48}
49
50// Load some boxes - a horizontal one for the window layout and a vertical
51// one to contain a flow
52static void
53_ui_boxes_setup(Efl_Ui_Win *win)
54{
55 Efl_Ui_Box *hbox, *box, *button;
56 int i;
57
58 hbox = efl_add(EFL_UI_BOX_CLASS, win,
59 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
60 efl_pack_padding_set(efl_added, 5, 0, EINA_TRUE),
61 efl_content_set(win, efl_added));
62
63 box = efl_add(EFL_UI_BOX_CLASS, win,
64 efl_pack(hbox, efl_added));
65 efl_pack(hbox, _ui_grid_setup(win));
66
67 for (i = 1; i <= 4; i++)
68 {
69 button = efl_add(EFL_UI_BUTTON_CLASS, win,
70 efl_text_set(efl_added, eina_slstr_printf("Boxed %d", i)),
71 efl_pack(box, efl_added));
72
73 if (i == 2)
74 efl_gfx_size_hint_max_set(button, EINA_SIZE2D(100, 50));
75 }
76
77}
78
79// Load a vertical and horizontal split into the window
80// TODO re-enable this when it actually works in EFL
81static void
82_ui_panes_setup(Efl_Ui_Win *win)
83{
84 Efl_Ui_Panes *split, *horiz_split;
85
86 split = efl_add(EFL_UI_PANES_CLASS, win,
87 efl_content_set(win, efl_added),
88 efl_ui_panes_split_ratio_set(efl_added, 0.75));
89
90 efl_add(EFL_UI_BOX_CLASS, win,
91 efl_content_set(efl_part(split, "first"), efl_added));
92
93 horiz_split = efl_add(EFL_UI_PANES_CLASS, win,
94 efl_content_set(efl_part(split, "second"), efl_added),
95 efl_ui_panes_split_ratio_set(efl_added, 0.85));
96
97 efl_add(EFL_UI_BOX_CLASS, win,
98 efl_content_set(efl_part(horiz_split, "first"), efl_added));
99
100 efl_add(EFL_UI_BUTTON_CLASS, win,
101 efl_text_set(efl_added, "Quit"),
102 efl_content_set(efl_part(horiz_split, "second"), efl_added));
103}
104
105EAPI_MAIN void
106efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
107{
108 Eo *win;
109
110 win = efl_add(EFL_UI_WIN_CLASS, NULL,
111 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
112 efl_text_set(efl_added, "Hello World"),
113 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
114
115// _ui_panes_setup(win);
116 _ui_boxes_setup(win);
117
118 efl_gfx_size_set(win, EINA_SIZE2D(350, 250));
119}
120EFL_MAIN()
121