summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2015-11-24 18:08:50 +0100
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>2015-12-13 00:44:18 +0100
commitab9f78ace6361e57010a2c9370365a98301216d8 (patch)
treea31f49675cd0a249a509264e4de2bf0509471ef0
parentcafda5928f9bf8116564219dc03d12c3a6e131b3 (diff)
gengrid: add scrollto BOTTOM alignment type.devs/stanluk/genscroll
-rw-r--r--src/bin/test_gengrid.c166
-rw-r--r--src/lib/elm_gengrid.c6
-rw-r--r--src/lib/elm_gengrid_item.eo3
3 files changed, 65 insertions, 110 deletions
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index 523aaf330..6ba3622bc 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -36,8 +36,8 @@ typedef struct _api_data api_data;
36 36
37struct _Show_Data 37struct _Show_Data
38{ 38{
39 int winmode;
40 int scrollto; 39 int scrollto;
40 Evas_Object *grid;
41}; 41};
42typedef struct _Show_Data Show_Data; 42typedef struct _Show_Data Show_Data;
43 43
@@ -1128,7 +1128,11 @@ static void
1128_rd1_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 1128_rd1_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1129{ 1129{
1130 Show_Data *sd = data; 1130 Show_Data *sd = data;
1131 sd->winmode = elm_radio_state_value_get(obj); 1131 int winmode = elm_radio_state_value_get(obj);
1132 if (winmode == 0)
1133 elm_gengrid_horizontal_set(sd->grid, EINA_TRUE);
1134 else if (winmode == 1)
1135 elm_gengrid_horizontal_set(sd->grid, EINA_FALSE);
1132} 1136}
1133 1137
1134static void 1138static void
@@ -1141,119 +1145,19 @@ _rd2_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
1141static void 1145static void
1142_bring_in_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1146_bring_in_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1143{ 1147{
1144 Evas_Object *win, *grid;
1145 static Item_Data ti[5000];
1146 int i, n;
1147 char buf[PATH_MAX];
1148
1149 if (!data) return;
1150
1151 Show_Data *sd = data; 1148 Show_Data *sd = data;
1152 1149 Elm_Object_Item *item = elm_gengrid_selected_item_get(sd->grid);
1153 if (sd->winmode == 0) 1150 elm_gengrid_item_bring_in(item, sd->scrollto);
1154 win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in"); 1151 elm_gengrid_item_selected_set(item, EINA_TRUE);
1155 else
1156 win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in");
1157 elm_win_autodel_set(win, EINA_TRUE);
1158
1159 grid = elm_gengrid_add(win);
1160 elm_gengrid_item_size_set(grid, 150, 150);
1161 elm_gengrid_group_item_size_set(grid, 31, 31);
1162 if (sd->winmode == 0)
1163 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1164 else if (sd->winmode == 1)
1165 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1166 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1167 elm_win_resize_object_add(win, grid);
1168 elm_gengrid_align_set(grid, 0.1, 0.1);
1169
1170 gic = elm_gengrid_item_class_new();
1171 gic->item_style = "default";
1172 gic->func.text_get = grid_text_get;
1173 gic->func.content_get = grid_content_get;
1174 gic->func.state_get = grid_state_get;
1175 gic->func.del = NULL;
1176
1177 n = 0;
1178 for (i = 0; i < 5000; i++)
1179 {
1180 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1181 n = (n + 1) % 9;
1182 ti[i].mode = i;
1183 ti[i].path = eina_stringshare_add(buf);
1184 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
1185 if (i == 1430)
1186 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
1187 }
1188
1189 elm_gengrid_item_class_free(gic);
1190 elm_gengrid_item_bring_in(ti[1430].item, sd->scrollto);
1191 evas_object_show(grid);
1192
1193 if (sd->winmode == 0)
1194 evas_object_resize(win, 600, 200);
1195 if (sd->winmode == 1)
1196 evas_object_resize(win, 600, 400);
1197 evas_object_show(win);
1198} 1152}
1199 1153
1200static void 1154static void
1201_show_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1155_show_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1202{ 1156{
1203 Evas_Object *win, *grid;
1204 static Item_Data ti[10000];
1205 int i, n;
1206 char buf[PATH_MAX];
1207
1208 if (!data) return;
1209
1210 Show_Data *sd = data; 1157 Show_Data *sd = data;
1211 1158 Elm_Object_Item *item = elm_gengrid_selected_item_get(sd->grid);
1212 if (sd->winmode == 0) 1159 elm_gengrid_item_show(item, sd->scrollto);
1213 win = elm_win_util_standard_add("horz show", "Horz Show"); 1160 elm_gengrid_item_selected_set(item, EINA_TRUE);
1214 else
1215 win = elm_win_util_standard_add("vertical show", "Vertical Show");
1216 elm_win_autodel_set(win, EINA_TRUE);
1217
1218 grid = elm_gengrid_add(win);
1219 elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(150), ELM_SCALE_SIZE(150));
1220 elm_gengrid_group_item_size_set(grid, ELM_SCALE_SIZE(31), ELM_SCALE_SIZE(31));
1221 if (sd->winmode == 0)
1222 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1223 else if (sd->winmode == 1)
1224 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1225 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1226 elm_win_resize_object_add(win, grid);
1227 elm_gengrid_align_set(grid, 0.1, 0.1);
1228
1229 gic = elm_gengrid_item_class_new();
1230 gic->item_style = "default";
1231 gic->func.text_get = grid_text_get;
1232 gic->func.content_get = grid_content_get;
1233 gic->func.state_get = grid_state_get;
1234 gic->func.del = NULL;
1235
1236 n = 0;
1237 for (i = 0; i < 10000; i++)
1238 {
1239 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1240 n = (n + 1) % 9;
1241 ti[i].mode = i;
1242 ti[i].path = eina_stringshare_add(buf);
1243 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
1244 if (i == 2579)
1245 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
1246 }
1247
1248 elm_gengrid_item_class_free(gic);
1249 evas_object_show(grid);
1250 elm_gengrid_item_show(ti[2579].item, sd->scrollto);
1251
1252 if (sd->winmode == 0)
1253 evas_object_resize(win, 600, 200);
1254 if (sd->winmode == 1)
1255 evas_object_resize(win, 600, 600);
1256 evas_object_show(win);
1257} 1161}
1258 1162
1259static Evas_Object * 1163static Evas_Object *
@@ -1345,14 +1249,26 @@ _scrollto_mode_frame_new(Evas_Object *win, void *data)
1345 evas_object_show(rd); 1249 evas_object_show(rd);
1346 elm_box_pack_end(bx, rd); 1250 elm_box_pack_end(bx, rd);
1347 1251
1252 rd = elm_radio_add(win);
1253 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1254 elm_radio_state_value_set(rd, 8);
1255 elm_object_text_set(rd, "SCROLLTO_BOTTOM");
1256 elm_radio_group_add(rd, rdg);
1257 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1258 evas_object_show(rd);
1259 elm_box_pack_end(bx, rd);
1260
1348 return fr; 1261 return fr;
1349} 1262}
1350 1263
1351void 1264void
1352test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1265test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1353{ 1266{
1354 Evas_Object *win, *bt, *bx, *bx2, *fr; 1267 Evas_Object *win, *bt, *bx, *bx2, *fr, *grid;
1355 Show_Data *sd = calloc(1, sizeof(Show_Data)); 1268 Show_Data *sd = calloc(1, sizeof(Show_Data));
1269 char buf[PATH_MAX];
1270 int i, n;
1271 static Item_Data ti[10000];
1356 1272
1357 win = elm_win_util_standard_add("gengrid-show-bringin", "GenGrid Show/Bring_in"); 1273 win = elm_win_util_standard_add("gengrid-show-bringin", "GenGrid Show/Bring_in");
1358 elm_win_autodel_set(win, EINA_TRUE); 1274 elm_win_autodel_set(win, EINA_TRUE);
@@ -1363,6 +1279,38 @@ test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
1363 elm_win_resize_object_add(win, bx); 1279 elm_win_resize_object_add(win, bx);
1364 evas_object_show(bx); 1280 evas_object_show(bx);
1365 1281
1282 grid = elm_gengrid_add(win);
1283 elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(150), ELM_SCALE_SIZE(150));
1284 elm_gengrid_group_item_size_set(grid, ELM_SCALE_SIZE(31), ELM_SCALE_SIZE(31));
1285 elm_gengrid_align_set(grid, 0.1, 0.1);
1286 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1287
1288 gic = elm_gengrid_item_class_new();
1289 gic->item_style = "default";
1290 gic->func.text_get = grid_text_get;
1291 gic->func.content_get = grid_content_get;
1292 gic->func.state_get = grid_state_get;
1293 gic->func.del = NULL;
1294
1295 for (i = 0, n = 0; i < 10000; i++)
1296 {
1297 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
1298 n = (n + 1) % 9;
1299 ti[i].mode = i;
1300 ti[i].path = eina_stringshare_add(buf);
1301 ti[i].item = elm_gengrid_item_append(grid, gic, &(ti[i]), grid_sel, NULL);
1302 if (i == 2579)
1303 elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
1304 }
1305
1306 elm_gengrid_item_class_free(gic);
1307 elm_gengrid_item_show(ti[2579].item, sd->scrollto);
1308 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1309 evas_object_size_hint_min_set(grid, 600, 400);
1310 evas_object_show(grid);
1311 sd->grid = grid;
1312 elm_box_pack_end(bx, grid);
1313
1366 bx2 = elm_box_add(bx); 1314 bx2 = elm_box_add(bx);
1367 elm_box_horizontal_set(bx2, EINA_TRUE); 1315 elm_box_horizontal_set(bx2, EINA_TRUE);
1368 elm_box_pack_end(bx, bx2); 1316 elm_box_pack_end(bx, bx2);
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 093f5e428..6e84810cf 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -400,6 +400,12 @@ _item_show_region(void *data)
400 it_xpos = it_xpos - ((vw - sd->item_width) / 2); 400 it_xpos = it_xpos - ((vw - sd->item_width) / 2);
401 it_ypos = it_ypos - ((vh - sd->item_height) / 2); 401 it_ypos = it_ypos - ((vh - sd->item_height) / 2);
402 break; 402 break;
403 case ELM_GENGRID_ITEM_SCROLLTO_BOTTOM:
404 eo_do(WIDGET(it), elm_interface_scrollable_content_viewport_geometry_get
405 (NULL, NULL, &vw, &vh));
406 it_xpos = it_xpos - vw + sd->item_width;
407 it_ypos = it_ypos - vh + sd->item_height;
408 break;
403 default: 409 default:
404 vw = sd->item_width; 410 vw = sd->item_width;
405 vh = sd->item_height; 411 vh = sd->item_height;
diff --git a/src/lib/elm_gengrid_item.eo b/src/lib/elm_gengrid_item.eo
index 0783ee576..719d00f07 100644
--- a/src/lib/elm_gengrid_item.eo
+++ b/src/lib/elm_gengrid_item.eo
@@ -7,7 +7,8 @@ enum Elm.Gengrid.Item.Scrollto_Type
7 none = 0, [[No scrollto.]] 7 none = 0, [[No scrollto.]]
8 in = (1 << 0), [[To the nearest viewport.]] 8 in = (1 << 0), [[To the nearest viewport.]]
9 top = (1 << 1), [[To the top of viewport.]] 9 top = (1 << 1), [[To the top of viewport.]]
10 middle = (1 << 2) [[To the middle of viewport.]] 10 middle = (1 << 2), [[To the middle of viewport.]]
11 bottom = (1 << 3) [[To the bottom of viewport.]]
11} 12}
12 13
13enum Elm.Gengrid.Item.Field_Type 14enum Elm.Gengrid.Item.Field_Type