summaryrefslogtreecommitdiff
path: root/reference/c/ui/src/ui_relative_layout.c
blob: 0b8447c8b03c38f2141896c1f8867e06d1845d22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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()