summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2018-04-12 21:45:32 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2018-04-12 22:02:29 +0900
commite432852d587db791fdf902d243e95a5927704c81 (patch)
treeb632960c24004837eeb1332c826ebb4e5ac7d2c3
parent52201061db225fb2bcc074844783a7067369bcdb (diff)
test_ui_stack: Add test using Efl.Ui.Stack classdevs/jaehyun/efl_ui_naviframe
Add test using Efl.Ui.Stack, Efl.Ui.Navigation_Layout, and Efl.Ui.Navigation_Bar classes. Navigation_Bar widget is set into Navigation_Layout widget and Navigation_Layout widget is pushed into Stack widget.
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_ui_stack.c228
3 files changed, 231 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 4d596bd1a2..8e321c9e7d 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -942,6 +942,7 @@ bin/elementary/test_glview.c \
942bin/elementary/test_glview_manygears.c \ 942bin/elementary/test_glview_manygears.c \
943bin/elementary/test_grid.c \ 943bin/elementary/test_grid.c \
944bin/elementary/test_ui_table_static.c \ 944bin/elementary/test_ui_table_static.c \
945bin/elementary/test_ui_stack.c \
945bin/elementary/test_hover.c \ 946bin/elementary/test_hover.c \
946bin/elementary/test_hoversel.c \ 947bin/elementary/test_hoversel.c \
947bin/elementary/test_icon.c \ 948bin/elementary/test_icon.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 9862d1d906..4ef1ac78d6 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -277,6 +277,7 @@ void test_naviframe(void *data, Evas_Object *obj, void *event_info);
277void test_naviframe2(void *data, Evas_Object *obj, void *event_info); 277void test_naviframe2(void *data, Evas_Object *obj, void *event_info);
278void test_naviframe3(void *data, Evas_Object *obj, void *event_info); 278void test_naviframe3(void *data, Evas_Object *obj, void *event_info);
279void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info); 279void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info);
280void test_ui_stack(void *data, Evas_Object *obj, void *event_info);
280//void test_factory(void *data, Evas_Object *obj, void *event_info); 281//void test_factory(void *data, Evas_Object *obj, void *event_info);
281void test_datetime(void *data, Evas_Object *obj, void *event_info); 282void test_datetime(void *data, Evas_Object *obj, void *event_info);
282void test_ui_clock(void *data, Evas_Object *obj, void *event_info); 283void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
@@ -1116,6 +1117,7 @@ add_tests:
1116 ADD_TEST(NULL, "Naviframe", "Naviframe 2", test_naviframe2); 1117 ADD_TEST(NULL, "Naviframe", "Naviframe 2", test_naviframe2);
1117 ADD_TEST(NULL, "Naviframe", "Naviframe 3", test_naviframe3); 1118 ADD_TEST(NULL, "Naviframe", "Naviframe 3", test_naviframe3);
1118 ADD_TEST(NULL, "Naviframe", "Naviframe: Complex", test_naviframe_complex); 1119 ADD_TEST(NULL, "Naviframe", "Naviframe: Complex", test_naviframe_complex);
1120 ADD_TEST_EO(NULL, "Naviframe", "Efl.Ui.Stack", test_ui_stack);
1119 1121
1120 //------------------------------// 1122 //------------------------------//
1121 ADD_TEST(NULL, "Geographic", "Map", test_map); 1123 ADD_TEST(NULL, "Geographic", "Map", test_map);
diff --git a/src/bin/elementary/test_ui_stack.c b/src/bin/elementary/test_ui_stack.c
new file mode 100644
index 0000000000..f6281a67ce
--- /dev/null
+++ b/src/bin/elementary/test_ui_stack.c
@@ -0,0 +1,228 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7static void _third_layout_push(void *data, const Efl_Event *ev EINA_UNUSED);
8static void _fourth_layout_push(void *data, const Efl_Event *ev EINA_UNUSED);
9
10static void
11_stack_remove(void *data, const Efl_Event *ev EINA_UNUSED)
12{
13 Eo *stack = data;
14 Eo *top_layout = efl_ui_stack_top(stack);
15 efl_ui_stack_remove(stack, top_layout);
16}
17
18static void
19_stack_double_pop(void *data, const Efl_Event *ev EINA_UNUSED)
20{
21 Eo *stack = data;
22 efl_ui_stack_pop(stack);
23 efl_ui_stack_pop(stack);
24}
25
26static void
27_stack_pop(void *data, const Efl_Event *ev EINA_UNUSED)
28{
29 Eo *stack = data;
30 efl_ui_stack_pop(stack);
31}
32
33static void
34_stack_double_push(void *data, const Efl_Event *ev EINA_UNUSED)
35{
36 Eo *stack = data;
37 _third_layout_push(stack, NULL);
38 _fourth_layout_push(stack, NULL);
39}
40
41static void
42_stack_del(void *data, const Efl_Event *ev EINA_UNUSED)
43{
44 Eo *stack = data;
45 Eo *top_layout = efl_ui_stack_top(stack);
46 efl_del(top_layout);
47}
48
49static void
50_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
51{
52 Eo *win = data;
53 efl_del(win);
54}
55
56static Eo *
57_navigation_layout_create(Eo *stack, const char *text, Eo *content)
58{
59 Eo *nl = efl_add(EFL_UI_NAVIGATION_LAYOUT_CLASS, stack);
60
61 Eo *bn = efl_add(EFL_UI_NAVIGATION_BAR_CLASS, nl);
62 efl_text_set(bn, text);
63 efl_gfx_visible_set(efl_part(bn, "back_button"), EINA_TRUE);
64 efl_ui_navigation_layout_bar_set(nl, bn);
65
66 efl_content_set(nl, content);
67
68 printf("Create content(%p).\n\n", nl);
69
70 return nl;
71}
72
73static void
74_bar_left_btn_set(Eo *navigation_layout, Efl_Event_Cb clicked_cb, void *data)
75{
76 Eo *bn = efl_ui_navigation_layout_bar_get(navigation_layout);
77
78 Eo *left_btn = efl_add(EFL_UI_BUTTON_CLASS, bn);
79 efl_text_set(left_btn, "Prev");
80 efl_content_set(efl_part(bn, "left_content"), left_btn);
81
82 efl_event_callback_add(left_btn, EFL_UI_EVENT_CLICKED, clicked_cb, data);
83
84 //Positions of "left_content" and "back_button" are the same.
85 efl_gfx_visible_set(efl_part(bn, "back_button"), EINA_FALSE);
86}
87
88static void
89_bar_right_btn_set(Eo *navigation_layout, Efl_Event_Cb clicked_cb, void *data)
90{
91 Eo *bn = efl_ui_navigation_layout_bar_get(navigation_layout);
92
93 Eo *right_btn = efl_add(EFL_UI_BUTTON_CLASS, bn);
94 efl_text_set(right_btn, "Next");
95 efl_content_set(efl_part(bn, "right_content"), right_btn);
96
97 efl_event_callback_add(right_btn, EFL_UI_EVENT_CLICKED, clicked_cb, data);
98}
99
100static void
101_fifth_layout_insert(void *data, const Efl_Event *ev EINA_UNUSED)
102{
103 Eo *stack = data;
104
105 Eo *top_layout = efl_ui_stack_top(stack);
106
107 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, stack);
108 efl_text_set(btn, "Press to remove top layout");
109 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _stack_remove, stack);
110
111 Eo *nl = _navigation_layout_create(stack, "5th layout", btn);
112
113 efl_ui_stack_insert_after(stack, top_layout, nl);
114}
115
116static void
117_fourth_layout_push(void *data, const Efl_Event *ev EINA_UNUSED)
118{
119 Eo *stack = data;
120
121 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, stack);
122 efl_text_set(btn, "Press to double pop");
123 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _stack_double_pop, stack);
124
125 Eo *nl = _navigation_layout_create(stack, "4th layout", btn);
126
127 _bar_right_btn_set(nl, _fifth_layout_insert, stack);
128
129 efl_ui_stack_push(stack, nl);
130}
131
132static void
133_third_layout_push(void *data, const Efl_Event *ev EINA_UNUSED)
134{
135 Eo *stack = data;
136
137 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, stack);
138 efl_text_set(btn, "Press to pop");
139 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _stack_pop, stack);
140
141 Eo *nl = _navigation_layout_create(stack, "3rd layout", btn);
142
143 _bar_right_btn_set(nl, _fourth_layout_push, stack);
144
145 efl_ui_stack_push(stack, nl);
146}
147
148static void
149_second_layout_push(void *data, const Efl_Event *ev EINA_UNUSED)
150{
151 Eo *stack = data;
152
153 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, stack);
154 efl_text_set(btn, "Press to double push");
155 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _stack_double_push, stack);
156
157 Eo *nl = _navigation_layout_create(stack, "2nd layout", btn);
158
159 _bar_right_btn_set(nl, _third_layout_push, stack);
160
161 efl_ui_stack_push(stack, nl);
162}
163
164static void
165_first_layout_push(Eo *win, Eo *stack)
166{
167 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, stack);
168 efl_text_set(btn, "Press to delete stack");
169 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _stack_del, stack);
170
171 Eo *nl = _navigation_layout_create(stack, "1st layout", btn);
172
173 _bar_left_btn_set(nl, _win_del, win);
174 _bar_right_btn_set(nl, _second_layout_push, stack);
175
176 efl_ui_stack_push(stack, nl);
177}
178
179static void
180_stack_loaded_cb(void *data EINA_UNUSED, const Efl_Event *event)
181{
182 Efl_Ui_Stack_Event_Loaded *loaded_info = event->info;
183 printf("Content(%p) is loaded to the stack.\n\n", loaded_info->content);
184}
185
186static void
187_stack_unloaded_cb(void *data EINA_UNUSED, const Efl_Event *event)
188{
189 Efl_Ui_Stack_Event_Unloaded *unloaded_info = event->info;
190 printf("Content(%p) is unloaded from the stack.\n\n", unloaded_info->content);
191}
192
193static void
194_stack_activated_cb(void *data EINA_UNUSED, const Efl_Event *event)
195{
196 Efl_Ui_Stack_Event_Activated *activated_info = event->info;
197 printf("Content(%p) is activated in the stack.\n\n", activated_info->content);
198}
199
200static void
201_stack_deactivated_cb(void *data EINA_UNUSED, const Efl_Event *event)
202{
203 Efl_Ui_Stack_Event_Deactivated *deactivated_info = event->info;
204 printf("Content(%p) is deactivated in the stack.\n\n", deactivated_info->content);
205}
206
207void
208test_ui_stack(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
209{
210 Eo *win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
211 efl_text_set(efl_added, "Efl.Ui.Stack"),
212 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
213
214 efl_gfx_size_set(win, EINA_SIZE2D(500, 500));
215
216 Eo *stack = efl_add(EFL_UI_STACK_CLASS, win);
217 efl_event_callback_add(stack, EFL_UI_STACK_EVENT_LOADED,
218 _stack_loaded_cb, NULL);
219 efl_event_callback_add(stack, EFL_UI_STACK_EVENT_UNLOADED,
220 _stack_unloaded_cb, NULL);
221 efl_event_callback_add(stack, EFL_UI_STACK_EVENT_ACTIVATED,
222 _stack_activated_cb, NULL);
223 efl_event_callback_add(stack, EFL_UI_STACK_EVENT_DEACTIVATED,
224 _stack_deactivated_cb, NULL);
225 efl_content_set(win, stack);
226
227 _first_layout_push(win, stack);
228}