[gengrid] Sync test to upstream
authorMike McCormack <mj.mccormack@samsung.com>
Wed, 23 Nov 2011 07:10:28 +0000 (16:10 +0900)
committerMike McCormack <mj.mccormack@samsung.com>
Wed, 23 Nov 2011 07:10:28 +0000 (16:10 +0900)
src/bin/test_gengrid.c

index 1371631..936be4b 100644 (file)
@@ -24,7 +24,7 @@ static const char *img[9] =
    "wood_01.jpg",
 };
 
-static Elm_Gengrid_Item_Class gic;
+static Elm_Gengrid_Item_Class gic, ggic;
 
 static void
 _horizontal_grid(void *data, Evas_Object *obj, void *event_info __UNUSED__)
@@ -244,6 +244,19 @@ _after_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UN
 }
 
 static void
+_delete_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Evas_Object *grid = data;
+   Eina_List *l, *l2, *l3;
+   Elm_Gengrid_Item *it;
+
+   l = (Eina_List*)elm_gengrid_selected_items_get(grid);
+   if (!l) return;
+   EINA_LIST_FOREACH_SAFE(l, l2, l3, it)
+     elm_gengrid_item_del(it);
+}
+
+static void
 _prepend_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Testitem *ti;
@@ -338,6 +351,12 @@ test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
    elm_box_pack_end(hbx, bt);
    evas_object_show(bt);
 
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Delete");
+   evas_object_smart_callback_add(bt, "clicked", _delete_bt_clicked, grid);
+   elm_box_pack_end(hbx, bt);
+   evas_object_show(bt);
+
    bt = elm_spinner_add(win);
    elm_spinner_min_max_set(bt, 10, 1024);
    elm_spinner_value_set(bt, 150);
@@ -362,4 +381,76 @@ test_gengrid2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
    evas_object_resize(win, 600, 600);
    evas_object_show(win);
 }
+
+void
+test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Evas_Object *win, *bg, *grid;
+   static Testitem ti[144];
+   int i, n;
+   char buf[PATH_MAX];
+
+   win = elm_win_add(NULL, "gengrid_group", ELM_WIN_BASIC);
+   elm_win_title_set(win, "GenGrid Group");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   bg = elm_bg_add(win);
+   evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bg);
+   evas_object_show(bg);
+
+   grid = elm_gengrid_add(win);
+   elm_gengrid_item_size_set(grid, 150, 150);
+   //elm_gengrid_group_item_size_set(grid, 31, 31);
+   //elm_gengrid_horizontal_set(grid, EINA_TRUE);
+   elm_gengrid_horizontal_set(grid, EINA_FALSE);
+   elm_gengrid_multi_select_set(grid, EINA_TRUE);
+   elm_gengrid_reorder_mode_set(grid, EINA_TRUE);
+   evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
+   evas_object_smart_callback_add(grid, "clicked,double", grid_double_clicked, NULL);
+   evas_object_smart_callback_add(grid, "longpressed", grid_longpress, NULL);
+   evas_object_smart_callback_add(grid, "moved", grid_moved, NULL);
+   evas_object_smart_callback_add(grid, "drag,start,up", grid_drag_up, NULL);
+   evas_object_smart_callback_add(grid, "drag,start,right", grid_drag_right, NULL);
+   evas_object_smart_callback_add(grid, "drag,start,down", grid_drag_down, NULL);
+   evas_object_smart_callback_add(grid, "drag,start,left", grid_drag_left, NULL);
+   evas_object_smart_callback_add(grid, "drag,stop", grid_drag_stop, NULL);
+   evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+   gic.item_style = "default";
+   gic.func.label_get = grid_label_get;
+   gic.func.content_get = grid_content_get;
+   gic.func.state_get = grid_state_get;
+   gic.func.del = grid_del;
+
+   ggic.item_style = "group_index";
+   ggic.func.label_get = grid_label_get;
+   ggic.func.content_get = NULL;
+   ggic.func.state_get = NULL;
+   ggic.func.del = NULL;
+
+
+   n = 0;
+   for (i = 0; i < 12 * 12; i++)
+     {
+       snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
+       n = (n + 1) % 9;
+       ti[i].mode = i;
+       ti[i].path = eina_stringshare_add(buf);
+        if (i == 0 || i == 18 || i == 53 || i == 100)
+        //if (i == 0 || i == 18)
+          ti[i].item = elm_gengrid_item_append(grid, &ggic, &(ti[i]), grid_sel, NULL);
+        else
+          ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), grid_sel, NULL);
+       if (!(i % 5))
+         elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
+     }
+
+   evas_object_show(grid);
+   elm_win_resize_object_add(win, grid);
+
+   evas_object_resize(win, 600, 600);
+   evas_object_show(win);
+}
+
 #endif