summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_ui_popup.c
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-30 20:03:01 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-28 17:15:42 +0900
commitf82779efc220faf2c382489dede0e3910c37ea77 (patch)
tree3d51e6f105314d01c7b6f32e55d0dddf6bea4ac5 /src/bin/elementary/test_ui_popup.c
parent4a020223d89735dbfe99ef3c69a89c9aeb9717e6 (diff)
test_ui_popup: Move code for Efl.Ui.Popup classes from test_popup
Code refactoring to replace legacy APIs and move test code for Efl.Ui.Popup and its sub classes from test_popup to test_ui_popup.
Diffstat (limited to '')
-rw-r--r--src/bin/elementary/test_ui_popup.c529
1 files changed, 529 insertions, 0 deletions
diff --git a/src/bin/elementary/test_ui_popup.c b/src/bin/elementary/test_ui_popup.c
new file mode 100644
index 0000000000..2c7075de32
--- /dev/null
+++ b/src/bin/elementary/test_ui_popup.c
@@ -0,0 +1,529 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_UI_POPUP_ANCHOR_BETA
6#include <Elementary.h>
7
8#define POPUP_POINT_MAX 8
9
10typedef struct
11{
12 Eo *win;
13 Eo *panel_win;
14 Eo *efl_ui_popup;
15 Eo *button;
16} efl_ui_popup_data;
17
18static void
19_bg_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
20{
21 printf("Popup's background is clicked.\n");
22}
23
24static void
25_timeout_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
26{
27 efl_ui_popup_data *p_data = data;
28 p_data->efl_ui_popup = NULL;
29 printf("Popup times out and it is deleted.\n");
30}
31
32static void
33_delete_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
34{
35 efl_ui_popup_data *p_data = data;
36 if (p_data->efl_ui_popup)
37 {
38 efl_del(p_data->efl_ui_popup);
39 p_data->efl_ui_popup = NULL;
40 return;
41 }
42 printf("Efl.Ui.Popup does not exist.\n");
43}
44
45static Eo*
46_create_popup(efl_ui_popup_data *p_data)
47{
48 if (!p_data->win) return NULL;
49 if (p_data->efl_ui_popup)
50 {
51 printf("Efl.Ui.Popup is already created.\n");
52 efl_gfx_visible_set(p_data->efl_ui_popup, EINA_TRUE);
53 return p_data->efl_ui_popup;
54 }
55
56 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_CLASS, p_data->win);
57
58 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_EVENT_BG_CLICKED, _bg_clicked, NULL);
59 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_EVENT_TIMEOUT, _timeout_cb, p_data);
60 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
61
62 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
63 efl_text_set(btn, "Efl.Ui.Popup");
64
65 efl_content_set(efl_ui_popup, btn);
66
67 return efl_ui_popup;
68}
69
70static void
71_create_cb(void *data, const Efl_Event *ev EINA_UNUSED)
72{
73 efl_ui_popup_data *p_data = data;
74 p_data->efl_ui_popup = _create_popup(p_data);
75}
76
77static void
78_bg_cb(void *data EINA_UNUSED, const Efl_Event *ev)
79{
80 static int k = 0;
81 efl_ui_popup_data *p_data = data;
82 if (!p_data->efl_ui_popup) return;
83 if (k == 0)
84 {
85 char buf[PATH_MAX];
86 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
87 efl_ui_popup_bg_set(p_data->efl_ui_popup, buf, NULL);
88 efl_text_set(ev->object, "Bg UnSet");
89 }
90 else
91 {
92 efl_ui_popup_bg_set(p_data->efl_ui_popup, NULL, NULL);
93 efl_text_set(ev->object, "Bg Set");
94 }
95 k = !k;
96}
97
98static void
99_repeat_event_cb(void *data EINA_UNUSED, const Efl_Event *ev)
100{
101 efl_ui_popup_data *p_data = data;
102 if (!p_data->efl_ui_popup) return;
103 if (!efl_ui_popup_bg_repeat_events_get(p_data->efl_ui_popup))
104 {
105 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_TRUE);
106 efl_text_set(ev->object, "Repeat Event UnSet");
107 }
108 else
109 {
110 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_FALSE);
111 efl_text_set(ev->object, "Repeat Event Set");
112 }
113}
114
115static void
116_repeat_test_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
117{
118 printf("Repeat Test Button is Clicked.\n");
119}
120
121static void
122_dummy_cb(void *data EINA_UNUSED, const Efl_Event *ev)
123{
124 efl_ui_popup_data *p_data = data;
125 if (!p_data->efl_ui_popup) return;
126 if (!efl_gfx_visible_get(p_data->button))
127 {
128 efl_gfx_visible_set(p_data->button, EINA_TRUE);
129 efl_text_set(ev->object, "Hide Dummy Button");
130 }
131 else
132 {
133 efl_gfx_visible_set(p_data->button, EINA_FALSE);
134 efl_text_set(ev->object, "Show Dummy Button");
135 }
136}
137
138static void
139_center_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
140{
141 efl_ui_popup_data *p_data = data;
142 if (!p_data->efl_ui_popup) return;
143 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_CENTER);
144}
145
146static void
147_left_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
148{
149 efl_ui_popup_data *p_data = data;
150 if (!p_data->efl_ui_popup) return;
151 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_LEFT);
152}
153
154static void
155_right_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
156{
157 efl_ui_popup_data *p_data = data;
158 if (!p_data->efl_ui_popup) return;
159 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_RIGHT);
160}
161
162static void
163_top_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
164{
165 efl_ui_popup_data *p_data = data;
166 if (!p_data->efl_ui_popup) return;
167 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP);
168}
169
170static void
171_bottom_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
172{
173 efl_ui_popup_data *p_data = data;
174 if (!p_data->efl_ui_popup) return;
175 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_BOTTOM);
176}
177
178static void
179_position_set_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
180{
181 efl_ui_popup_data *p_data = data;
182 if (!p_data->efl_ui_popup) return;
183 efl_gfx_position_set(p_data->efl_ui_popup, EINA_POSITION2D(0, 0));
184}
185
186static void
187_timeout_set_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
188{
189 efl_ui_popup_data *p_data = data;
190 if (!p_data->efl_ui_popup) return;
191 efl_ui_popup_timeout_set(p_data->efl_ui_popup, 3);
192 printf("timemout is set to 3 seconds\n");
193}
194
195static void
196_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
197{
198 efl_ui_popup_data *p_data = data;
199 efl_del(p_data->panel_win);
200 free(p_data);
201 printf("window is deleted\n");
202}
203
204static void
205_panel_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
206{
207 efl_ui_popup_data *p_data = data;
208 efl_del(p_data->win);
209 free(p_data);
210 printf("window is deleted\n");
211}
212
213void
214test_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
215{
216 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
217
218 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
219 efl_text_set(efl_added, "Efl.Ui.Popup"),
220 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
221 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _win_del, p_data);
222
223 efl_gfx_size_set(win, EINA_SIZE2D(500, 500));
224
225 Eo *panel_win = efl_add(EFL_UI_WIN_CLASS, NULL,
226 efl_text_set(efl_added, "Efl.Ui.Popup Panel"),
227 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
228 efl_event_callback_add(panel_win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _panel_win_del, p_data);
229
230 efl_gfx_size_set(panel_win, EINA_SIZE2D(300, 500));
231
232 Eo *repeat_test_btn = efl_add(EFL_UI_BUTTON_CLASS, win);
233 efl_gfx_position_set(repeat_test_btn, EINA_POSITION2D(0, 0));
234 efl_gfx_size_set(repeat_test_btn, EINA_SIZE2D(100, 100));
235 efl_text_set(repeat_test_btn, "Repeat Event Test");
236 efl_event_callback_add(repeat_test_btn, EFL_UI_EVENT_CLICKED, _repeat_test_cb, NULL);
237 efl_gfx_visible_set(repeat_test_btn, EINA_FALSE);
238
239 p_data->win = win;
240 p_data->panel_win = panel_win;
241 p_data->button = repeat_test_btn;
242 p_data->efl_ui_popup = _create_popup(p_data);
243
244 Eo *create_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
245 efl_text_set(create_btn, "Create Popup");
246 efl_gfx_position_set(create_btn, EINA_POSITION2D(0, 0));
247 efl_gfx_size_set(create_btn, EINA_SIZE2D(150, 50));
248 efl_event_callback_add(create_btn, EFL_UI_EVENT_CLICKED, _create_cb, p_data);
249
250 Eo *delete_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
251 efl_text_set(delete_btn, "Delete Popup");
252 efl_gfx_position_set(delete_btn, EINA_POSITION2D(150, 0));
253 efl_gfx_size_set(delete_btn, EINA_SIZE2D(150, 50));
254 efl_event_callback_add(delete_btn, EFL_UI_EVENT_CLICKED, _delete_cb, p_data);
255
256 Eo *repeat_event_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
257 efl_text_set(repeat_event_btn, "Repeat Event Set");
258 efl_gfx_position_set(repeat_event_btn, EINA_POSITION2D(0, 50));
259 efl_gfx_size_set(repeat_event_btn, EINA_SIZE2D(150, 50));
260 efl_event_callback_add(repeat_event_btn, EFL_UI_EVENT_CLICKED, _repeat_event_cb, p_data);
261
262 Eo *dummy_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
263 efl_text_set(dummy_btn, "Show Dummy Button");
264 efl_gfx_position_set(dummy_btn, EINA_POSITION2D(150, 50));
265 efl_gfx_size_set(dummy_btn, EINA_SIZE2D(150, 50));
266 efl_event_callback_add(dummy_btn, EFL_UI_EVENT_CLICKED, _dummy_cb, p_data);
267
268 Eo *bg_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
269 efl_gfx_position_set(bg_btn, EINA_POSITION2D(0, 100));
270 efl_gfx_size_set(bg_btn, EINA_SIZE2D(150, 50));
271 efl_text_set(bg_btn, "Bg Set");
272 efl_event_callback_add(bg_btn, EFL_UI_EVENT_CLICKED, _bg_cb, p_data);
273
274 Eo *timeout_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
275 efl_text_set(timeout_btn, "Timeout Set");
276 efl_gfx_position_set(timeout_btn, EINA_POSITION2D(150, 100));
277 efl_gfx_size_set(timeout_btn, EINA_SIZE2D(150, 50));
278 efl_event_callback_add(timeout_btn, EFL_UI_EVENT_CLICKED, _timeout_set_cb, p_data);
279
280 Eo *center_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
281 efl_text_set(center_btn, "Center Align");
282 efl_gfx_position_set(center_btn, EINA_POSITION2D(0, 150));
283 efl_gfx_size_set(center_btn, EINA_SIZE2D(150, 50));
284 efl_event_callback_add(center_btn, EFL_UI_EVENT_CLICKED, _center_align_cb, p_data);
285
286 Eo *top_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
287 efl_text_set(top_btn, "Top Align");
288 efl_gfx_position_set(top_btn, EINA_POSITION2D(150, 150));
289 efl_gfx_size_set(top_btn, EINA_SIZE2D(150, 50));
290 efl_event_callback_add(top_btn, EFL_UI_EVENT_CLICKED, _top_align_cb, p_data);
291
292 Eo *left_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
293 efl_text_set(left_btn, "Left Align");
294 efl_gfx_position_set(left_btn, EINA_POSITION2D(0, 200));
295 efl_gfx_size_set(left_btn, EINA_SIZE2D(150, 50));
296 efl_event_callback_add(left_btn, EFL_UI_EVENT_CLICKED, _left_align_cb, p_data);
297
298 Eo *right_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
299 efl_text_set(right_btn, "Right Align");
300 efl_gfx_position_set(right_btn, EINA_POSITION2D(150, 200));
301 efl_gfx_size_set(right_btn, EINA_SIZE2D(150, 50));
302 efl_event_callback_add(right_btn, EFL_UI_EVENT_CLICKED, _right_align_cb, p_data);
303
304 Eo *bottom_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
305 efl_text_set(bottom_btn, "Bottom Align");
306 efl_gfx_position_set(bottom_btn, EINA_POSITION2D(0, 250));
307 efl_gfx_size_set(bottom_btn, EINA_SIZE2D(150, 50));
308 efl_event_callback_add(bottom_btn, EFL_UI_EVENT_CLICKED, _bottom_align_cb, p_data);
309
310 Eo *position_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
311 efl_text_set(position_btn, "Position Set (x:0, y:0)");
312 efl_gfx_position_set(position_btn, EINA_POSITION2D(150, 250));
313 efl_gfx_size_set(position_btn, EINA_SIZE2D(150, 50));
314 efl_event_callback_add(position_btn, EFL_UI_EVENT_CLICKED, _position_set_cb, p_data);
315}
316
317static void
318efl_ui_popup_alert_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
319{
320 Efl_Ui_Popup_Alert_Clicked_Event *event = ev->info;
321
322 if (event->button_type == EFL_UI_POPUP_ALERT_BUTTON_POSITIVE)
323 printf("Positive Button is clicked\n");
324 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE)
325 printf("Negative Button is clicked\n");
326 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_USER)
327 printf("User Button is clicked\n");
328}
329
330void
331test_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
332{
333 char buf[PATH_MAX];
334
335 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
336 efl_text_set(efl_added, "Efl.Ui.Popup.Alert"),
337 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
338
339 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
340
341 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
342
343 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
344
345 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
346
347 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, efl_ui_popup);
348 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
349 efl_file_set(layout, buf, "efl_ui_popup_scroll_content");
350
351 efl_content_set(efl_ui_popup, layout);
352 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
353 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
354 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
355
356 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
357}
358
359void
360test_ui_popup_alert_scroll(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
361{
362 char buf[PATH_MAX];
363
364 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
365 efl_text_set(efl_added, "Efl.Ui.Popup.Alert.Scroll"),
366 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
367
368 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
369
370 Eo *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_SCROLL_CLASS, win);
371
372 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
373
374 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
375
376 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, efl_ui_popup);
377 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
378 efl_file_set(layout, buf, "efl_ui_popup_scroll_content");
379
380 efl_content_set(efl_ui_popup, layout);
381
382 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
383 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
384 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
385
386 efl_ui_popup_alert_scroll_expandable_set(efl_ui_popup, EINA_TRUE, EINA_TRUE);
387 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(300, 180));
388
389 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
390}
391
392void
393test_ui_popup_alert_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
394{
395 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
396 efl_text_set(efl_added, "Efl.Ui.Popup.Alert.Text"),
397 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
398
399 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
400
401 Eo *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_TEXT_CLASS, win);
402
403 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
404
405 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
406
407 efl_text_set(efl_ui_popup,
408 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
409 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
410 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup");
411
412 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
413 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
414 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
415
416 efl_ui_popup_alert_text_expandable_set(efl_ui_popup, EINA_TRUE);
417 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(100, 180));
418
419 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
420}
421
422static void
423_anchor_set_cb(void *data, const Efl_Event *ev)
424{
425 efl_ui_popup_anchor_set(data, ev->object);
426}
427
428static void
429_anchor_unset_cb(void *data, const Efl_Event *ev EINA_UNUSED)
430{
431 efl_ui_popup_anchor_set(data, NULL);
432}
433
434void
435test_ui_popup_anchor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
436{
437 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
438
439 char buf[PATH_MAX];
440
441 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
442 efl_text_set(efl_added, "Efl.Ui.Popup.Anchor"),
443 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
444 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _win_del, p_data);
445
446 efl_gfx_size_set(win, EINA_SIZE2D(500, 500));
447
448 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, win);
449 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
450 efl_file_set(layout, buf, "efl_ui_popup_anchor_layout");
451 efl_gfx_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
452 efl_content_set(win, layout);
453
454 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ANCHOR_CLASS, win);
455
456 efl_ui_popup_bg_repeat_events_set(efl_ui_popup, EINA_TRUE);
457
458 //Default align priority order is top, left, right, bottom, center.
459 efl_ui_popup_anchor_align_priority_set(efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP,
460 EFL_UI_POPUP_ALIGN_BOTTOM,
461 EFL_UI_POPUP_ALIGN_LEFT,
462 EFL_UI_POPUP_ALIGN_RIGHT,
463 EFL_UI_POPUP_ALIGN_CENTER);
464
465 efl_gfx_position_set(efl_ui_popup, EINA_POSITION2D(80, 80));
466 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 120));
467
468 p_data->win = win;
469 p_data->efl_ui_popup = efl_ui_popup;
470
471 Eo *btn = NULL;
472 for (int i = 0; i < 6; i++)
473 {
474 btn = efl_add(EFL_UI_BUTTON_CLASS, win);
475 efl_text_set(btn, "anchor");
476 efl_gfx_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
477 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _anchor_set_cb, efl_ui_popup);
478
479 snprintf(buf, sizeof(buf), "anchor%d", i+1);
480 efl_content_set(efl_part(layout, buf), btn);
481 }
482
483 btn = efl_add(EFL_UI_BUTTON_CLASS, win);
484 efl_text_set(btn, "anchor none");
485 efl_gfx_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
486 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _anchor_unset_cb, efl_ui_popup);
487 efl_content_set(efl_part(layout, "anchor_none"), btn);
488
489 Eo *grid = efl_add(EFL_UI_GRID_CLASS, efl_ui_popup);
490 efl_gfx_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
491
492 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
493 efl_text_set(btn, "Center Align");
494 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
495 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _center_align_cb, p_data);
496 efl_pack_grid(grid, btn, 0, 0, 1, 1);
497
498 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
499 efl_text_set(btn, "Left Align");
500 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
501 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _left_align_cb, p_data);
502 efl_pack_grid(grid, btn, 1, 0, 1, 1);
503
504 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
505 efl_text_set(btn, "Right Align");
506 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
507 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _right_align_cb, p_data);
508 efl_pack_grid(grid, btn, 2, 0, 1, 1);
509
510 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
511 efl_text_set(btn, "Top Align");
512 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
513 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _top_align_cb, p_data);
514 efl_pack_grid(grid, btn, 0, 1, 1, 1);
515
516 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
517 efl_text_set(btn, "Bottom Align");
518 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
519 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _bottom_align_cb, p_data);
520 efl_pack_grid(grid, btn, 1, 1, 1, 1);
521
522 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
523 efl_text_set(btn, "Position Set");
524 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
525 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _position_set_cb, p_data);
526 efl_pack_grid(grid, btn, 2, 1, 1, 1);
527
528 efl_content_set(efl_ui_popup, grid);
529}