summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-15 21:16:22 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-27 14:15:56 +0900
commit29ea176d0b0de7e7720486200c44189d9235f104 (patch)
treee0398a9ddbee487f33f884e4732fecdccc428ab7
parent70eafcc276461833a07da0c98a1878cb034dac76 (diff)
examples: Add popup cxx exampledevs/jaehyun/efl_popup_test
-rw-r--r--src/examples/elementary/Makefile.am3
-rw-r--r--src/examples/elementary/popup_cxx_example.cc324
-rw-r--r--src/examples/elementary/sky_01.jpgbin0 -> 134813 bytes
3 files changed, 327 insertions, 0 deletions
diff --git a/src/examples/elementary/Makefile.am b/src/examples/elementary/Makefile.am
index ff746b1446..dfe590a34b 100644
--- a/src/examples/elementary/Makefile.am
+++ b/src/examples/elementary/Makefile.am
@@ -199,6 +199,7 @@ calendar_cxx_example_05.cc \
199clock_cxx_example.cc \ 199clock_cxx_example.cc \
200icon_cxx_example_01.cc \ 200icon_cxx_example_01.cc \
201menu_cxx_example_01.cc \ 201menu_cxx_example_01.cc \
202popup_cxx_example.cc \
202radio_cxx_example_01.cc \ 203radio_cxx_example_01.cc \
203slider_cxx_example.cc \ 204slider_cxx_example.cc \
204spinner_cxx_example.cc \ 205spinner_cxx_example.cc \
@@ -418,6 +419,7 @@ calendar_cxx_example_05 \
418clock_cxx_example \ 419clock_cxx_example \
419icon_cxx_example_01 \ 420icon_cxx_example_01 \
420menu_cxx_example_01 \ 421menu_cxx_example_01 \
422popup_cxx_example \
421radio_cxx_example_01 \ 423radio_cxx_example_01 \
422slider_cxx_example \ 424slider_cxx_example \
423spinner_cxx_example \ 425spinner_cxx_example \
@@ -447,6 +449,7 @@ clock_cxx_example_SOURCES = clock_cxx_example.cc
447icon_cxx_example_01_SOURCES = icon_cxx_example_01.cc 449icon_cxx_example_01_SOURCES = icon_cxx_example_01.cc
448menu_cxx_example_01_SOURCES = menu_cxx_example_01.cc 450menu_cxx_example_01_SOURCES = menu_cxx_example_01.cc
449radio_cxx_example_01_SOURCES = radio_cxx_example_01.cc 451radio_cxx_example_01_SOURCES = radio_cxx_example_01.cc
452popup_cxx_example_SOURCES = popup_cxx_example.cc
450slider_cxx_example_SOURCES = slider_cxx_example.cc 453slider_cxx_example_SOURCES = slider_cxx_example.cc
451spinner_cxx_example_SOURCES = spinner_cxx_example.cc 454spinner_cxx_example_SOURCES = spinner_cxx_example.cc
452table_cxx_example_01_SOURCES = table_cxx_example_01.cc 455table_cxx_example_01_SOURCES = table_cxx_example_01.cc
diff --git a/src/examples/elementary/popup_cxx_example.cc b/src/examples/elementary/popup_cxx_example.cc
new file mode 100644
index 0000000000..8a06a81ac0
--- /dev/null
+++ b/src/examples/elementary/popup_cxx_example.cc
@@ -0,0 +1,324 @@
1// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` popup_cxx_example.cc -o popup_cxx_example
2
3#define EFL_CXX_WREF_EASY
4#include <Evas.hh>
5#include <Elementary.hh>
6#include <iostream>
7
8using efl::eo::instantiate;
9
10static efl::ui::Popup g_popup(nullptr);
11static efl::ui::Button g_repeat_events_test_btn(nullptr);
12
13static efl::ui::Popup
14create_popup(efl::ui::Win win)
15{
16 efl::ui::Popup popup(instantiate, win);
17
18 efl::ui::Button btn(instantiate, popup);
19 btn.text_set("Efl.Ui.Popup");
20 popup.content_set(btn);
21
22 popup.size_set({160, 160});
23
24 auto timeout_cb(std::bind([]() {
25 g_popup = nullptr;
26 std::cout << "Popup times out and it is deleted" << std::endl;
27 }));
28 efl::eolian::event_add(efl::ui::Popup::timeout_event, popup, timeout_cb);
29
30
31 return popup;
32}
33
34static void
35efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
36{
37 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN);
38
39
40 //Popup Window
41 efl::ui::Win win(instantiate);
42 win.text_set("Efl.Ui.Popup");
43 win.autohide_set(true);
44 win.size_set({500, 500});
45
46
47 //Popup Function Window
48 efl::ui::Win func_win(instantiate);
49 func_win.text_set("Efl.Ui.Popup Function");
50 func_win.autohide_set(true);
51 func_win.size_set({300, 500});
52
53
54 //Popup Window Delete callback
55 auto wfunc_win(func_win._get_wref());
56 auto win_del_cb(std::bind([wfunc_win]() {
57 g_popup = nullptr;
58 g_repeat_events_test_btn = nullptr;
59 ::efl_del(wfunc_win->_eo_ptr());
60 std::cout << "Window is deleted" << std::endl;
61 }));
62 efl::eolian::event_add(win.delete_request_event, win, win_del_cb);
63
64
65 //Popup Function Window Delete callback
66 auto wwin(win._get_wref());
67 auto func_win_del_cb(std::bind([wwin]() {
68 g_popup = nullptr;
69 g_repeat_events_test_btn = nullptr;
70 ::efl_del(wwin->_eo_ptr());
71 std::cout << "Window is deleted" << std::endl;
72 }));
73 efl::eolian::event_add(func_win.delete_request_event, func_win, func_win_del_cb);
74
75
76 //Dummy Button for Repeat Events Test
77 efl::ui::Button repeat_events_test_btn(instantiate, win);
78 repeat_events_test_btn.text_set("Repeat Event Test");
79 repeat_events_test_btn.position_set({0, 0});
80 repeat_events_test_btn.size_set({100, 100});
81 repeat_events_test_btn.visible_set(false);
82
83 auto repeat_events_test_cb(std::bind([]() {
84 std::cout << "Repeat Test Button is clicked" << std::endl;
85 }));
86 efl::eolian::event_add(efl::ui::Clickable::clicked_event, repeat_events_test_btn, repeat_events_test_cb);
87 g_repeat_events_test_btn = repeat_events_test_btn;
88
89
90 //Popup
91 g_popup = create_popup(win);
92
93
94 //Create Button
95 efl::ui::Button create_btn(instantiate, func_win);
96 create_btn.text_set("Create Popup");
97 create_btn.position_set({0, 0});
98 create_btn.size_set({150, 50});
99
100 auto create_cb(std::bind([wwin]() {
101 if (g_popup)
102 std::cout << "Efl.Ui.Popup is already created" << std::endl;
103 else {
104 std::cout << "Efl.Ui.Popup is created" << std::endl;
105 auto lwin = wwin.lock();
106 if (lwin) {
107 auto win = lwin.get();
108 g_popup = create_popup(win);
109 }
110 }
111 }));
112 efl::eolian::event_add(efl::ui::Clickable::clicked_event, create_btn, create_cb);
113
114
115 //Delete Button
116 efl::ui::Button delete_btn(instantiate, func_win);
117 delete_btn.text_set("Delete Popup");
118 delete_btn.position_set({150, 0});
119 delete_btn.size_set({150, 50});
120
121 auto delete_cb(std::bind([wwin]() {
122 if (g_popup) {
123 auto wpopup(g_popup._get_wref());
124 ::efl_del(wpopup->_eo_ptr());
125 g_popup = nullptr;
126 }
127 else
128 std::cout << "Efl.Ui.Popup does not exist" << std::endl;
129 }));
130 efl::eolian::event_add(efl::ui::Clickable::clicked_event, delete_btn, delete_cb);
131
132
133 //Repeat Events Button
134 efl::ui::Button repeat_events_btn(instantiate, func_win);
135 repeat_events_btn.text_set("Repeat Events Set");
136 repeat_events_btn.position_set({0, 50});
137 repeat_events_btn.size_set({150, 50});
138
139 auto wrepeat_events_btn(repeat_events_btn._get_wref());
140 auto repeat_events_cb(std::bind([wrepeat_events_btn]() {
141 if (!g_popup) return;
142
143 auto lrepeat_events_btn = wrepeat_events_btn.lock();
144 if (!lrepeat_events_btn) return;
145
146 auto repeat_events_btn = lrepeat_events_btn.get();
147 if (!repeat_events_btn) return;
148
149 if (efl::eo::downcast<efl::canvas::Object>(g_popup.part("backwall")).repeat_events_get()) {
150 efl::eo::downcast<efl::canvas::Object>(g_popup.part("backwall")).repeat_events_set(false);
151 repeat_events_btn.text_set("Set Repeat Events");
152 }
153 else {
154 efl::eo::downcast<efl::canvas::Object>(g_popup.part("backwall")).repeat_events_set(true);
155 repeat_events_btn.text_set("Unset Repeat Events");
156 }
157 }));
158 efl::eolian::event_add(efl::ui::Clickable::clicked_event, repeat_events_btn, repeat_events_cb);
159
160
161 //Dummy Button
162 efl::ui::Button dummy_btn(instantiate, func_win);
163 dummy_btn.text_set("Show Dummy Button");
164 dummy_btn.position_set({150, 50});
165 dummy_btn.size_set({150, 50});
166
167 auto wdummy_btn(dummy_btn._get_wref());
168 auto dummy_cb(std::bind([wdummy_btn]() {
169 if (!g_popup) return;
170
171 auto ldummy_btn = wdummy_btn.lock();
172 if (!ldummy_btn) return;
173
174 auto dummy_btn = ldummy_btn.get();
175 if (!dummy_btn) return;
176
177 if (g_repeat_events_test_btn.visible_get()) {
178 g_repeat_events_test_btn.visible_set(false);
179 dummy_btn.text_set("Show Dummy Button");
180 }
181 else {
182 g_repeat_events_test_btn.visible_set(true);
183 dummy_btn.text_set("Hide Dummy Button");
184 }
185 }));
186 efl::eolian::event_add(efl::ui::Clickable::clicked_event, dummy_btn, dummy_cb);
187
188
189 //Backwall Button
190 efl::ui::Button backwall_btn(instantiate, func_win);
191 backwall_btn.text_set("Set Backwall");
192 backwall_btn.position_set({0, 100});
193 backwall_btn.size_set({150, 50});
194
195 auto wbackwall_btn(backwall_btn._get_wref());
196 auto backwall_cb(std::bind([wbackwall_btn]() {
197 static bool backwall_visible = false;
198
199 if (!g_popup) return;
200
201 auto lbackwall_btn = wbackwall_btn.lock();
202 if (!lbackwall_btn) return;
203
204 auto backwall_btn = lbackwall_btn.get();
205 if (!backwall_btn) return;
206
207 backwall_visible = !backwall_visible;
208 if (backwall_visible) {
209 efl::eo::downcast<efl::File>(g_popup.part("backwall")).file_set("./sky_01.jpg", nullptr);
210 backwall_btn.text_set("Unset Backwall");
211 }
212 else {
213 efl::eo::downcast<efl::File>(g_popup.part("backwall")).file_set(nullptr, nullptr);
214 backwall_btn.text_set("Set Backwall");
215 }
216 }));
217 efl::eolian::event_add(efl::ui::Clickable::clicked_event, backwall_btn, backwall_cb);
218
219
220 //Timeout Button
221 efl::ui::Button timeout_btn(instantiate, func_win);
222 timeout_btn.text_set("Set Timeout");
223 timeout_btn.position_set({150, 100});
224 timeout_btn.size_set({150, 50});
225
226 auto timeout_set_cb(std::bind([]() {
227 if (!g_popup) return;
228
229 g_popup.timeout_set(3);
230 std::cout << "Timeout is set to 3 seconds" << std::endl;
231 }));
232 efl::eolian::event_add(efl::ui::Clickable::clicked_event, timeout_btn, timeout_set_cb);
233
234
235 //Center Button
236 efl::ui::Button center_btn(instantiate, func_win);
237 center_btn.text_set("Align Center");
238 center_btn.position_set({0, 150});
239 center_btn.size_set({150, 50});
240
241 auto center_align_cb(std::bind([]() {
242 if (!g_popup) return;
243
244 g_popup.align_set(EFL_UI_POPUP_ALIGN_CENTER);
245 std::cout << "Align Center" << std::endl;
246 }));
247 efl::eolian::event_add(efl::ui::Clickable::clicked_event, center_btn, center_align_cb);
248
249
250 //Top Button
251 efl::ui::Button top_btn(instantiate, func_win);
252 top_btn.text_set("Align Top");
253 top_btn.position_set({150, 150});
254 top_btn.size_set({150, 50});
255
256 auto top_align_cb(std::bind([]() {
257 if (!g_popup) return;
258
259 g_popup.align_set(EFL_UI_POPUP_ALIGN_TOP);
260 std::cout << "Align Top" << std::endl;
261 }));
262 efl::eolian::event_add(efl::ui::Clickable::clicked_event, top_btn, top_align_cb);
263
264
265 //Left Button
266 efl::ui::Button left_btn(instantiate, func_win);
267 left_btn.text_set("Align Left");
268 left_btn.position_set({0, 200});
269 left_btn.size_set({150, 50});
270
271 auto left_align_cb(std::bind([]() {
272 if (!g_popup) return;
273
274 g_popup.align_set(EFL_UI_POPUP_ALIGN_LEFT);
275 std::cout << "Align Left" << std::endl;
276 }));
277 efl::eolian::event_add(efl::ui::Clickable::clicked_event, left_btn, left_align_cb);
278
279
280 //Right Button
281 efl::ui::Button right_btn(instantiate, func_win);
282 right_btn.text_set("Align Right");
283 right_btn.position_set({150, 200});
284 right_btn.size_set({150, 50});
285
286 auto right_align_cb(std::bind([]() {
287 if (!g_popup) return;
288
289 g_popup.align_set(EFL_UI_POPUP_ALIGN_RIGHT);
290 std::cout << "Align Right" << std::endl;
291 }));
292 efl::eolian::event_add(efl::ui::Clickable::clicked_event, right_btn, right_align_cb);
293
294
295 //Bottom Button
296 efl::ui::Button bottom_btn(instantiate, func_win);
297 bottom_btn.text_set("Align Bottom");
298 bottom_btn.position_set({0, 250});
299 bottom_btn.size_set({150, 50});
300
301 auto bottom_align_cb(std::bind([]() {
302 if (!g_popup) return;
303
304 g_popup.align_set(EFL_UI_POPUP_ALIGN_BOTTOM);
305 std::cout << "Align Bottom" << std::endl;
306 }));
307 efl::eolian::event_add(efl::ui::Clickable::clicked_event, bottom_btn, bottom_align_cb);
308
309
310 //Position Button
311 efl::ui::Button position_btn(instantiate, func_win);
312 position_btn.text_set("Set Position to (0, 0)");
313 position_btn.position_set({150, 250});
314 position_btn.size_set({150, 50});
315
316 auto position_set_cb(std::bind([]() {
317 if (!g_popup) return;
318
319 g_popup.position_set({0, 0});
320 std::cout << "Position is set to (0, 0)" << std::endl;
321 }));
322 efl::eolian::event_add(efl::ui::Clickable::clicked_event, position_btn, position_set_cb);
323}
324EFL_MAIN()
diff --git a/src/examples/elementary/sky_01.jpg b/src/examples/elementary/sky_01.jpg
new file mode 100644
index 0000000000..22f30508dd
--- /dev/null
+++ b/src/examples/elementary/sky_01.jpg
Binary files differ