aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDUBEYPRINCE KUMAR <prince.dubey@samsung.com>2013-01-03 12:03:55 +0000
committerCarsten Haitzler <raster@rasterman.com>2013-01-03 12:03:55 +0000
commitac8e33ea76126e5fb409073183820f027e42fe36 (patch)
tree65e0ad518304804cccf24d60e531dd40a20dbc54
parentelementary/naviframe - fixed some unacceptable stuffs. (diff)
downloadefl-ac8e33ea76126e5fb409073183820f027e42fe36.tar.gz
From: DUBEYPRINCE KUMAR <prince.dubey@samsung.com>
Subject: [E-devel] [BUG] [ELM] [PATCH] Bug fixes for APIs elm_gengrid_region_show/bring_in Please review the attached patches. Attached patch "elm_gengrid.patch" which fix the bug related to elm_gengrid_region_show/bring_in APIs. And patch "test_gengrid.patch" in order to test the fix. Change Description: 1. An internal function _item_show_region() is created which does the calculation for item position. 2. This function is called in _calc_job() as soon as pan object gets its size. 3. Test_gengrid code enhancement for testing the fix. SVN revision: 82063
-rw-r--r--legacy/elementary/ChangeLog4
-rw-r--r--legacy/elementary/src/bin/test.c2
-rw-r--r--legacy/elementary/src/bin/test_gengrid.c226
-rw-r--r--legacy/elementary/src/lib/elm_gengrid.c108
-rw-r--r--legacy/elementary/src/lib/elm_widget_gengrid.h4
5 files changed, 315 insertions, 29 deletions
diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog
index c7e01dcbfc..33bc84260a 100644
--- a/legacy/elementary/ChangeLog
+++ b/legacy/elementary/ChangeLog
@@ -878,3 +878,7 @@
2013-01-03 Jaehwan Kim
* Fix the bug which the callbacks of the sub-object are added even if the sub-object is added the parent object.
+
+2012-01-03 Prince Dubey Kumar <prince.dubey@samsung.com>
+
+ * Fix gengrid region_show/bring_in and add test
diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c
index 2ba08bc451..f62d5cac94 100644
--- a/legacy/elementary/src/bin/test.c
+++ b/legacy/elementary/src/bin/test.c
@@ -115,6 +115,7 @@ void test_gengrid(void *data, Evas_Object *obj, void *event_info);
void test_gengrid2(void *data, Evas_Object *obj, void *event_info);
void test_gengrid3(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info);
+void test_gengrid4(void *data, Evas_Object *obj, void *event_info);
void test_win_state(void *data, Evas_Object *obj, void *event_info);
void test_win_state2(void *data, Evas_Object *obj, void *event_info);
void test_progressbar(void *data, Evas_Object *obj, void *event_info);
@@ -607,6 +608,7 @@ add_tests:
ADD_TEST(NULL, "Lists", "GenGrid", test_gengrid);
ADD_TEST(NULL, "Lists", "GenGrid 2", test_gengrid2);
ADD_TEST(NULL, "Lists", "GenGrid Group", test_gengrid3);
+ ADD_TEST(NULL, "Lists", "GenGrid Show/Bring_in", test_gengrid4);
ADD_TEST(NULL, "Lists", "GenGrid Item Styles", test_gengrid_item_styles);
//------------------------------//
diff --git a/legacy/elementary/src/bin/test_gengrid.c b/legacy/elementary/src/bin/test_gengrid.c
index 3909021036..4c94bf9941 100644
--- a/legacy/elementary/src/bin/test_gengrid.c
+++ b/legacy/elementary/src/bin/test_gengrid.c
@@ -312,7 +312,6 @@ create_gengrid(Evas_Object *obj, int items)
elm_config_scale_get() * 150,
elm_config_scale_get() * 150);
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);
@@ -860,7 +859,6 @@ test_gengrid3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
evas_object_show(grid);
elm_win_resize_object_add(win, grid);
-
evas_object_resize(win, 600, 600);
evas_object_show(win);
}
@@ -998,4 +996,228 @@ test_gengrid_item_styles(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
evas_object_show(gengrid);
}
+static void
+_bring_in2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *grid;
+ static Testitem ti[5000];
+ int i, n;
+ char buf[PATH_MAX];
+
+ win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ 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);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_gengrid_align_set(grid, 0.4, 0.8);
+
+ gic = elm_gengrid_item_class_new();
+ gic->item_style = "default";
+ gic->func.text_get = grid_text_get;
+ gic->func.content_get = grid_content_get;
+ gic->func.state_get = grid_state_get;
+ gic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 5000; 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);
+ ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
+ if (i == 2400)
+ elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
+ }
+
+ elm_gengrid_item_class_free(gic);
+ evas_object_show(grid);
+ elm_gengrid_item_bring_in(ti[2400].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
+ elm_win_resize_object_add(win, grid);
+ evas_object_resize(win, 600, 200);
+ evas_object_show(win);
+}
+
+static void
+_bring_in1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *grid;
+ static Testitem ti[5000];
+ int i, n;
+ char buf[PATH_MAX];
+
+ win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ 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_FALSE);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_gengrid_align_set(grid, 0.1, 1.0);
+
+ gic = elm_gengrid_item_class_new();
+ gic->item_style = "default";
+ gic->func.text_get = grid_text_get;
+ gic->func.content_get = grid_content_get;
+ gic->func.state_get = grid_state_get;
+ gic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 5000; 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);
+ ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
+ if (i == 1430)
+ elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
+ }
+
+ elm_gengrid_item_class_free(gic);
+ elm_gengrid_item_bring_in(ti[1430].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
+ evas_object_show(grid);
+ elm_win_resize_object_add(win, grid);
+ evas_object_resize(win, 600, 400);
+ evas_object_show(win);
+}
+
+
+static void
+_show2_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *grid;
+ static Testitem ti[10000];
+ int i, n;
+ char buf[PATH_MAX];
+
+ win = elm_win_util_standard_add("horz show", "Horz Show");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ 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);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_gengrid_align_set(grid, 0.3, 0.7);
+
+ gic = elm_gengrid_item_class_new();
+ gic->item_style = "default";
+ gic->func.text_get = grid_text_get;
+ gic->func.content_get = grid_content_get;
+ gic->func.state_get = grid_state_get;
+ gic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 10000; 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);
+ ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
+ if (i == 3333)
+ elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
+ }
+
+ elm_gengrid_item_class_free(gic);
+ evas_object_show(grid);
+ elm_gengrid_item_show(ti[3333].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
+ elm_win_resize_object_add(win, grid);
+ evas_object_resize(win, 600, 200);
+ evas_object_show(win);
+}
+
+static void
+_show1_clicked_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *grid;
+ static Testitem ti[10000];
+ int i, n;
+ char buf[PATH_MAX];
+
+ win = elm_win_util_standard_add("vertical show", "Vertical Show");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ 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_FALSE);
+ evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_gengrid_align_set(grid, 0.1, 0.3);
+
+ gic = elm_gengrid_item_class_new();
+ gic->item_style = "default";
+ gic->func.text_get = grid_text_get;
+ gic->func.content_get = grid_content_get;
+ gic->func.state_get = grid_state_get;
+ gic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 10000; 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);
+ ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
+ if (i == 2579)
+ elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
+ }
+
+ elm_gengrid_item_class_free(gic);
+ evas_object_show(grid);
+ elm_gengrid_item_show(ti[2579].item, ELM_GENGRID_ITEM_SCROLLTO_IN);
+ elm_win_resize_object_add(win, grid);
+ evas_object_resize(win, 600, 600);
+ evas_object_show(win);
+}
+
+void
+test_gengrid4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Evas_Object *win, *bt, *bx;
+ api_data *api = calloc(1, sizeof(api_data));
+
+ win = elm_win_util_standard_add("gengrid show/scroll_in", "GenGrid Show/Bring_in");
+ elm_win_autodel_set(win, EINA_TRUE);
+ evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ elm_box_horizontal_set(bx, EINA_TRUE);
+ evas_object_show(bx);
+
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Vertical Show");
+ evas_object_smart_callback_add(bt, "clicked", _show1_clicked_cb, NULL);
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Vertical Bring_in");
+ evas_object_smart_callback_add(bt, "clicked", _bring_in1_clicked_cb, NULL);
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Horz Show");
+ evas_object_smart_callback_add(bt, "clicked", _show2_clicked_cb, NULL);
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
+ elm_object_text_set(bt, "Horz Bring_in");
+ evas_object_smart_callback_add(bt, "clicked", _bring_in2_clicked_cb, NULL);
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+
+ evas_object_resize(win, 300, 300);
+ evas_object_show(win);
+}
#endif
diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c
index 236cb7e17d..e2439262e7 100644
--- a/legacy/elementary/src/lib/elm_gengrid.c
+++ b/legacy/elementary/src/lib/elm_gengrid.c
@@ -86,6 +86,73 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
};
static void
+_item_show_region(void *data)
+{
+ Elm_Gengrid_Smart_Data *sd = data;
+ Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0;
+ Elm_Gen_Item *it = NULL;
+
+ evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
+
+ if ((cvw != 0) && (cvh != 0))
+ {
+ int x = 0, y = 0;
+ if (sd->show_region)
+ it = sd->show_it;
+ else if (sd->bring_in)
+ it = sd->bring_in_it;
+
+ if (!it) return;
+
+ eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
+
+ if (sd->horizontal && (sd->item_height > 0))
+ {
+ row = cvh / sd->item_height;
+ if (row <= 0) row = 1;
+ x = (it->position - 1) / row;
+ if (x > 0)
+ y = (it->position - 1) % x;
+ it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
+ + (GG_IT(it)->prev_group * sd->group_item_width)
+ + minx;
+ it_ypos = y * sd->item_height + miny;
+ it->x = x;
+ it->y = y;
+ }
+ else if (sd->item_width > 0)
+ {
+ col = cvw / sd->item_width;
+ if (col <= 0) col = 1;
+ y = (it->position - 1) / col;
+ if (y > 0)
+ x = (it->position - 1) % y;
+ it_xpos = x * sd->item_width + minx;
+ it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
+ + (GG_IT(it)->prev_group * sd->group_item_height)
+ + miny;
+ it->x = x;
+ it->y = y;
+ }
+
+ if (sd->show_region)
+ {
+ eo_do(WIDGET(it), elm_scrollable_interface_content_region_show(
+ it_xpos, it_ypos, sd->item_width,
+ sd->item_height));
+ sd->show_region = EINA_FALSE;
+ }
+ if (sd->bring_in)
+ {
+ eo_do(WIDGET(it), elm_scrollable_interface_region_bring_in(
+ it_xpos, it_ypos, sd->item_width,
+ sd->item_height));
+ sd->bring_in = EINA_FALSE;
+ }
+ }
+}
+
+static void
_calc_job(void *data)
{
Elm_Gengrid_Smart_Data *sd = data;
@@ -97,6 +164,7 @@ _calc_job(void *data)
sd->items_lost = 0;
evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
+
if ((cvw != 0) || (cvh != 0))
{
if ((sd->horizontal) && (sd->item_height > 0))
@@ -150,6 +218,9 @@ _calc_job(void *data)
sd->nmax = nmax;
evas_object_smart_changed(sd->pan_obj);
+
+ if (sd->show_region || sd->bring_in)
+ _item_show_region(sd);
}
sd->calc_job = NULL;
}
@@ -1247,6 +1318,7 @@ _elm_gengrid_pan_smart_calculate(Eo *obj EINA_UNUSED, void *_pd, va_list *list E
}
}
}
+
_item_place(it, cx, cy);
if (psd->wsd->reorder_item_changed) return;
if (it->group)
@@ -1287,6 +1359,7 @@ _elm_gengrid_pan_smart_calculate(Eo *obj EINA_UNUSED, void *_pd, va_list *list E
}
psd->wsd->move_effect_enabled = EINA_FALSE;
}
+
evas_object_smart_callback_call
(psd->wobj, SIG_CHANGED, NULL);
}
@@ -3555,30 +3628,21 @@ elm_gengrid_item_show(Elm_Object_Item *item,
{
Elm_Gen_Item *it = (Elm_Gen_Item *)item;
Elm_Gengrid_Smart_Data *sd;
- Evas_Coord minx = 0, miny = 0;
ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
sd = GG_IT(it)->wsd;
if ((it->generation < sd->generation)) return;
- eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
if (type == ELM_GENGRID_ITEM_SCROLLTO_IN)
{
//TODO : type based handling like gengrid
}
- if (sd->horizontal)
- eo_do(WIDGET(it), elm_scrollable_interface_content_region_show(
- ((it->x - GG_IT(it)->prev_group) * sd->item_width)
- + (GG_IT(it)->prev_group * sd->group_item_width) + minx,
- it->y * sd->item_height + miny, sd->item_width, sd->item_height));
- else
- eo_do(WIDGET(it), elm_scrollable_interface_content_region_show(
- it->x * sd->item_width + minx,
- ((it->y - GG_IT(it)->prev_group) * sd->item_height) +
- (GG_IT(it)->prev_group * sd->group_item_height) + miny,
- sd->item_width, sd->item_height));
+ sd->show_region = EINA_TRUE;
+ sd->show_it = it;
+
+ _item_show_region(sd);
}
EAPI void
@@ -3586,7 +3650,6 @@ elm_gengrid_item_bring_in(Elm_Object_Item *item,
Elm_Gengrid_Item_Scrollto_Type type)
{
Elm_Gengrid_Smart_Data *sd;
- Evas_Coord minx = 0, miny = 0;
Elm_Gen_Item *it = (Elm_Gen_Item *)item;
ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
@@ -3594,24 +3657,15 @@ elm_gengrid_item_bring_in(Elm_Object_Item *item,
if (it->generation < sd->generation) return;
- eo_do(sd->pan_obj, elm_obj_pan_pos_min_get(&minx, &miny));
-
if (type == ELM_GENGRID_ITEM_SCROLLTO_IN)
{
//TODO : type based handling like gengrid
}
- if (sd->horizontal)
- eo_do(WIDGET(it), elm_scrollable_interface_region_bring_in(
- ((it->x - GG_IT(it)->prev_group) * sd->item_width)
- + (GG_IT(it)->prev_group * sd->group_item_width) + minx,
- it->y * sd->item_height + miny, sd->item_width, sd->item_height));
- else
- eo_do(WIDGET(it), elm_scrollable_interface_region_bring_in(
- it->x * sd->item_width + minx,
- ((it->y - GG_IT(it)->prev_group) * sd->item_height)
- + (GG_IT(it)->prev_group * sd->group_item_height)
- + miny, sd->item_width, sd->item_height));
+ sd->bring_in = EINA_TRUE;
+ sd->bring_in_it = it;
+
+ _item_show_region(sd);
}
EAPI void
diff --git a/legacy/elementary/src/lib/elm_widget_gengrid.h b/legacy/elementary/src/lib/elm_widget_gengrid.h
index 7fb25aff16..09023a0279 100644
--- a/legacy/elementary/src/lib/elm_widget_gengrid.h
+++ b/legacy/elementary/src/lib/elm_widget_gengrid.h
@@ -37,6 +37,8 @@ struct _Elm_Gengrid_Smart_Data
* being
* repositioned */
Elm_Object_Item *last_selected_item;
+ Elm_Gen_Item *show_it;
+ Elm_Gen_Item *bring_in_it;
Ecore_Job *calc_job;
int walking;
@@ -99,6 +101,8 @@ struct _Elm_Gengrid_Smart_Data
Eina_Bool multi : 1; /* a flag for item
* multi
* selection */
+ Eina_Bool show_region : 1;
+ Eina_Bool bring_in : 1;
};
struct Elm_Gen_Item_Type