summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmail.com>2013-08-27 14:47:37 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2013-08-28 08:47:47 +0900
commit266007bd935d739f5850994a6cc9f4a4e2f94aee (patch)
tree9537f256221d14fea7fc1e7ed3ba1b111d62ff66 /src/bin
parentb7113b67ea6fad05dad9d6e6f8e37572940efc9c (diff)
test_gengrid.c: Overall refactoring.
1. Fixed formatting. 2. Used EINA_TRUE/FALSE for Eina_Bool type parameter. 3. Made item size scalable. 4. Changed Item Data structure name Testitem -> Item_Data 5. Used elm_image for gengrid icon instead of bg. 6. Removed unnecessary casting. 7. Moved code around to the proper place.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/test_gengrid.c283
1 files changed, 146 insertions, 137 deletions
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index 5762a4f8a..6b51c851e 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -20,13 +20,13 @@ Eina_Bool grid_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
20 const char *part __UNUSED__); 20 const char *part __UNUSED__);
21void grid_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__); 21void grid_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__);
22 22
23typedef struct _Testitem 23typedef struct _Item_Data
24{ 24{
25 Elm_Object_Item *item; 25 Elm_Object_Item *item;
26 const char *path; 26 const char *path;
27 int mode; 27 int mode;
28 int onoff; 28 int onoff;
29} Testitem; 29} Item_Data;
30 30
31struct _api_data 31struct _api_data
32{ 32{
@@ -213,38 +213,37 @@ grid_moved(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
213static void 213static void
214grid_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__) 214grid_item_check_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
215{ 215{
216 Testitem *ti = data; 216 Item_Data *id = data;
217 ti->onoff = elm_check_state_get(obj); 217 id->onoff = elm_check_state_get(obj);
218 printf("item %p onoff = %i\n", ti, ti->onoff); 218 printf("item %p onoff = %i\n", id, id->onoff);
219} 219}
220 220
221char * 221char *
222grid_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) 222grid_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
223{ 223{
224 const Testitem *ti = data; 224 const Item_Data *id = data;
225 char buf[256]; 225 char buf[256];
226 snprintf(buf, sizeof(buf), "Photo %s", ti->path); 226 snprintf(buf, sizeof(buf), "Photo %s", id->path);
227 return strdup(buf); 227 return strdup(buf);
228} 228}
229 229
230Evas_Object * 230Evas_Object *
231grid_content_get(void *data, Evas_Object *obj, const char *part) 231grid_content_get(void *data, Evas_Object *obj, const char *part)
232{ 232{
233 const Testitem *ti = data; 233 const Item_Data *id = data;
234 if (!strcmp(part, "elm.swallow.icon")) 234 if (!strcmp(part, "elm.swallow.icon"))
235 { 235 {
236 Evas_Object *icon = elm_bg_add(obj); 236 Evas_Object *image = elm_image_add(obj);
237 elm_bg_file_set(icon, ti->path, NULL); 237 elm_image_file_set(image, id->path, NULL);
238 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 238 elm_image_aspect_fixed_set(image, EINA_FALSE);
239 evas_object_show(icon); 239 evas_object_show(image);
240 return icon; 240 return image;
241 } 241 }
242 else if (!strcmp(part, "elm.swallow.end")) 242 else if (!strcmp(part, "elm.swallow.end"))
243 { 243 {
244 Evas_Object *ck; 244 Evas_Object *ck = elm_check_add(obj);
245 ck = elm_check_add(obj); 245 evas_object_propagate_events_set(ck, EINA_FALSE);
246 evas_object_propagate_events_set(ck, 0); 246 elm_check_state_set(ck, id->onoff);
247 elm_check_state_set(ck, ti->onoff);
248 evas_object_smart_callback_add(ck, "changed", grid_item_check_changed, data); 247 evas_object_smart_callback_add(ck, "changed", grid_item_check_changed, data);
249 evas_object_show(ck); 248 evas_object_show(ck);
250 return ck; 249 return ck;
@@ -304,15 +303,14 @@ static Evas_Object *
304create_gengrid(Evas_Object *obj, int items) 303create_gengrid(Evas_Object *obj, int items)
305{ 304{
306 Evas_Object *grid = NULL; 305 Evas_Object *grid = NULL;
307 static Testitem ti[144]; 306 static Item_Data id[144];
308 int i, n; 307 int i, n;
309 char buf[PATH_MAX]; 308 char buf[PATH_MAX];
310 309
311 grid = elm_gengrid_add(obj); 310 grid = elm_gengrid_add(obj);
312 elm_gengrid_item_size_set(grid, 311 elm_gengrid_item_size_set(grid,
313 elm_config_scale_get() * 150, 312 elm_config_scale_get() * 200,
314 elm_config_scale_get() * 150); 313 elm_config_scale_get() * 150);
315 elm_gengrid_horizontal_set(grid, EINA_FALSE);
316 elm_gengrid_reorder_mode_set(grid, EINA_TRUE); 314 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
317 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL); 315 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
318 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL); 316 evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
@@ -338,11 +336,11 @@ create_gengrid(Evas_Object *obj, int items)
338 { 336 {
339 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 337 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
340 n = (n + 1) % 9; 338 n = (n + 1) % 9;
341 ti[i].mode = i; 339 id[i].mode = i;
342 ti[i].path = eina_stringshare_add(buf); 340 id[i].path = eina_stringshare_add(buf);
343 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 341 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
344 if (!(i % 5)) 342 if (!(i % 5))
345 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 343 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
346 } 344 }
347 elm_gengrid_item_class_free(gic); 345 elm_gengrid_item_class_free(gic);
348 346
@@ -379,6 +377,8 @@ filled_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
379 377
380 win = elm_win_util_standard_add("test filled", "Test Filled"); 378 win = elm_win_util_standard_add("test filled", "Test Filled");
381 elm_win_autodel_set(win, EINA_TRUE); 379 elm_win_autodel_set(win, EINA_TRUE);
380 evas_object_resize(win, 450, 200);
381 evas_object_show(win);
382 382
383 box = elm_box_add(win); 383 box = elm_box_add(win);
384 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 384 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -400,9 +400,6 @@ filled_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
400 evas_object_smart_callback_add(tg, "changed", filled_cb, content_box); 400 evas_object_smart_callback_add(tg, "changed", filled_cb, content_box);
401 elm_box_pack_end(box, tg); 401 elm_box_pack_end(box, tg);
402 evas_object_show(tg); 402 evas_object_show(tg);
403
404 evas_object_resize(win, 450, 200);
405 evas_object_show(win);
406} 403}
407 404
408static void 405static void
@@ -434,6 +431,8 @@ cursor_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
434 431
435 win = elm_win_util_standard_add("test cursor", "Test Cursor"); 432 win = elm_win_util_standard_add("test cursor", "Test Cursor");
436 elm_win_autodel_set(win, EINA_TRUE); 433 elm_win_autodel_set(win, EINA_TRUE);
434 evas_object_resize(win, 450, 450);
435 evas_object_show(win);
437 436
438 box = elm_box_add(win); 437 box = elm_box_add(win);
439 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 438 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -461,9 +460,6 @@ cursor_bt_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
461 460
462 elm_box_pack_end(box, hbox); 461 elm_box_pack_end(box, hbox);
463 evas_object_show(hbox); 462 evas_object_show(hbox);
464
465 evas_object_resize(win, 450, 450);
466 evas_object_show(win);
467} 463}
468 464
469static void 465static void
@@ -493,6 +489,8 @@ test_gengrid(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
493 win = elm_win_util_standard_add("gengrid", "GenGrid"); 489 win = elm_win_util_standard_add("gengrid", "GenGrid");
494 elm_win_autodel_set(win, EINA_TRUE); 490 elm_win_autodel_set(win, EINA_TRUE);
495 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); 491 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
492 evas_object_resize(win, 600, 600);
493 evas_object_show(win);
496 494
497 api->box = bxx = elm_box_add(win); 495 api->box = bxx = elm_box_add(win);
498 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 496 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -577,15 +575,12 @@ test_gengrid(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf
577 evas_object_smart_callback_add(bt, "clicked", _btn_show_clicked_cb, api->grid); 575 evas_object_smart_callback_add(bt, "clicked", _btn_show_clicked_cb, api->grid);
578 elm_box_pack_end(bx, bt); 576 elm_box_pack_end(bx, bt);
579 evas_object_show(bt); 577 evas_object_show(bt);
580
581 evas_object_resize(win, 600, 600);
582 evas_object_show(win);
583} 578}
584 579
585static void 580static void
586_before_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 581_before_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
587{ 582{
588 Testitem *ti; 583 Item_Data *id;
589 Evas_Object *grid = data; 584 Evas_Object *grid = data;
590 Elm_Object_Item *sel; 585 Elm_Object_Item *sel;
591 char buf[PATH_MAX]; 586 char buf[PATH_MAX];
@@ -595,41 +590,41 @@ _before_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __U
595 return; 590 return;
596 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]); 591 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
597 n_current_pic = ((n_current_pic +1) % 9); 592 n_current_pic = ((n_current_pic +1) % 9);
598 ti = calloc(1, sizeof(*ti)); 593 id = calloc(1, sizeof(*id));
599 ti->mode = 0; 594 id->mode = 0;
600 ti->path = eina_stringshare_add(buf); 595 id->path = eina_stringshare_add(buf);
601 ti->item = elm_gengrid_item_insert_before(grid, gic, ti, sel, grid_sel, 596 id->item = elm_gengrid_item_insert_before(grid, gic, id, sel, grid_sel,
602 NULL); 597 NULL);
603} 598}
604 599
605static int 600static int
606compare_cb(const void *data1, const void *data2) 601compare_cb(const void *data1, const void *data2)
607{ 602{
608 Testitem *ti1 = (Testitem *)elm_object_item_data_get(data1); 603 Item_Data *ti1 = elm_object_item_data_get(data1);
609 Testitem *ti2 = (Testitem *)elm_object_item_data_get(data2); 604 Item_Data *ti2 = elm_object_item_data_get(data2);
610 return strlen(ti1->path) - strlen(ti2->path); 605 return strlen(ti1->path) - strlen(ti2->path);
611} 606}
612 607
613static void 608static void
614_sorted_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 609_sorted_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
615{ 610{
616 Testitem *ti; 611 Item_Data *id;
617 Evas_Object *grid = data; 612 Evas_Object *grid = data;
618 char buf[PATH_MAX]; 613 char buf[PATH_MAX];
619 614
620 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]); 615 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
621 n_current_pic = ((n_current_pic +1) % 9); 616 n_current_pic = ((n_current_pic +1) % 9);
622 ti = calloc(1, sizeof(*ti)); 617 id = calloc(1, sizeof(*id));
623 ti->mode = 0; 618 id->mode = 0;
624 ti->path = eina_stringshare_add(buf); 619 id->path = eina_stringshare_add(buf);
625 ti->item = elm_gengrid_item_sorted_insert(grid, gic, ti, compare_cb, grid_sel, 620 id->item = elm_gengrid_item_sorted_insert(grid, gic, id, compare_cb, grid_sel,
626 NULL); 621 NULL);
627} 622}
628 623
629static void 624static void
630_after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 625_after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
631{ 626{
632 Testitem *ti; 627 Item_Data *id;
633 Evas_Object *grid = data; 628 Evas_Object *grid = data;
634 Elm_Object_Item *sel; 629 Elm_Object_Item *sel;
635 char buf[PATH_MAX]; 630 char buf[PATH_MAX];
@@ -639,10 +634,10 @@ _after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
639 return; 634 return;
640 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]); 635 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
641 n_current_pic = ((n_current_pic +1) % 9); 636 n_current_pic = ((n_current_pic +1) % 9);
642 ti = calloc(1, sizeof(*ti)); 637 id = calloc(1, sizeof(*id));
643 ti->mode = 0; 638 id->mode = 0;
644 ti->path = eina_stringshare_add(buf); 639 id->path = eina_stringshare_add(buf);
645 ti->item = elm_gengrid_item_insert_after(grid, gic, ti, sel, grid_sel, 640 id->item = elm_gengrid_item_insert_after(grid, gic, id, sel, grid_sel,
646 NULL); 641 NULL);
647} 642}
648 643
@@ -662,31 +657,31 @@ _delete_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __U
662static void 657static void
663_prepend_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 658_prepend_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
664{ 659{
665 Testitem *ti; 660 Item_Data *id;
666 Evas_Object *grid = data; 661 Evas_Object *grid = data;
667 char buf[PATH_MAX]; 662 char buf[PATH_MAX];
668 663
669 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]); 664 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
670 n_current_pic = ((n_current_pic +1) % 9); 665 n_current_pic = ((n_current_pic +1) % 9);
671 ti = calloc(1, sizeof(*ti)); 666 id = calloc(1, sizeof(*id));
672 ti->mode = 0; 667 id->mode = 0;
673 ti->path = eina_stringshare_add(buf); 668 id->path = eina_stringshare_add(buf);
674 ti->item = elm_gengrid_item_prepend(grid, gic, ti, grid_sel, NULL); 669 id->item = elm_gengrid_item_prepend(grid, gic, id, grid_sel, NULL);
675} 670}
676 671
677static void 672static void
678_append_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 673_append_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
679{ 674{
680 Testitem *ti; 675 Item_Data *id;
681 Evas_Object *grid = data; 676 Evas_Object *grid = data;
682 char buf[PATH_MAX]; 677 char buf[PATH_MAX];
683 678
684 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]); 679 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n_current_pic]);
685 n_current_pic = ((n_current_pic +1) % 9); 680 n_current_pic = ((n_current_pic +1) % 9);
686 ti = calloc(1, sizeof(*ti)); 681 id = calloc(1, sizeof(*id));
687 ti->mode = 0; 682 id->mode = 0;
688 ti->path = eina_stringshare_add(buf); 683 id->path = eina_stringshare_add(buf);
689 ti->item = elm_gengrid_item_append(grid, gic, ti, grid_sel, NULL); 684 id->item = elm_gengrid_item_append(grid, gic, id, grid_sel, NULL);
690} 685}
691 686
692static void 687static void
@@ -694,7 +689,8 @@ _size_changed(void *data, Evas_Object *obj, void *event_info __UNUSED__)
694{ 689{
695 Evas_Object *grid = data; 690 Evas_Object *grid = data;
696 int size = elm_spinner_value_get(obj); 691 int size = elm_spinner_value_get(obj);
697 elm_gengrid_item_size_set(grid, elm_config_scale_get() * size, 692 elm_gengrid_item_size_set(grid,
693 elm_config_scale_get() * size,
698 elm_config_scale_get() * size); 694 elm_config_scale_get() * size);
699} 695}
700 696
@@ -705,6 +701,8 @@ test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
705 701
706 win = elm_win_util_standard_add("gengrid2", "GenGrid 2"); 702 win = elm_win_util_standard_add("gengrid2", "GenGrid 2");
707 elm_win_autodel_set(win, EINA_TRUE); 703 elm_win_autodel_set(win, EINA_TRUE);
704 evas_object_resize(win, 600, 600);
705 evas_object_show(win);
708 706
709 bx = elm_box_add(win); 707 bx = elm_box_add(win);
710 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 708 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -712,9 +710,9 @@ test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
712 evas_object_show(bx); 710 evas_object_show(bx);
713 711
714 grid = elm_gengrid_add(win); 712 grid = elm_gengrid_add(win);
715 elm_gengrid_item_size_set(grid, elm_config_scale_get() * 150, 713 elm_gengrid_item_size_set(grid,
714 elm_config_scale_get() * 150,
716 elm_config_scale_get() * 150); 715 elm_config_scale_get() * 150);
717 elm_gengrid_horizontal_set(grid, EINA_FALSE);
718 elm_gengrid_multi_select_set(grid, EINA_FALSE); 716 elm_gengrid_multi_select_set(grid, EINA_FALSE);
719 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL); 717 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
720 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 718 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -789,29 +787,30 @@ test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
789 /* item_class_ref is needed for gic. some items can be added in callbacks */ 787 /* item_class_ref is needed for gic. some items can be added in callbacks */
790 elm_gengrid_item_class_ref(gic); 788 elm_gengrid_item_class_ref(gic);
791 elm_gengrid_item_class_free(gic); 789 elm_gengrid_item_class_free(gic);
792
793 evas_object_resize(win, 600, 600);
794 evas_object_show(win);
795} 790}
796 791
797void 792void
798test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 793test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
799{ 794{
800 Evas_Object *win, *grid; 795 Evas_Object *win, *grid;
801 static Testitem ti[144]; 796 static Item_Data id[144];
802 int i, n; 797 int i, n;
803 char buf[PATH_MAX]; 798 char buf[PATH_MAX];
804 799
805 win = elm_win_util_standard_add("gengrid_group", "GenGrid Group"); 800 win = elm_win_util_standard_add("gengrid_group", "GenGrid Group");
806 elm_win_autodel_set(win, EINA_TRUE); 801 elm_win_autodel_set(win, EINA_TRUE);
802 evas_object_resize(win, 600, 600);
803 evas_object_show(win);
807 804
808 grid = elm_gengrid_add(win); 805 grid = elm_gengrid_add(win);
809 elm_gengrid_item_size_set(grid, elm_config_scale_get() * 150, 806 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
807 elm_win_resize_object_add(win, grid);
808 elm_gengrid_item_size_set(grid,
809 elm_config_scale_get() * 150,
810 elm_config_scale_get() * 150); 810 elm_config_scale_get() * 150);
811 elm_gengrid_group_item_size_set(grid, elm_config_scale_get() * 31, 811 elm_gengrid_group_item_size_set(grid,
812 elm_config_scale_get() * 31,
812 elm_config_scale_get() * 31); 813 elm_config_scale_get() * 31);
813 //elm_gengrid_horizontal_set(grid, EINA_TRUE);
814 elm_gengrid_horizontal_set(grid, EINA_FALSE);
815 elm_gengrid_multi_select_set(grid, EINA_TRUE); 814 elm_gengrid_multi_select_set(grid, EINA_TRUE);
816 elm_gengrid_reorder_mode_set(grid, EINA_TRUE); 815 elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
817 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL); 816 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
@@ -823,7 +822,6 @@ test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
823 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL); 822 evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
824 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL); 823 evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
825 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL); 824 evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
826 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
827 825
828 gic = elm_gengrid_item_class_new(); 826 gic = elm_gengrid_item_class_new();
829 gic->item_style = "default"; 827 gic->item_style = "default";
@@ -844,23 +842,20 @@ test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
844 { 842 {
845 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 843 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
846 n = (n + 1) % 9; 844 n = (n + 1) % 9;
847 ti[i].mode = i; 845 id[i].mode = i;
848 ti[i].path = eina_stringshare_add(buf); 846 id[i].path = eina_stringshare_add(buf);
849 if (i == 0 || i == 18 || i == 53 || i == 100) 847 if (i == 0 || i == 18 || i == 53 || i == 100)
850 //if (i == 0 || i == 18) 848 //if (i == 0 || i == 18)
851 ti[i].item = elm_gengrid_item_append(grid, ggic, &(ti[i]), grid_sel, NULL); 849 id[i].item = elm_gengrid_item_append(grid, ggic, &(id[i]), grid_sel, NULL);
852 else 850 else
853 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 851 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
854 if (!(i % 5)) 852 if (!(i % 5))
855 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 853 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
856 } 854 }
857 elm_gengrid_item_class_free(gic); 855 elm_gengrid_item_class_free(gic);
858 elm_gengrid_item_class_free(ggic); 856 elm_gengrid_item_class_free(ggic);
859 857
860 evas_object_show(grid); 858 evas_object_show(grid);
861 elm_win_resize_object_add(win, grid);
862 evas_object_resize(win, 600, 600);
863 evas_object_show(win);
864} 859}
865 860
866/* test gengrid item styles */ 861/* test gengrid item styles */
@@ -870,7 +865,7 @@ _gengrid_create(Evas_Object *obj, int items, const char *style)
870{ 865{
871 static Evas_Object *grid = NULL; 866 static Evas_Object *grid = NULL;
872 Elm_Gengrid_Item_Class *ic; 867 Elm_Gengrid_Item_Class *ic;
873 Testitem *ti; 868 Item_Data *id;
874 int i, n; 869 int i, n;
875 char buf[PATH_MAX]; 870 char buf[PATH_MAX];
876 871
@@ -880,7 +875,8 @@ _gengrid_create(Evas_Object *obj, int items, const char *style)
880 { 875 {
881 if (!obj) return NULL; 876 if (!obj) return NULL;
882 grid = elm_gengrid_add(obj); 877 grid = elm_gengrid_add(obj);
883 elm_gengrid_item_size_set(grid, elm_config_scale_get() * 150, 878 elm_gengrid_item_size_set(grid,
879 elm_config_scale_get() * 150,
884 elm_config_scale_get() * 150); 880 elm_config_scale_get() * 150);
885 EXPAND(grid); FILL(grid); 881 EXPAND(grid); FILL(grid);
886 } 882 }
@@ -896,12 +892,12 @@ _gengrid_create(Evas_Object *obj, int items, const char *style)
896 n = 0; 892 n = 0;
897 for (i = 0; i < items; i++) 893 for (i = 0; i < items; i++)
898 { 894 {
899 ti = calloc(1, sizeof(Testitem)); 895 id = calloc(1, sizeof(Item_Data));
900 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 896 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
901 n = (n + 1) % 9; 897 n = (n + 1) % 9;
902 ti->mode = i; 898 id->mode = i;
903 ti->path = eina_stringshare_add(buf); 899 id->path = eina_stringshare_add(buf);
904 ti->item = elm_gengrid_item_append(grid, ic, ti, NULL, NULL); 900 id->item = elm_gengrid_item_append(grid, ic, id, NULL, NULL);
905 } 901 }
906 elm_gengrid_item_class_free(ic); 902 elm_gengrid_item_class_free(ic);
907 903
@@ -998,18 +994,25 @@ static void
998_bring_in2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 994_bring_in2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
999{ 995{
1000 Evas_Object *win, *grid; 996 Evas_Object *win, *grid;
1001 static Testitem ti[5000]; 997 static Item_Data id[5000];
1002 int i, n; 998 int i, n;
1003 char buf[PATH_MAX]; 999 char buf[PATH_MAX];
1004 1000
1005 win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in"); 1001 win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in");
1006 elm_win_autodel_set(win, EINA_TRUE); 1002 elm_win_autodel_set(win, EINA_TRUE);
1003 evas_object_resize(win, 600, 200);
1004 evas_object_show(win);
1007 1005
1008 grid = elm_gengrid_add(win); 1006 grid = elm_gengrid_add(win);
1009 elm_gengrid_item_size_set(grid, 150, 150);
1010 elm_gengrid_group_item_size_set(grid, 31, 31);
1011 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1012 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1007 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1008 elm_win_resize_object_add(win, grid);
1009 elm_gengrid_item_size_set(grid,
1010 elm_config_scale_get() * 150,
1011 elm_config_scale_get() * 150);
1012 elm_gengrid_group_item_size_set(grid,
1013 elm_config_scale_get() * 31,
1014 elm_config_scale_get() * 31);
1015 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1013 elm_gengrid_align_set(grid, 0.4, 0.8); 1016 elm_gengrid_align_set(grid, 0.4, 0.8);
1014 1017
1015 gic = elm_gengrid_item_class_new(); 1018 gic = elm_gengrid_item_class_new();
@@ -1024,37 +1027,40 @@ _bring_in2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
1024 { 1027 {
1025 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 1028 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1026 n = (n + 1) % 9; 1029 n = (n + 1) % 9;
1027 ti[i].mode = i; 1030 id[i].mode = i;
1028 ti[i].path = eina_stringshare_add(buf); 1031 id[i].path = eina_stringshare_add(buf);
1029 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 1032 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
1030 if (i == 2400) 1033 if (i == 2400)
1031 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 1034 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
1032 } 1035 }
1033 1036
1034 elm_gengrid_item_class_free(gic); 1037 elm_gengrid_item_class_free(gic);
1035 evas_object_show(grid); 1038 evas_object_show(grid);
1036 elm_gengrid_item_bring_in(ti[2400].item, ELM_GENGRID_ITEM_SCROLLTO_IN); 1039 elm_gengrid_item_bring_in(id[2400].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
1037 elm_win_resize_object_add(win, grid);
1038 evas_object_resize(win, 600, 200);
1039 evas_object_show(win);
1040} 1040}
1041 1041
1042static void 1042static void
1043_bring_in1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 1043_bring_in1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1044{ 1044{
1045 Evas_Object *win, *grid; 1045 Evas_Object *win, *grid;
1046 static Testitem ti[5000]; 1046 static Item_Data id[5000];
1047 int i, n; 1047 int i, n;
1048 char buf[PATH_MAX]; 1048 char buf[PATH_MAX];
1049 1049
1050 win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in"); 1050 win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in");
1051 elm_win_autodel_set(win, EINA_TRUE); 1051 elm_win_autodel_set(win, EINA_TRUE);
1052 evas_object_resize(win, 600, 400);
1053 evas_object_show(win);
1052 1054
1053 grid = elm_gengrid_add(win); 1055 grid = elm_gengrid_add(win);
1054 elm_gengrid_item_size_set(grid, 150, 150);
1055 elm_gengrid_group_item_size_set(grid, 31, 31);
1056 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1057 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1056 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1057 elm_win_resize_object_add(win, grid);
1058 elm_gengrid_item_size_set(grid,
1059 elm_config_scale_get() * 150,
1060 elm_config_scale_get() * 150);
1061 elm_gengrid_group_item_size_set(grid,
1062 elm_config_scale_get() * 31,
1063 elm_config_scale_get() * 31);
1058 elm_gengrid_align_set(grid, 0.1, 1.0); 1064 elm_gengrid_align_set(grid, 0.1, 1.0);
1059 1065
1060 gic = elm_gengrid_item_class_new(); 1066 gic = elm_gengrid_item_class_new();
@@ -1069,19 +1075,16 @@ _bring_in1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *
1069 { 1075 {
1070 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 1076 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1071 n = (n + 1) % 9; 1077 n = (n + 1) % 9;
1072 ti[i].mode = i; 1078 id[i].mode = i;
1073 ti[i].path = eina_stringshare_add(buf); 1079 id[i].path = eina_stringshare_add(buf);
1074 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 1080 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
1075 if (i == 1430) 1081 if (i == 1430)
1076 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 1082 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
1077 } 1083 }
1078 1084
1079 elm_gengrid_item_class_free(gic); 1085 elm_gengrid_item_class_free(gic);
1080 elm_gengrid_item_bring_in(ti[1430].item, ELM_GENGRID_ITEM_SCROLLTO_IN); 1086 elm_gengrid_item_bring_in(id[1430].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
1081 evas_object_show(grid); 1087 evas_object_show(grid);
1082 elm_win_resize_object_add(win, grid);
1083 evas_object_resize(win, 600, 400);
1084 evas_object_show(win);
1085} 1088}
1086 1089
1087 1090
@@ -1089,18 +1092,25 @@ static void
1089_show2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 1092_show2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1090{ 1093{
1091 Evas_Object *win, *grid; 1094 Evas_Object *win, *grid;
1092 static Testitem ti[10000]; 1095 static Item_Data id[10000];
1093 int i, n; 1096 int i, n;
1094 char buf[PATH_MAX]; 1097 char buf[PATH_MAX];
1095 1098
1096 win = elm_win_util_standard_add("horz show", "Horz Show"); 1099 win = elm_win_util_standard_add("horz show", "Horz Show");
1097 elm_win_autodel_set(win, EINA_TRUE); 1100 elm_win_autodel_set(win, EINA_TRUE);
1101 evas_object_resize(win, 600, 200);
1102 evas_object_show(win);
1098 1103
1099 grid = elm_gengrid_add(win); 1104 grid = elm_gengrid_add(win);
1100 elm_gengrid_item_size_set(grid, 150, 150);
1101 elm_gengrid_group_item_size_set(grid, 31, 31);
1102 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1103 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1105 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1106 elm_win_resize_object_add(win, grid);
1107 elm_gengrid_item_size_set(grid,
1108 elm_config_scale_get() * 150,
1109 elm_config_scale_get() * 150);
1110 elm_gengrid_group_item_size_set(grid,
1111 elm_config_scale_get() * 31,
1112 elm_config_scale_get() * 31);
1113 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1104 elm_gengrid_align_set(grid, 0.3, 0.7); 1114 elm_gengrid_align_set(grid, 0.3, 0.7);
1105 1115
1106 gic = elm_gengrid_item_class_new(); 1116 gic = elm_gengrid_item_class_new();
@@ -1115,37 +1125,40 @@ _show2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
1115 { 1125 {
1116 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 1126 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1117 n = (n + 1) % 9; 1127 n = (n + 1) % 9;
1118 ti[i].mode = i; 1128 id[i].mode = i;
1119 ti[i].path = eina_stringshare_add(buf); 1129 id[i].path = eina_stringshare_add(buf);
1120 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 1130 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
1121 if (i == 3333) 1131 if (i == 3333)
1122 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 1132 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
1123 } 1133 }
1124 1134
1125 elm_gengrid_item_class_free(gic); 1135 elm_gengrid_item_class_free(gic);
1126 evas_object_show(grid); 1136 evas_object_show(grid);
1127 elm_gengrid_item_show(ti[3333].item, ELM_GENGRID_ITEM_SCROLLTO_IN); 1137 elm_gengrid_item_show(id[3333].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
1128 elm_win_resize_object_add(win, grid);
1129 evas_object_resize(win, 600, 200);
1130 evas_object_show(win);
1131} 1138}
1132 1139
1133static void 1140static void
1134_show1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 1141_show1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1135{ 1142{
1136 Evas_Object *win, *grid; 1143 Evas_Object *win, *grid;
1137 static Testitem ti[10000]; 1144 static Item_Data id[10000];
1138 int i, n; 1145 int i, n;
1139 char buf[PATH_MAX]; 1146 char buf[PATH_MAX];
1140 1147
1141 win = elm_win_util_standard_add("vertical show", "Vertical Show"); 1148 win = elm_win_util_standard_add("vertical show", "Vertical Show");
1142 elm_win_autodel_set(win, EINA_TRUE); 1149 elm_win_autodel_set(win, EINA_TRUE);
1150 evas_object_resize(win, 600, 600);
1151 evas_object_show(win);
1143 1152
1144 grid = elm_gengrid_add(win); 1153 grid = elm_gengrid_add(win);
1145 elm_gengrid_item_size_set(grid, 150, 150);
1146 elm_gengrid_group_item_size_set(grid, 31, 31);
1147 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1148 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1154 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1155 elm_win_resize_object_add(win, grid);
1156 elm_gengrid_item_size_set(grid,
1157 elm_config_scale_get() * 150,
1158 elm_config_scale_get() * 150);
1159 elm_gengrid_group_item_size_set(grid,
1160 elm_config_scale_get() * 31,
1161 elm_config_scale_get() * 31);
1149 elm_gengrid_align_set(grid, 0.1, 0.3); 1162 elm_gengrid_align_set(grid, 0.1, 0.3);
1150 1163
1151 gic = elm_gengrid_item_class_new(); 1164 gic = elm_gengrid_item_class_new();
@@ -1160,19 +1173,16 @@ _show1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *even
1160 { 1173 {
1161 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]); 1174 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1162 n = (n + 1) % 9; 1175 n = (n + 1) % 9;
1163 ti[i].mode = i; 1176 id[i].mode = i;
1164 ti[i].path = eina_stringshare_add(buf); 1177 id[i].path = eina_stringshare_add(buf);
1165 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL); 1178 id[i].item = elm_gengrid_item_append(grid, gic, &(id[i]), grid_sel, NULL);
1166 if (i == 2579) 1179 if (i == 2579)
1167 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE); 1180 elm_gengrid_item_selected_set(id[i].item, EINA_TRUE);
1168 } 1181 }
1169 1182
1170 elm_gengrid_item_class_free(gic); 1183 elm_gengrid_item_class_free(gic);
1171 evas_object_show(grid); 1184 evas_object_show(grid);
1172 elm_gengrid_item_show(ti[2579].item, ELM_GENGRID_ITEM_SCROLLTO_IN); 1185 elm_gengrid_item_show(id[2579].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
1173 elm_win_resize_object_add(win, grid);
1174 evas_object_resize(win, 600, 600);
1175 evas_object_show(win);
1176} 1186}
1177 1187
1178void 1188void
@@ -1184,6 +1194,8 @@ test_gengrid4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
1184 win = elm_win_util_standard_add("gengrid show/scroll_in", "GenGrid Show/Bring_in"); 1194 win = elm_win_util_standard_add("gengrid show/scroll_in", "GenGrid Show/Bring_in");
1185 elm_win_autodel_set(win, EINA_TRUE); 1195 elm_win_autodel_set(win, EINA_TRUE);
1186 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); 1196 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
1197 evas_object_resize(win, 300, 300);
1198 evas_object_show(win);
1187 1199
1188 bx = elm_box_add(win); 1200 bx = elm_box_add(win);
1189 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1201 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -1214,8 +1226,5 @@ test_gengrid4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
1214 evas_object_smart_callback_add(bt, "clicked", _bring_in2_clicked_cb, NULL); 1226 evas_object_smart_callback_add(bt, "clicked", _bring_in2_clicked_cb, NULL);
1215 elm_box_pack_end(bx, bt); 1227 elm_box_pack_end(bx, bt);
1216 evas_object_show(bt); 1228 evas_object_show(bt);
1217
1218 evas_object_resize(win, 300, 300);
1219 evas_object_show(win);
1220} 1229}
1221#endif 1230#endif