summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-06 03:23:41 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-11-06 03:23:41 +0900
commitcc2226620a2045518d86d41d0cc9eb4e48704ba7 (patch)
tree3390077b4e652f4d761ce127482e517c791e49e2 /src/bin
parente5f40f1d694a9ec35c7c43b480f88bbf573c157b (diff)
test_list.c: Splitted list multi select example.
Diffstat (limited to 'src/bin')
-rwxr-xr-xsrc/bin/test.c2
-rw-r--r--src/bin/test_list.c208
2 files changed, 126 insertions, 84 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index 4a123752f..c56df2142 100755
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -82,6 +82,7 @@ void test_list7(void *data, Evas_Object *obj, void *event_info);
82void test_list8(void *data, Evas_Object *obj, void *event_info); 82void test_list8(void *data, Evas_Object *obj, void *event_info);
83void test_list9(void *data, Evas_Object *obj, void *event_info); 83void test_list9(void *data, Evas_Object *obj, void *event_info);
84void test_list_separator(void *data, Evas_Object *obj, void *event_info); 84void test_list_separator(void *data, Evas_Object *obj, void *event_info);
85void test_list_multi_select(void *data, Evas_Object *obj, void *event_info);
85void test_inwin(void *data, Evas_Object *obj, void *event_info); 86void test_inwin(void *data, Evas_Object *obj, void *event_info);
86void test_inwin2(void *data, Evas_Object *obj, void *event_info); 87void test_inwin2(void *data, Evas_Object *obj, void *event_info);
87void test_scaling(void *data, Evas_Object *obj, void *event_info); 88void test_scaling(void *data, Evas_Object *obj, void *event_info);
@@ -633,6 +634,7 @@ add_tests:
633 ADD_TEST(NULL, "Lists", "List Focus", test_list8); 634 ADD_TEST(NULL, "Lists", "List Focus", test_list8);
634 ADD_TEST(NULL, "Lists", "List Focus Horizontal", test_list9); 635 ADD_TEST(NULL, "Lists", "List Focus Horizontal", test_list9);
635 ADD_TEST(NULL, "Lists", "List Separator", test_list_separator); 636 ADD_TEST(NULL, "Lists", "List Separator", test_list_separator);
637 ADD_TEST(NULL, "Lists", "List Multi Select", test_list_multi_select);
636 ADD_TEST(NULL, "Lists", "Genlist", test_genlist); 638 ADD_TEST(NULL, "Lists", "Genlist", test_genlist);
637 ADD_TEST(NULL, "Lists", "Genlist 2", test_genlist2); 639 ADD_TEST(NULL, "Lists", "Genlist 2", test_genlist2);
638 ADD_TEST(NULL, "Lists", "Genlist 3", test_genlist3); 640 ADD_TEST(NULL, "Lists", "Genlist 3", test_genlist3);
diff --git a/src/bin/test_list.c b/src/bin/test_list.c
index 412377907..67ca66fdf 100644
--- a/src/bin/test_list.c
+++ b/src/bin/test_list.c
@@ -565,14 +565,6 @@ test_list_horizontal(void *data EINA_UNUSED,
565 565
566/***********/ 566/***********/
567 567
568typedef struct _List2_Data List2_Data;
569struct _List2_Data
570{
571 Evas_Object *list;
572 Evas_Object *rd1;
573 Evas_Object *rd2;
574};
575
576static void 568static void
577my_li2_clear(void *data, 569my_li2_clear(void *data,
578 Evas_Object *obj EINA_UNUSED, 570 Evas_Object *obj EINA_UNUSED,
@@ -591,77 +583,6 @@ my_li2_sel(void *data EINA_UNUSED,
591 printf("item selected\n"); 583 printf("item selected\n");
592} 584}
593 585
594static void
595_multi_select_changed_cb(void *data, Evas_Object *obj,
596 void *event_info EINA_UNUSED)
597{
598 Eina_Bool multi = elm_check_state_get(obj);
599 List2_Data *ld = data;
600 if (!ld) return;
601
602 elm_list_multi_select_set(ld->list, multi);
603 elm_object_disabled_set(ld->rd1, !multi);
604 elm_object_disabled_set(ld->rd2, !multi);
605}
606
607static void
608_multi_select_mode_changed_cb(void *data, Evas_Object *obj,
609 void *event_info EINA_UNUSED)
610{
611 elm_list_multi_select_mode_set(data, elm_radio_value_get(obj));
612}
613
614static void
615_multi_select_frame_create(Evas_Object *bx, List2_Data *ld)
616{
617 Evas_Object *fr, *bx2, *bx3, *tg, *rd, *rdg;
618 if (!ld) return;
619
620 fr = elm_frame_add(bx);
621 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
622 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.5);
623 elm_object_text_set(fr, "Multi Select Option");
624 elm_box_pack_end(bx, fr);
625 evas_object_show(fr);
626
627 bx2 = elm_box_add(fr);
628 elm_object_content_set(fr, bx2);
629 evas_object_show(bx2);
630
631 tg = elm_check_add(bx2);
632 elm_object_style_set(tg, "toggle");
633 elm_object_text_set(tg, "Multi Select Mode");
634 elm_box_pack_end(bx2, tg);
635 evas_object_show(tg);
636
637 bx3 = elm_box_add(bx2);
638 elm_box_horizontal_set(bx3, EINA_TRUE);
639 elm_box_pack_end(bx2, bx3);
640 evas_object_show(bx3);
641
642 ld->rd1 = rdg = rd = elm_radio_add(bx3);
643 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
644 elm_object_text_set(rd, "Default Mode");
645 elm_box_pack_end(bx3, rd);
646 evas_object_show(rd);
647 elm_object_disabled_set(rd, EINA_TRUE);
648 evas_object_smart_callback_add(rd, "changed",
649 _multi_select_mode_changed_cb, ld->list);
650
651 ld->rd2 = rd = elm_radio_add(bx3);
652 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL);
653 elm_radio_group_add(rd, rdg);
654 elm_object_text_set(rd, "With Control Mode");
655 elm_box_pack_end(bx3, rd);
656 evas_object_show(rd);
657 elm_object_disabled_set(rd, EINA_TRUE);
658 evas_object_smart_callback_add(rd, "changed",
659 _multi_select_mode_changed_cb, ld->list);
660
661 evas_object_smart_callback_add(tg, "changed",
662 _multi_select_changed_cb, ld);
663}
664
665void 586void
666test_list2(void *data EINA_UNUSED, 587test_list2(void *data EINA_UNUSED,
667 Evas_Object *obj EINA_UNUSED, 588 Evas_Object *obj EINA_UNUSED,
@@ -670,14 +591,12 @@ test_list2(void *data EINA_UNUSED,
670 Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *bx2, *bt; 591 Evas_Object *win, *bg, *li, *ic, *ic2, *bx, *bx2, *bt;
671 char buf[PATH_MAX]; 592 char buf[PATH_MAX];
672 Elm_Object_Item *list_it; 593 Elm_Object_Item *list_it;
673 List2_Data *ld = calloc(1, sizeof(List2_Data));
674 594
675 win = elm_win_add(NULL, "list2", ELM_WIN_BASIC); 595 win = elm_win_add(NULL, "list2", ELM_WIN_BASIC);
676 elm_win_title_set(win, "List 2"); 596 elm_win_title_set(win, "List 2");
677 elm_win_autodel_set(win, EINA_TRUE); 597 elm_win_autodel_set(win, EINA_TRUE);
678 evas_object_resize(win, 320, 500); 598 evas_object_resize(win, 320, 500);
679 evas_object_show(win); 599 evas_object_show(win);
680 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, ld);
681 600
682 bg = elm_bg_add(win); 601 bg = elm_bg_add(win);
683 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); 602 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
@@ -691,7 +610,7 @@ test_list2(void *data EINA_UNUSED,
691 elm_win_resize_object_add(win, bx); 610 elm_win_resize_object_add(win, bx);
692 evas_object_show(bx); 611 evas_object_show(bx);
693 612
694 ld->list = li = elm_list_add(bx); 613 li = elm_list_add(bx);
695 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL); 614 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
696 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 615 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
697 elm_list_mode_set(li, ELM_LIST_LIMIT); 616 elm_list_mode_set(li, ELM_LIST_LIMIT);
@@ -766,8 +685,6 @@ test_list2(void *data EINA_UNUSED,
766 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); 685 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
767 elm_box_pack_end(bx, bt); 686 elm_box_pack_end(bx, bt);
768 evas_object_show(bt); 687 evas_object_show(bt);
769
770 _multi_select_frame_create(bx, ld);
771} 688}
772 689
773/***********/ 690/***********/
@@ -1567,3 +1484,126 @@ test_list_separator(void *data EINA_UNUSED,
1567 evas_object_show(win); 1484 evas_object_show(win);
1568} 1485}
1569 1486
1487/***********/
1488
1489typedef struct _List2_Data List2_Data;
1490struct _List2_Data
1491{
1492 Evas_Object *list;
1493 Evas_Object *rd1;
1494 Evas_Object *rd2;
1495};
1496
1497static void
1498_multi_select_changed_cb(void *data, Evas_Object *obj,
1499 void *event_info EINA_UNUSED)
1500{
1501 Eina_Bool multi = elm_check_state_get(obj);
1502 List2_Data *ld = data;
1503 if (!ld) return;
1504
1505 elm_list_multi_select_set(ld->list, multi);
1506 elm_object_disabled_set(ld->rd1, !multi);
1507 elm_object_disabled_set(ld->rd2, !multi);
1508}
1509
1510static void
1511_multi_select_mode_changed_cb(void *data, Evas_Object *obj,
1512 void *event_info EINA_UNUSED)
1513{
1514 elm_list_multi_select_mode_set(data, elm_radio_value_get(obj));
1515}
1516
1517static void
1518_multi_select_frame_create(Evas_Object *bx, List2_Data *ld)
1519{
1520 Evas_Object *fr, *bx2, *bx3, *tg, *rd, *rdg;
1521 if (!ld) return;
1522
1523 fr = elm_frame_add(bx);
1524 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
1525 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0.5);
1526 elm_object_text_set(fr, "Multi Select Option");
1527 elm_box_pack_end(bx, fr);
1528 evas_object_show(fr);
1529
1530 bx2 = elm_box_add(fr);
1531 elm_object_content_set(fr, bx2);
1532 evas_object_show(bx2);
1533
1534 tg = elm_check_add(bx2);
1535 elm_object_style_set(tg, "toggle");
1536 elm_object_text_set(tg, "Multi Select Mode");
1537 elm_box_pack_end(bx2, tg);
1538 evas_object_show(tg);
1539
1540 bx3 = elm_box_add(bx2);
1541 elm_box_horizontal_set(bx3, EINA_TRUE);
1542 elm_box_pack_end(bx2, bx3);
1543 evas_object_show(bx3);
1544
1545 ld->rd1 = rdg = rd = elm_radio_add(bx3);
1546 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT);
1547 elm_object_text_set(rd, "Default Mode");
1548 elm_box_pack_end(bx3, rd);
1549 evas_object_show(rd);
1550 elm_object_disabled_set(rd, EINA_TRUE);
1551 evas_object_smart_callback_add(rd, "changed",
1552 _multi_select_mode_changed_cb, ld->list);
1553
1554 ld->rd2 = rd = elm_radio_add(bx3);
1555 elm_radio_state_value_set(rd, ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL);
1556 elm_radio_group_add(rd, rdg);
1557 elm_object_text_set(rd, "With Control Mode");
1558 elm_box_pack_end(bx3, rd);
1559 evas_object_show(rd);
1560 elm_object_disabled_set(rd, EINA_TRUE);
1561 evas_object_smart_callback_add(rd, "changed",
1562 _multi_select_mode_changed_cb, ld->list);
1563
1564 evas_object_smart_callback_add(tg, "changed",
1565 _multi_select_changed_cb, ld);
1566}
1567
1568void
1569test_list_multi_select(void *data EINA_UNUSED,
1570 Evas_Object *obj EINA_UNUSED,
1571 void *event_info EINA_UNUSED)
1572{
1573 Evas_Object *win, *li, *bx;
1574 List2_Data *ld = calloc(1, sizeof(List2_Data));
1575
1576 win = elm_win_util_standard_add("list-multi-select", "List Multi Select");
1577 elm_win_autodel_set(win, EINA_TRUE);
1578 evas_object_resize(win, 320, 500);
1579 evas_object_show(win);
1580 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, ld);
1581
1582 bx = elm_box_add(win);
1583 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1584 elm_win_resize_object_add(win, bx);
1585 evas_object_show(bx);
1586
1587 ld->list = li = elm_list_add(bx);
1588 _multi_select_frame_create(bx, ld);
1589
1590 evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1591 evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
1592 elm_box_pack_end(bx, li);
1593 evas_object_show(li);
1594
1595 elm_list_item_append(li, "you", NULL, NULL, NULL, NULL);
1596 elm_list_item_append(li, "doing", NULL, NULL, NULL, NULL);
1597 elm_list_item_append(li, "out", NULL, NULL, NULL, NULL);
1598 elm_list_item_append(li, "there", NULL, NULL, NULL, NULL);
1599 elm_list_item_append(li, "today", NULL, NULL, NULL, NULL);
1600 elm_list_item_append(li, "?", NULL, NULL, NULL, NULL);
1601 elm_list_item_append(li, "Here", NULL, NULL, NULL, NULL);
1602 elm_list_item_append(li, "are", NULL, NULL, NULL, NULL);
1603 elm_list_item_append(li, "some", NULL, NULL, NULL, NULL);
1604 elm_list_item_append(li, "more", NULL, NULL, NULL, NULL);
1605 elm_list_item_append(li, "items", NULL, NULL, NULL, NULL);
1606 elm_list_item_append(li, "Longer label.", NULL, NULL, NULL, NULL);
1607
1608 elm_list_go(li);
1609}