summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangHyeon Lee <sh10233.lee@samsung.com>2014-01-21 16:54:59 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-01-21 16:54:59 +0900
commit8a6b898bca8b90ff64452b786a7c31ae1b2f8b81 (patch)
tree1681acbb3a9d9ac4b945e10de10e7221fdaa9e35
parentbbb5975c8c4ef64b613aaf1ed654142dafa23224 (diff)
[Gengrid] Refactoring gengrid item show reigion calculation
Summary: Gengrid _item_show_region function calculate gengrid x, y moving postion with scroll to type. Belows are summaries of this refactoring works. 1. Refactoring recalculation of scroll type. 2. Bug fix : - when x or y is 0, y or x value is set as default value, it->position-1. - when x or y is less then 1, calculation is not correct. - make calculate correct position of y when even though scroll direction is horiziontal (when virtical, x is also calculation correct position). 3. change smart data variable s_type to scroll_to_type to make unity on gen widget. (genlist smart data variable name is scroll_to_type); Reviewers: seoz, Hermet, raster Reviewed By: raster CC: bluezery Differential Revision: https://phab.enlightenment.org/D474
-rw-r--r--src/lib/elm_gengrid.c81
-rw-r--r--src/lib/elm_widget_gengrid.h2
2 files changed, 40 insertions, 43 deletions
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 98ba519cf..491a9b610 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -96,6 +96,7 @@ _item_show_region(void *data)
96{ 96{
97 Elm_Gengrid_Smart_Data *sd = data; 97 Elm_Gengrid_Smart_Data *sd = data;
98 Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0; 98 Evas_Coord cvw, cvh, it_xpos = 0, it_ypos = 0, col = 0, row = 0, minx = 0, miny = 0;
99 Evas_Coord vw = 0, vh = 0;
99 Elm_Gen_Item *it = NULL; 100 Elm_Gen_Item *it = NULL;
100 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh); 101 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &cvw, &cvh);
101 102
@@ -115,24 +116,15 @@ _item_show_region(void *data)
115 row = cvh / sd->item_height; 116 row = cvh / sd->item_height;
116 if (row <= 0) row = 1; 117 if (row <= 0) row = 1;
117 x = (it->position - 1) / row; 118 x = (it->position - 1) / row;
118 if (x > 0) 119 if (x == 0) y = it->position - 1;
119 y = (it->position - 1) % x; 120 else if (x > 0) y = (it->position - 1) % x;
120 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width) 121 if (x >= 1)
121 + (GG_IT(it)->prev_group * sd->group_item_width) 122 it_xpos = ((x - GG_IT(it)->prev_group) * sd->item_width)
122 + minx; 123 + (GG_IT(it)->prev_group * sd->group_item_width)
123 if (sd->s_type == ELM_GENGRID_ITEM_SCROLLTO_MIDDLE) 124 + minx;
124 { 125 else it_xpos = minx;
125 if (it_xpos > 0) it_xpos = it_xpos + (cvw / 2) - (sd->item_width / 2); 126 miny = miny + ((cvh - (sd->item_height * row))
126 else it_xpos = it_xpos - (cvw / 2) + (sd->item_width / 2); 127 * GG_IT(it)->wsd->align_y);
127 }
128 else if (sd->s_type == ELM_GENGRID_ITEM_SCROLLTO_TOP)
129 {
130 if (it_xpos > 0) it_xpos = it_xpos + cvw - sd->item_width;
131 }
132 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN)
133 {
134 it_xpos = 0;
135 }
136 it_ypos = y * sd->item_height + miny; 128 it_ypos = y * sd->item_height + miny;
137 it->x = x; 129 it->x = x;
138 it->y = y; 130 it->y = y;
@@ -142,41 +134,46 @@ _item_show_region(void *data)
142 col = cvw / sd->item_width; 134 col = cvw / sd->item_width;
143 if (col <= 0) col = 1; 135 if (col <= 0) col = 1;
144 y = (it->position - 1) / col; 136 y = (it->position - 1) / col;
145 if (y > 0) 137 if (y == 0) x = it->position - 1;
146 x = (it->position - 1) % y; 138 else if (y > 0) x = (it->position - 1) % y;
147 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
148 + (GG_IT(it)->prev_group * sd->group_item_height)
149 + miny;
150 if (sd->s_type == ELM_GENGRID_ITEM_SCROLLTO_MIDDLE)
151 {
152 if (it_ypos > 0) it_ypos = it_ypos + (cvh / 2) - (sd->item_height / 2);
153 else it_ypos = it_ypos - (cvh / 2) + (sd->item_height / 2);
154 }
155 else if (sd->s_type == ELM_GENGRID_ITEM_SCROLLTO_TOP)
156 {
157 if (it_ypos > 0) it_ypos = it_ypos + cvh - sd->item_height;
158 }
159 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN)
160 {
161 it_ypos = 0;
162 }
163 it_xpos = x * sd->item_width + minx; 139 it_xpos = x * sd->item_width + minx;
140 if (y >= 1)
141 it_ypos = ((y - GG_IT(it)->prev_group) * sd->item_height)
142 + (GG_IT(it)->prev_group * sd->group_item_height)
143 + miny;
144 else it_ypos = miny;
145 minx = minx + ((cvw - (sd->item_width * col))
146 * GG_IT(it)->wsd->align_x);
164 it->x = x; 147 it->x = x;
165 it->y = y; 148 it->y = y;
166 } 149 }
167 150
151 switch (sd->scroll_to_type)
152 {
153 case ELM_GENGRID_ITEM_SCROLLTO_TOP:
154 eo_do(WIDGET(it), elm_scrollable_interface_content_viewport_size_get(&vw, &vh));
155 break;
156 case ELM_GENGRID_ITEM_SCROLLTO_MIDDLE:
157 eo_do(WIDGET(it), elm_scrollable_interface_content_viewport_size_get(&vw, &vh));
158 it_xpos = it_xpos - ((vw - sd->item_width) / 2);
159 it_ypos = it_ypos - ((vh - sd->item_height) / 2);
160 break;
161 default:
162 vw = sd->item_width;
163 vh = sd->item_height;
164 break;
165 }
166
168 if (sd->show_region) 167 if (sd->show_region)
169 { 168 {
170 eo_do(WIDGET(it), elm_scrollable_interface_content_region_show( 169 eo_do(WIDGET(it), elm_scrollable_interface_content_region_show(
171 it_xpos, it_ypos, sd->item_width, 170 it_xpos, it_ypos, vw, vh));
172 sd->item_height));
173 sd->show_region = EINA_FALSE; 171 sd->show_region = EINA_FALSE;
174 } 172 }
175 if (sd->bring_in) 173 if (sd->bring_in)
176 { 174 {
177 eo_do(WIDGET(it), elm_scrollable_interface_region_bring_in( 175 eo_do(WIDGET(it), elm_scrollable_interface_region_bring_in(
178 it_xpos, it_ypos, sd->item_width, 176 it_xpos, it_ypos, vw, vh));
179 sd->item_height));
180 sd->bring_in = EINA_FALSE; 177 sd->bring_in = EINA_FALSE;
181 } 178 }
182 } 179 }
@@ -3811,7 +3808,7 @@ elm_gengrid_item_show(Elm_Object_Item *item,
3811 3808
3812 sd->show_region = EINA_TRUE; 3809 sd->show_region = EINA_TRUE;
3813 sd->show_it = it; 3810 sd->show_it = it;
3814 sd->s_type = type; 3811 sd->scroll_to_type = type;
3815 3812
3816 _item_show_region(sd); 3813 _item_show_region(sd);
3817} 3814}
@@ -3830,7 +3827,7 @@ elm_gengrid_item_bring_in(Elm_Object_Item *item,
3830 3827
3831 sd->bring_in = EINA_TRUE; 3828 sd->bring_in = EINA_TRUE;
3832 sd->bring_in_it = it; 3829 sd->bring_in_it = it;
3833 sd->s_type = type; 3830 sd->scroll_to_type = type;
3834 3831
3835 _item_show_region(sd); 3832 _item_show_region(sd);
3836} 3833}
diff --git a/src/lib/elm_widget_gengrid.h b/src/lib/elm_widget_gengrid.h
index 7748252bf..52a4ea0fd 100644
--- a/src/lib/elm_widget_gengrid.h
+++ b/src/lib/elm_widget_gengrid.h
@@ -40,7 +40,7 @@ struct _Elm_Gengrid_Smart_Data
40 Elm_Object_Item *last_selected_item; 40 Elm_Object_Item *last_selected_item;
41 Elm_Gen_Item *show_it; 41 Elm_Gen_Item *show_it;
42 Elm_Gen_Item *bring_in_it; 42 Elm_Gen_Item *bring_in_it;
43 Elm_Gengrid_Item_Scrollto_Type s_type; 43 Elm_Gengrid_Item_Scrollto_Type scroll_to_type;
44 44
45 Ecore_Job *calc_job; 45 Ecore_Job *calc_job;
46 int walking; 46 int walking;