summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_ui_pager_scroll.c
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2019-01-25 09:41:24 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2019-01-25 09:49:49 +0100
commit41977fd19e2abeebb90f885af599d9ece2fb4406 (patch)
tree32a8b1aaf03a18062fc6c02228801ac7d1bb8f38 /src/bin/elementary/test_ui_pager_scroll.c
parenta686b7d9fee99c631756eca2ce3e2dad1e296f0d (diff)
Revert "Revert "efl_ui_pager: add tests for efl_ui_pager""
This reverts commit a686b7d9fee99c631756eca2ce3e2dad1e296f0d. Turns out in my eagerness to un-break the build I did not check the patch queue before reverting. If I would have done this I would have seen the fix for the break alreay being submitted by Junsu Choi. This is my bad, the two reverts could have been avoid. Sorry. Note to self: give yourself a moment, and check the patch queue, before rushing out a revert. :/
Diffstat (limited to 'src/bin/elementary/test_ui_pager_scroll.c')
-rw-r--r--src/bin/elementary/test_ui_pager_scroll.c934
1 files changed, 934 insertions, 0 deletions
diff --git a/src/bin/elementary/test_ui_pager_scroll.c b/src/bin/elementary/test_ui_pager_scroll.c
new file mode 100644
index 0000000..b336f11
--- /dev/null
+++ b/src/bin/elementary/test_ui_pager_scroll.c
@@ -0,0 +1,934 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#define EO_BETA_API
5#define EFL_UI_WIDGET_PROTECTED
6
7#include <Elementary.h>
8
9
10#define PAGE_NUM 3
11
12
13/** |----------panes----------|
14 * ||--left---| |---right---||
15 * || | | layout ||
16 * || | ||---------|||
17 * ||naviframe| || pager |||
18 * || | || |||
19 * || | ||---------|||
20 * ||---------| |-----------||
21 * |-------------------------|
22 *
23 */
24
25
26typedef enum _Page_Type {
27 LAYOUT,
28 LIST,
29 BUTTON
30} Page_Type;
31
32typedef enum _Pack_Type {
33 PACK_BEGIN,
34 PACK_END,
35 PACK_BEFORE,
36 PACK_AFTER,
37 PACK_AT,
38 UNPACK_AT
39} Pack_Type;
40
41typedef struct _Params {
42 Evas_Object *navi;
43 Eo *pager;
44 Eo *transition;
45 Eo *indicator;
46 int w, h;
47 int padding;
48 int side_page_num;
49 int curr_page;
50 Eina_Bool prev_block, next_block;
51 Eina_Bool wfill, hfill;
52} Params;
53
54typedef struct _Page_Set_Params {
55 Eo *pager;
56 Eo *spinner;
57} Page_Set_Params;
58
59typedef struct _Pack_Params {
60 Pack_Type type;
61 Eo *pager;
62 Eo *pack_sp;
63 Eo *unpack_sp;
64 Eo *unpack_btn;
65} Pack_Params;
66
67typedef struct _Size_Params {
68 Eo *pager;
69 Eo *slider;
70 Params *params;
71} Size_Params;
72
73
74
75static Eo *page_add(Page_Type p, Eo *parent)
76{
77 Eo *page;
78 char buf[PATH_MAX];
79 int i;
80
81 switch (p) {
82 case LAYOUT:
83 snprintf(buf, sizeof(buf), "%s/objects/test_pager.edj",
84 elm_app_data_dir_get());
85 page = efl_add(EFL_UI_LAYOUT_CLASS, parent,
86 efl_file_set(efl_added, buf, "page"),
87 efl_text_set(efl_part(efl_added, "text"), "Layout Page"));
88 efl_gfx_size_hint_fill_set(page, EINA_TRUE, EINA_TRUE);
89 break;
90 case LIST:
91 page = elm_list_add(parent);
92 elm_list_select_mode_set(page, ELM_OBJECT_SELECT_MODE_ALWAYS);
93 evas_object_show(page);
94 for (i = 0; i < 20; i++) {
95 snprintf(buf, sizeof(buf), "List Page - Item #%d", i);
96 elm_list_item_append(page, buf, NULL, NULL, NULL, NULL);
97 }
98 evas_object_size_hint_weight_set(page, EVAS_HINT_EXPAND,
99 EVAS_HINT_EXPAND);
100 evas_object_size_hint_align_set(page, EVAS_HINT_FILL,
101 EVAS_HINT_FILL);
102 break;
103 case BUTTON:
104 page = efl_add(EFL_UI_BUTTON_CLASS, parent,
105 efl_text_set(efl_added, "Button Page"));
106 efl_gfx_size_hint_fill_set(page, EINA_TRUE, EINA_TRUE);
107 break;
108 default:
109 snprintf(buf, sizeof(buf), "%s/objects/test_pager.edj",
110 elm_app_data_dir_get());
111 page = efl_add(EFL_UI_LAYOUT_CLASS, parent,
112 efl_file_set(efl_added, buf, "page"),
113 efl_text_set(efl_part(efl_added, "text"), "Layout Page"));
114 efl_gfx_size_hint_fill_set(page, EINA_TRUE, EINA_TRUE);
115 break;
116 }
117
118 return page;
119}
120
121static void prev_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
122{
123 Eo *pager = data;
124 int curr_page = efl_ui_pager_current_page_get(pager);
125
126 efl_ui_pager_current_page_set(pager, (curr_page - 1));
127}
128
129static void next_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
130{
131 Eo *pager = data;
132 int curr_page = efl_ui_pager_current_page_get(pager);
133
134 efl_ui_pager_current_page_set(pager, (curr_page + 1));
135}
136
137static void back_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
138{
139 elm_naviframe_item_pop(data);
140}
141
142static void list_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
143{
144 free(data);
145}
146
147static void width_slider_cb(void *data, const Efl_Event *ev)
148{
149 Params *params = data;
150 int h;
151
152 if (params->hfill) h = -1;
153 else h = params->h;
154
155 params->w = efl_ui_range_value_get(ev->object);
156 efl_ui_pager_page_size_set(params->pager, EINA_SIZE2D(params->w, h));
157}
158
159static void height_slider_cb(void *data, const Efl_Event *ev)
160{
161 Params *params = data;
162 int w;
163
164 if (params->wfill) w = -1;
165 else w = params->w;
166
167 params->h = efl_ui_range_value_get(ev->object);
168 efl_ui_pager_page_size_set(params->pager, EINA_SIZE2D(w, params->h));
169}
170
171static void width_check_cb(void *data, const Efl_Event *ev)
172{
173 Size_Params *params = data;
174 Eina_Bool ck = elm_check_selected_get(ev->object);
175 int w, h;
176
177 elm_object_disabled_set(params->slider, ck);
178
179 params->params->wfill = ck;
180
181 if (params->params->wfill) w = -1;
182 else w = params->params->w;
183
184 if (params->params->hfill) h = -1;
185 else h = params->params->h;
186
187 efl_ui_pager_page_size_set(params->pager, EINA_SIZE2D(w, h));
188}
189
190static void height_check_cb(void *data, const Efl_Event *ev)
191{
192 Size_Params *params = data;
193 Eina_Bool ck = elm_check_selected_get(ev->object);
194 int w, h;
195
196 elm_object_disabled_set(params->slider, ck);
197
198 params->params->hfill = ck;
199
200 if (params->params->wfill) w = -1;
201 else w = params->params->w;
202
203 if (params->params->hfill) h = -1;
204 else h = params->params->h;
205
206 efl_ui_pager_page_size_set(params->pager, EINA_SIZE2D(w, h));
207}
208
209static void check_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
210{
211 free(data);
212}
213
214static void padding_slider_cb(void *data, const Efl_Event *ev)
215{
216 Params *params = (Params *) data;
217
218 params->padding = efl_ui_range_value_get(ev->object);
219 efl_ui_pager_padding_set(params->pager, params->padding);
220}
221
222static void side_page_num_slider_cb(void *data, const Efl_Event *ev)
223{
224 Params *params = (Params *) data;
225
226 params->side_page_num = efl_ui_range_value_get(ev->object);
227 efl_page_transition_scroll_side_page_num_set(params->transition,
228 params->side_page_num);
229}
230
231static void pack_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
232{
233 Pack_Params *param = data;
234 Eo *pager = param->pager;
235 Eo *page, *curr_page;
236 int index, cnt;
237
238 if (param->type != UNPACK_AT) {
239 index = efl_content_count(pager);
240
241 switch (index % 3) {
242 case 0:
243 page = page_add(LAYOUT, pager);
244 break;
245 case 1:
246 page = page_add(LIST, pager);
247 break;
248 case 2:
249 page = page_add(BUTTON, pager);
250 break;
251 default:
252 page = page_add(LAYOUT, pager);
253 break;
254 }
255 }
256
257 switch (param->type) {
258 case PACK_BEGIN:
259 efl_pack_begin(pager, page);
260 break;
261 case PACK_END:
262 efl_pack_end(pager, page);
263 break;
264 case PACK_BEFORE:
265 index = efl_ui_pager_current_page_get(pager);
266 curr_page = efl_pack_content_get(pager, index);
267 efl_pack_before(pager, page, curr_page);
268 break;
269 case PACK_AFTER:
270 index = efl_ui_pager_current_page_get(pager);
271 curr_page = efl_pack_content_get(pager, index);
272 efl_pack_after(pager, page, curr_page);
273 break;
274 case PACK_AT:
275 index = efl_ui_range_value_get(param->pack_sp);
276 efl_pack_at(pager, page, index);
277 break;
278 case UNPACK_AT:
279 index = efl_ui_range_value_get(param->unpack_sp);
280 page = efl_pack_content_get(pager, index);
281 efl_pack_unpack(pager, page);
282 efl_del(page);
283 break;
284 }
285
286 cnt = efl_content_count(pager);
287
288 index = efl_ui_range_value_get(param->pack_sp);
289 if (index > cnt)
290 efl_ui_range_value_set(param->pack_sp, cnt);
291 efl_ui_range_min_max_set(param->pack_sp, 0, cnt);
292
293 if (cnt > 0)
294 {
295 elm_object_disabled_set(param->unpack_btn, EINA_FALSE);
296 elm_object_disabled_set(param->unpack_sp, EINA_FALSE);
297
298 cnt -= 1;
299 index = efl_ui_range_value_get(param->unpack_sp);
300 if (index > cnt)
301 efl_ui_range_value_set(param->unpack_sp, cnt);
302 efl_ui_range_min_max_set(param->unpack_sp, 0, cnt);
303 }
304 else
305 {
306 elm_object_disabled_set(param->unpack_btn, EINA_TRUE);
307 elm_object_disabled_set(param->unpack_sp, EINA_TRUE);
308 }
309}
310
311static void pack_btn_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
312{
313 free(data);
314}
315
316static void page_set_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
317{
318 Page_Set_Params *psp = data;
319
320 efl_ui_pager_current_page_set(psp->pager,
321 efl_ui_range_value_get(psp->spinner));
322}
323
324static void page_set_btn_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
325{
326 free(data);
327}
328
329static void prev_block_check_cb(void *data, const Efl_Event *ev)
330{
331 Eo *pager = data;
332 Eina_Bool prev, next;
333
334 prev = efl_ui_nstate_value_get(ev->object);
335
336 efl_ui_pager_scroll_block_get(pager, NULL, &next);
337 efl_ui_pager_scroll_block_set(pager, prev, next);
338}
339
340static void next_block_check_cb(void *data, const Efl_Event *ev)
341{
342 Eo *pager = data;
343 Eina_Bool prev, next;
344
345 next = efl_ui_nstate_value_get(ev->object);
346
347 efl_ui_pager_scroll_block_get(pager, &prev, NULL);
348 efl_ui_pager_scroll_block_set(pager, prev, next);
349}
350
351static void loop_check_cb(void *data, const Efl_Event *ev)
352{
353 Eo *pager = data;
354 int state = efl_ui_nstate_value_get(ev->object);
355
356 //FIXME use other widget (i.e. radio) than check
357 // since loop might not be enabled according to the number of items
358 efl_ui_pager_loop_mode_set(pager, state);
359}
360
361static void indicator_icon_btn_cb(void *data,
362 const Efl_Event *ev EINA_UNUSED)
363{
364 Params *params = data;
365
366 params->indicator = efl_add(EFL_PAGE_INDICATOR_ICON_CLASS, params->pager);
367 efl_ui_pager_indicator_set(params->pager, params->indicator);
368}
369
370static void indicator_none_btn_cb(void *data,
371 const Efl_Event *ev EINA_UNUSED)
372{
373 Params *params = data;
374 efl_ui_pager_indicator_set(params->pager, NULL);
375}
376
377static void page_size_cb(void *data,
378 Evas_Object *obj EINA_UNUSED,
379 void *event_info EINA_UNUSED)
380{
381 Params *params = data;
382 Size_Params *size_params;
383 Evas_Object *navi = params->navi;
384 Eo *btn, *box, *fr, *inbox, *ck, *sl;
385
386 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
387 efl_text_set(efl_added, "Back"),
388 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
389 back_btn_cb, navi));
390
391 box = efl_add(EFL_UI_BOX_CLASS, navi,
392 elm_naviframe_item_push(navi, "Page Size", btn, NULL,
393 efl_added, NULL));
394
395 // Width
396 fr = elm_frame_add(box);
397 elm_object_text_set(fr, "Width");
398 efl_gfx_size_hint_align_set(fr, -1, -1);
399 efl_gfx_size_hint_weight_set(fr, 1, 1);
400 efl_pack(box, fr);
401 efl_gfx_entity_visible_set(fr, 1);
402
403 inbox = efl_add(EFL_UI_BOX_CLASS, fr,
404 efl_content_set(fr, efl_added));
405
406 ck = elm_check_add(inbox);
407 elm_object_text_set(ck, "Fill");
408 efl_pack_end(inbox, ck);
409 efl_gfx_entity_visible_set(ck, 1);
410
411 sl = efl_add(EFL_UI_SLIDER_CLASS, inbox,
412 efl_ui_range_min_max_set(efl_added, 100, 200),
413 efl_ui_range_value_set(efl_added, params->w),
414 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 0)),
415 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED,
416 width_slider_cb, params),
417 efl_pack_end(inbox, efl_added));
418
419 size_params = calloc(1, sizeof(Size_Params));
420 size_params->slider = sl;
421 size_params->pager = params->pager;
422 size_params->params = params;
423
424 efl_event_callback_add(ck, EFL_UI_CHECK_EVENT_CHANGED, width_check_cb,
425 size_params);
426 efl_event_callback_add(ck, EFL_EVENT_DEL, check_del_cb, size_params);
427
428 if (params->wfill)
429 {
430 elm_check_state_set(ck, EINA_TRUE);
431 elm_object_disabled_set(sl, EINA_TRUE);
432 }
433
434 // Height
435 fr = elm_frame_add(box);
436 elm_object_text_set(fr, "Height");
437 efl_gfx_size_hint_align_set(fr, -1, -1);
438 efl_gfx_size_hint_weight_set(fr, 1, 1);
439 efl_pack(box, fr);
440 efl_gfx_entity_visible_set(fr, 1);
441
442 inbox = efl_add(EFL_UI_BOX_CLASS, fr,
443 efl_content_set(fr, efl_added));
444
445 ck = elm_check_add(inbox);
446 elm_object_text_set(ck, "Fill");
447 efl_pack_end(inbox, ck);
448 efl_gfx_entity_visible_set(ck, 1);
449
450 sl = efl_add(EFL_UI_SLIDER_CLASS, inbox,
451 efl_ui_range_min_max_set(efl_added, 100, 300),
452 efl_ui_range_value_set(efl_added, params->h),
453 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 0)),
454 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED,
455 height_slider_cb, params),
456 efl_pack_end(inbox, efl_added));
457
458 size_params = calloc(1, sizeof(Size_Params));
459 size_params->slider = sl;
460 size_params->pager = params->pager;
461 size_params->params = params;
462
463 efl_event_callback_add(ck, EFL_UI_CHECK_EVENT_CHANGED, height_check_cb,
464 size_params);
465 efl_event_callback_add(ck, EFL_EVENT_DEL, check_del_cb, size_params);
466
467 if (params->hfill)
468 {
469 elm_check_state_set(ck, EINA_TRUE);
470 elm_object_disabled_set(sl, EINA_TRUE);
471 }
472}
473
474static void padding_cb(void *data,
475 Evas_Object *obj EINA_UNUSED,
476 void *event_info EINA_UNUSED)
477{
478 Params *params = (Params *)data;
479 Evas_Object *navi = params->navi;
480 Eo *btn, *box;
481
482 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
483 efl_text_set(efl_added, "Back"),
484 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
485 back_btn_cb, navi));
486
487 box = efl_add(EFL_UI_BOX_CLASS, navi,
488 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
489 elm_naviframe_item_push(navi, "Padding Size", btn, NULL,
490 efl_added, NULL));
491
492 efl_add(EFL_UI_SLIDER_CLASS, box,
493 efl_ui_range_min_max_set(efl_added, 0, 50),
494 efl_ui_range_value_set(efl_added, params->padding),
495 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(100, 0)),
496 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED,
497 padding_slider_cb, params),
498 efl_pack_end(box, efl_added));
499}
500
501static void side_page_num_cb(void *data,
502 Evas_Object *obj EINA_UNUSED,
503 void *event_info EINA_UNUSED)
504{
505 Params *params = (Params *)data;
506 Evas_Object *navi = params->navi;
507 Eo *btn, *box;
508
509 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
510 efl_text_set(efl_added, "Back"),
511 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
512 back_btn_cb, navi));
513
514 box = efl_add(EFL_UI_BOX_CLASS, navi,
515 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
516 elm_naviframe_item_push(navi, "Side Page Num", btn, NULL,
517 efl_added, NULL));
518
519 efl_add(EFL_UI_SLIDER_CLASS, box,
520 efl_text_set(efl_added, "side page num"),
521 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
522 efl_ui_range_min_max_set(efl_added, 0, 3),
523 efl_ui_range_value_set(efl_added, params->side_page_num),
524 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
525 efl_gfx_size_hint_weight_set(efl_added, 1, 1),
526 efl_gfx_size_hint_align_set(efl_added, -1, -1),
527 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED,
528 side_page_num_slider_cb, params),
529 efl_pack_end(box, efl_added));
530}
531
532static void pack_cb(void *data,
533 Evas_Object *obj EINA_UNUSED,
534 void *event_info EINA_UNUSED)
535{
536 Params *params = (Params *)data;
537 Evas_Object *navi = params->navi;
538 Eo *pager = params->pager;
539 Eo *btn, *box, *in_box1, *in_box2, *sp1, *sp2;
540 Pack_Params *pack_param;
541
542 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
543 efl_text_set(efl_added, "Back"),
544 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
545 back_btn_cb, navi));
546
547 box = efl_add(EFL_UI_BOX_CLASS, navi,
548 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
549 elm_naviframe_item_push(navi, "Pack", btn, NULL,
550 efl_added, NULL));
551
552 in_box1 = efl_add(EFL_UI_BOX_CLASS, box,
553 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
554 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL));
555
556 sp1 = efl_add(EFL_UI_SPIN_BUTTON_CLASS, in_box1,
557 efl_ui_range_min_max_set(efl_added, 0,
558 efl_content_count(pager)),
559 efl_ui_range_value_set(efl_added,
560 efl_ui_pager_current_page_get(pager)));
561
562 in_box2 = efl_add(EFL_UI_BOX_CLASS, box,
563 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
564 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL));
565
566 sp2 = efl_add(EFL_UI_SPIN_BUTTON_CLASS, in_box2);
567
568 btn = efl_add(EFL_UI_BUTTON_CLASS, in_box2,
569 efl_text_set(efl_added, "Unpack At"));
570
571 // Pack Begin
572 pack_param = calloc(1, sizeof(Pack_Params));
573 pack_param->pager = pager;
574 pack_param->pack_sp = sp1;
575 pack_param->unpack_sp = sp2;
576 pack_param->unpack_btn = btn;
577 pack_param->type = PACK_BEGIN;
578
579 efl_add(EFL_UI_BUTTON_CLASS, box,
580 efl_text_set(efl_added, "Pack Begin"),
581 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
582 pack_btn_cb, pack_param),
583 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
584 pack_btn_del_cb, pack_param),
585 efl_pack_end(box, efl_added));
586
587 // Pack End
588 pack_param = calloc(1, sizeof(Pack_Params));
589 pack_param->pager = pager;
590 pack_param->pack_sp = sp1;
591 pack_param->unpack_sp = sp2;
592 pack_param->unpack_btn = btn;
593 pack_param->type = PACK_END;
594
595 efl_add(EFL_UI_BUTTON_CLASS, box,
596 efl_text_set(efl_added, "Pack End"),
597 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
598 pack_btn_cb, pack_param),
599 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
600 pack_btn_del_cb, pack_param),
601 efl_pack_end(box, efl_added));
602
603 // Pack Before
604 pack_param = calloc(1, sizeof(Pack_Params));
605 pack_param->pager = pager;
606 pack_param->pack_sp = sp1;
607 pack_param->unpack_sp = sp2;
608 pack_param->unpack_btn = btn;
609 pack_param->type = PACK_BEFORE;
610
611 efl_add(EFL_UI_BUTTON_CLASS, box,
612 efl_text_set(efl_added, "Pack Before Current Page"),
613 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
614 pack_btn_cb, pack_param),
615 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
616 pack_btn_del_cb, pack_param),
617 efl_pack_end(box, efl_added));
618
619 // Pack After
620 pack_param = calloc(1, sizeof(Pack_Params));
621 pack_param->pager = pager;
622 pack_param->pack_sp = sp1;
623 pack_param->unpack_sp = sp2;
624 pack_param->unpack_btn = btn;
625 pack_param->type = PACK_AFTER;
626
627 efl_add(EFL_UI_BUTTON_CLASS, box,
628 efl_text_set(efl_added, "Pack After Current Page"),
629 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
630 pack_btn_cb, pack_param),
631 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
632 pack_btn_del_cb, pack_param),
633 efl_pack_end(box, efl_added));
634
635 // Pack At
636 pack_param = calloc(1, sizeof(Pack_Params));
637 pack_param->pager = pager;
638 pack_param->pack_sp = sp1;
639 pack_param->unpack_sp = sp2;
640 pack_param->unpack_btn = btn;
641 pack_param->type = PACK_AT;
642
643 efl_add(EFL_UI_BUTTON_CLASS, in_box1,
644 efl_text_set(efl_added, "Pack At"),
645 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
646 pack_btn_cb, pack_param),
647 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
648 pack_btn_del_cb, pack_param),
649 efl_pack_end(in_box1, efl_added));
650
651 efl_pack_end(box, in_box1);
652 efl_pack_end(in_box1, sp1);
653
654 // Unpack At
655 pack_param = calloc(1, sizeof(Pack_Params));
656 pack_param->pager = pager;
657 pack_param->pack_sp = sp1;
658 pack_param->unpack_sp = sp2;
659 pack_param->unpack_btn = btn;
660 pack_param->type = UNPACK_AT;
661
662 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED,
663 pack_btn_cb, pack_param);
664 efl_event_callback_add(btn, EFL_EVENT_DEL,
665 pack_btn_del_cb, pack_param);
666
667 if (efl_content_count(pager) > 0)
668 {
669 efl_ui_range_min_max_set(sp2, 0,
670 (efl_content_count(pager) - 1));
671 efl_ui_range_value_set(sp2,
672 efl_ui_pager_current_page_get(pager));
673 }
674 else
675 {
676 elm_object_disabled_set(btn, EINA_TRUE);
677 elm_object_disabled_set(sp2, EINA_TRUE);
678 }
679
680 efl_pack_end(box, in_box2);
681 efl_pack_end(in_box2, btn);
682 efl_pack_end(in_box2, sp2);
683}
684
685static void current_page_cb(void *data,
686 Evas_Object *obj EINA_UNUSED,
687 void *event_info EINA_UNUSED)
688{
689 Params *params = (Params *)data;
690 Evas_Object *navi = params->navi;
691 Eo *pager = params->pager;
692 Eo *btn, *box, *sp;
693 Page_Set_Params *psp = calloc(1, sizeof(Page_Set_Params));
694
695 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
696 efl_text_set(efl_added, "Back"),
697 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
698 back_btn_cb, navi));
699
700 box = efl_add(EFL_UI_BOX_CLASS, navi,
701 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
702 elm_naviframe_item_push(navi, "Current Page", btn, NULL,
703 efl_added, NULL));
704
705 btn = efl_add(EFL_UI_BUTTON_CLASS, box,
706 efl_text_set(efl_added, "Set Current Page As"),
707 efl_pack_end(box, efl_added));
708
709 sp = efl_add(EFL_UI_SPIN_BUTTON_CLASS, box,
710 efl_gfx_size_hint_align_set(efl_added, -1, -1),
711 efl_pack_end(box, efl_added));
712
713 if (efl_content_count(pager) > 0)
714 {
715 efl_ui_range_min_max_set(sp, 0,
716 (efl_content_count(pager) - 1));
717 efl_ui_range_value_set(sp,
718 efl_ui_pager_current_page_get(pager));
719 }
720 else
721 {
722 elm_object_disabled_set(btn, EINA_TRUE);
723 elm_object_disabled_set(sp, EINA_TRUE);
724 }
725
726 psp->pager = pager;
727 psp->spinner = sp;
728
729 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, page_set_btn_cb, psp);
730 efl_event_callback_add(btn, EFL_EVENT_DEL, page_set_btn_del_cb, psp);
731}
732
733static void scroll_block_cb(void *data,
734 Evas_Object *obj EINA_UNUSED,
735 void *event_info EINA_UNUSED)
736{
737 Params *params = (Params *)data;
738 Evas_Object *navi = params->navi;
739 Eo *pager = params->pager;
740 Eo *btn, *box;
741 Eina_Bool prev, next;
742
743 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
744 efl_text_set(efl_added, "Back"),
745 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
746 back_btn_cb, navi));
747
748 box = efl_add(EFL_UI_BOX_CLASS, navi,
749 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
750 elm_naviframe_item_push(navi, "Scroll Block", btn, NULL,
751 efl_added, NULL));
752
753 efl_ui_pager_scroll_block_get(pager, &prev, &next);
754
755 efl_add(EFL_UI_CHECK_CLASS, box,
756 efl_ui_widget_style_set(efl_added, "toggle"),
757 efl_text_set(efl_added, "Prev Block"),
758 efl_ui_nstate_value_set(efl_added, prev),
759 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED,
760 prev_block_check_cb, pager),
761 efl_pack_end(box, efl_added));
762
763 efl_add(EFL_UI_CHECK_CLASS, box,
764 efl_ui_widget_style_set(efl_added, "toggle"),
765 efl_text_set(efl_added, "Next Block"),
766 efl_ui_nstate_value_set(efl_added, next),
767 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED,
768 next_block_check_cb, pager),
769 efl_pack_end(box, efl_added));
770}
771
772static void loop_cb(void *data EINA_UNUSED,
773 Evas_Object *obj EINA_UNUSED,
774 void *event_info EINA_UNUSED)
775{
776 Params *params = (Params *)data;
777 Evas_Object *navi = params->navi;
778 Eo *pager = params->pager;
779 Eo *btn, *box;
780
781 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
782 efl_text_set(efl_added, "Back"),
783 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
784 back_btn_cb, navi));
785
786 box = efl_add(EFL_UI_BOX_CLASS, navi,
787 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
788 elm_naviframe_item_push(navi, "Loop", btn, NULL,
789 efl_added, NULL));
790
791 efl_add(EFL_UI_CHECK_CLASS, box,
792 efl_ui_widget_style_set(efl_added, "toggle"),
793 efl_text_set(efl_added, "Loop"),
794 efl_ui_nstate_value_set(efl_added, efl_ui_pager_loop_mode_get(pager)),
795 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED,
796 loop_check_cb, pager),
797 efl_pack_end(box, efl_added));
798}
799
800static void indicator_cb(void *data EINA_UNUSED,
801 Evas_Object *obj EINA_UNUSED,
802 void *event_info EINA_UNUSED)
803{
804 Params *params = (Params *)data;
805 Evas_Object *navi = params->navi;
806 Eo *btn, *box;
807
808 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
809 efl_text_set(efl_added, "Back"),
810 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
811 back_btn_cb, navi));
812
813 box = efl_add(EFL_UI_BOX_CLASS, navi,
814 efl_pack_padding_set(efl_added, 10, 10, EINA_TRUE),
815 elm_naviframe_item_push(navi, "Indicator", btn, NULL,
816 efl_added, NULL));
817
818 efl_add(EFL_UI_BUTTON_CLASS, box,
819 efl_text_set(efl_added, "Icon Type"),
820 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
821 indicator_icon_btn_cb, params),
822 efl_pack_end(box, efl_added));
823
824 efl_add(EFL_UI_BUTTON_CLASS, box,
825 efl_text_set(efl_added, "None"),
826 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
827 indicator_none_btn_cb, params),
828 efl_pack_end(box, efl_added));
829}
830
831void test_ui_pager_scroll(void *data EINA_UNUSED,
832 Evas_Object *obj EINA_UNUSED,
833 void *event_info EINA_UNUSED)
834{
835 Eo *win, *panes, *navi, *list, *layout, *pager, *page, *tran;
836 Params *params = NULL;
837 char buf[PATH_MAX];
838 int i;
839
840 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
841 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
842 efl_text_set(efl_added, "Pager"),
843 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
844
845 panes = efl_add(EFL_UI_PANES_CLASS, win,
846 efl_gfx_size_hint_weight_set(efl_added, 1, 1),
847 efl_ui_panes_split_ratio_set(efl_added, 0.3),
848 efl_content_set(win, efl_added));
849
850 navi = elm_naviframe_add(panes);
851 evas_object_show(navi);
852 efl_content_set(efl_part(panes, "first"), navi);
853
854 list = elm_list_add(navi);
855 elm_list_horizontal_set(list, EINA_FALSE);
856 elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
857 elm_naviframe_item_push(navi, "Properties", NULL, NULL, list, NULL);
858 evas_object_show(list);
859
860 snprintf(buf, sizeof(buf), "%s/objects/test_pager.edj",
861 elm_app_data_dir_get());
862 layout = efl_add(EFL_UI_LAYOUT_CLASS, panes,
863 efl_file_set(efl_added, buf, "pager"),
864 efl_content_set(efl_part(panes, "second"), efl_added));
865
866 pager = efl_add(EFL_UI_PAGER_CLASS, layout,
867 efl_content_set(efl_part(layout, "pager"), efl_added),
868 efl_ui_pager_page_size_set(efl_added, EINA_SIZE2D(200, 300)),
869 efl_ui_pager_padding_set(efl_added, 20));
870
871 efl_add(EFL_UI_BUTTON_CLASS, layout,
872 efl_text_set(efl_added, "Prev"),
873 efl_event_callback_add(efl_added,
874 EFL_UI_EVENT_CLICKED, prev_btn_cb, pager),
875 efl_content_set(efl_part(layout, "prev_btn"), efl_added));
876
877 efl_add(EFL_UI_BUTTON_CLASS, layout,
878 efl_text_set(efl_added, "Next"),
879 efl_event_callback_add(efl_added,
880 EFL_UI_EVENT_CLICKED, next_btn_cb, pager),
881 efl_content_set(efl_part(layout, "next_btn"), efl_added));
882
883 tran = efl_add(EFL_PAGE_TRANSITION_SCROLL_CLASS, pager,
884 efl_ui_pager_transition_set(pager, efl_added));
885
886 params = calloc(1, sizeof(Params));
887 params->navi = navi;
888 params->pager = pager;
889 params->transition = NULL;
890 params->indicator = NULL;
891 params->w = 200;
892 params->h = 300;
893 params->padding = 20;
894 params->side_page_num = efl_page_transition_scroll_side_page_num_get(tran);
895 params->curr_page = 0;
896 params->wfill = EINA_FALSE;
897 params->hfill = EINA_FALSE;
898 params->prev_block = EINA_FALSE;
899 params->next_block = EINA_FALSE;
900 params->transition = tran;
901
902 elm_list_item_append(list, "Page Size", NULL, NULL, page_size_cb, params);
903 elm_list_item_append(list, "Padding", NULL, NULL, padding_cb, params);
904 elm_list_item_append(list, "Side Page Num", NULL, NULL, side_page_num_cb, params);
905 elm_list_item_append(list, "Pack / Unpack", NULL, NULL, pack_cb, params);
906 elm_list_item_append(list, "Current Page", NULL, NULL, current_page_cb, params);
907 elm_list_item_append(list, "Scroll Block", NULL, NULL, scroll_block_cb, params);
908 elm_list_item_append(list, "Loop", NULL, NULL, loop_cb, params);
909 elm_list_item_append(list, "Indicator", NULL, NULL, indicator_cb, params);
910
911 elm_list_go(list);
912
913 efl_event_callback_add(list, EFL_EVENT_DEL, list_del_cb, params);
914
915 for (i = 0; i < PAGE_NUM; i++) {
916 switch (i % 3) {
917 case 0:
918 page = page_add(LAYOUT, pager);
919 break;
920 case 1:
921 page = page_add(LIST, pager);
922 break;
923 case 2:
924 page = page_add(BUTTON, pager);
925 break;
926 default:
927 page = page_add(LAYOUT, pager);
928 break;
929 }
930 efl_pack_end(pager, page);
931 }
932
933 efl_gfx_entity_size_set(win, EINA_SIZE2D(580, 320));
934}