summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_ui_pager_scroll.c
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2019-02-19 18:42:31 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2019-03-29 20:14:09 +0900
commit30bd541bf264d369e2a96d27fa3ff5139c360e26 (patch)
tree96de90cac283d6b2c8a4476a26e1a432307f4a49 /src/bin/elementary/test_ui_pager_scroll.c
parent74c48f029632d2260816b4cb3de6dbb40a29f040 (diff)
test/efl_ui_pager_scroll: fix demo
- use radio than check for loop mode - use unpack_at function than unpack function - add CLEAR option
Diffstat (limited to 'src/bin/elementary/test_ui_pager_scroll.c')
-rw-r--r--src/bin/elementary/test_ui_pager_scroll.c72
1 files changed, 57 insertions, 15 deletions
diff --git a/src/bin/elementary/test_ui_pager_scroll.c b/src/bin/elementary/test_ui_pager_scroll.c
index f062a9d..7fc6645 100644
--- a/src/bin/elementary/test_ui_pager_scroll.c
+++ b/src/bin/elementary/test_ui_pager_scroll.c
@@ -36,7 +36,8 @@ typedef enum _Pack_Type {
36 PACK_BEFORE, 36 PACK_BEFORE,
37 PACK_AFTER, 37 PACK_AFTER,
38 PACK_AT, 38 PACK_AT,
39 UNPACK_AT 39 UNPACK_AT,
40 CLEAR
40} Pack_Type; 41} Pack_Type;
41 42
42typedef struct _Params { 43typedef struct _Params {
@@ -240,7 +241,7 @@ static void pack_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
240 Eo *page, *curr_page; 241 Eo *page, *curr_page;
241 int index, cnt; 242 int index, cnt;
242 243
243 if (param->type != UNPACK_AT) { 244 if ((param->type != UNPACK_AT) && (param->type != CLEAR)) {
244 index = efl_content_count(pager); 245 index = efl_content_count(pager);
245 246
246 switch (index % 3) { 247 switch (index % 3) {
@@ -282,10 +283,12 @@ static void pack_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
282 break; 283 break;
283 case UNPACK_AT: 284 case UNPACK_AT:
284 index = efl_ui_range_value_get(param->unpack_sp); 285 index = efl_ui_range_value_get(param->unpack_sp);
285 page = efl_pack_content_get(pager, index); 286 page = efl_pack_unpack_at(pager, index);
286 efl_pack_unpack(pager, page);
287 efl_del(page); 287 efl_del(page);
288 break; 288 break;
289 case CLEAR:
290 efl_pack_clear(pager);
291 break;
289 } 292 }
290 293
291 cnt = efl_content_count(pager); 294 cnt = efl_content_count(pager);
@@ -353,13 +356,11 @@ static void next_block_check_cb(void *data, const Efl_Event *ev)
353 efl_ui_pager_scroll_block_set(pager, prev, next); 356 efl_ui_pager_scroll_block_set(pager, prev, next);
354} 357}
355 358
356static void loop_check_cb(void *data, const Efl_Event *ev) 359static void loop_radio_cb(void *data, const Efl_Event *ev)
357{ 360{
358 Eo *pager = data; 361 Eo *pager = data;
359 int state = efl_ui_nstate_value_get(ev->object); 362 int state = efl_ui_nstate_value_get(ev->object);
360 363
361 //FIXME use other widget (i.e. radio) than check
362 // since loop might not be enabled according to the number of items
363 efl_ui_pager_loop_mode_set(pager, state); 364 efl_ui_pager_loop_mode_set(pager, state);
364} 365}
365 366
@@ -701,6 +702,24 @@ static void pack_cb(void *data,
701 efl_pack_end(box, in_box2); 702 efl_pack_end(box, in_box2);
702 efl_pack_end(in_box2, btn); 703 efl_pack_end(in_box2, btn);
703 efl_pack_end(in_box2, sp2); 704 efl_pack_end(in_box2, sp2);
705
706 // Clear
707 pack_param = calloc(1, sizeof(Pack_Params));
708 if (!pack_param) return;
709
710 pack_param->pager = pager;
711 pack_param->pack_sp = sp1;
712 pack_param->unpack_sp = sp2;
713 pack_param->unpack_btn = btn;
714 pack_param->type = CLEAR;
715
716 efl_add(EFL_UI_BUTTON_CLASS, box,
717 efl_text_set(efl_added, "Clear"),
718 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
719 pack_btn_cb, pack_param),
720 efl_event_callback_add(efl_added, EFL_EVENT_DEL,
721 pack_btn_del_cb, pack_param),
722 efl_pack_end(box, efl_added));
704} 723}
705 724
706static void current_page_cb(void *data, 725static void current_page_cb(void *data,
@@ -798,7 +817,8 @@ static void loop_cb(void *data EINA_UNUSED,
798 Params *params = (Params *)data; 817 Params *params = (Params *)data;
799 Evas_Object *navi = params->navi; 818 Evas_Object *navi = params->navi;
800 Eo *pager = params->pager; 819 Eo *pager = params->pager;
801 Eo *btn, *box; 820 Eo *btn, *box, *rd;
821 Efl_Ui_Pager_Loop loop;
802 822
803 btn = efl_add(EFL_UI_BUTTON_CLASS, navi, 823 btn = efl_add(EFL_UI_BUTTON_CLASS, navi,
804 efl_text_set(efl_added, "Back"), 824 efl_text_set(efl_added, "Back"),
@@ -810,13 +830,35 @@ static void loop_cb(void *data EINA_UNUSED,
810 elm_naviframe_item_push(navi, "Loop", btn, NULL, 830 elm_naviframe_item_push(navi, "Loop", btn, NULL,
811 efl_added, NULL)); 831 efl_added, NULL));
812 832
813 efl_add(EFL_UI_CHECK_CLASS, box, 833 rd = efl_add(EFL_UI_RADIO_CLASS, box,
814 efl_ui_widget_style_set(efl_added, "toggle"), 834 efl_ui_radio_state_value_set(efl_added, EFL_UI_PAGER_LOOP_DISABLED),
815 efl_text_set(efl_added, "Loop"), 835 efl_text_set(efl_added, "Disabled"),
816 efl_ui_nstate_value_set(efl_added, efl_ui_pager_loop_mode_get(pager)), 836 efl_gfx_hint_weight_set(efl_added, 1, 0),
817 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED, 837 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED,
818 loop_check_cb, pager), 838 loop_radio_cb, pager),
819 efl_pack_end(box, efl_added)); 839 efl_pack(box, efl_added));
840
841 rd = efl_add(EFL_UI_RADIO_CLASS, box,
842 efl_ui_radio_state_value_set(efl_added, EFL_UI_PAGER_LOOP_ENABLED),
843 efl_ui_radio_group_add(efl_added, rd),
844 efl_text_set(efl_added, "Enabled"),
845 efl_gfx_hint_weight_set(efl_added, 1, 0),
846 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED,
847 loop_radio_cb, pager),
848 efl_pack(box, efl_added));
849
850 loop = efl_ui_pager_loop_mode_get(pager);
851
852 efl_ui_nstate_value_set(rd, loop);
853
854 if (loop == EFL_UI_PAGER_LOOP_DISABLED)
855 {
856 Eina_Bool ret = efl_ui_pager_loop_mode_set(pager, EFL_UI_PAGER_LOOP_ENABLED);
857 if (!ret)
858 elm_object_disabled_set(rd, EINA_TRUE);
859 else
860 efl_ui_pager_loop_mode_set(pager, EFL_UI_PAGER_LOOP_DISABLED);
861 }
820} 862}
821 863
822static void indicator_cb(void *data EINA_UNUSED, 864static void indicator_cb(void *data EINA_UNUSED,