summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <juyung.seo@samsung.com>2013-12-02 20:32:14 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2013-12-02 20:32:14 +0900
commit625ee2151ffac9021226c9ad7b29b091e774e67c (patch)
tree3f3c0872b946571fba497b4349c343f4fdb60de5
parent1f38e52d9946377bd613953e935e343920fbbebf (diff)
gengrid: refactoring of commit 7187a3124fc6c169fcfec2c249a1fd483481fbba.
- follow the convention for structure name - removed unnecessary callback - removed wrong api usage - removed unnecessary variables - removed unnecessary parameter passing - fixed ugly ui - added 'static' to local function - changed frame description more descriptive - fixed formatting
-rw-r--r--src/bin/test_gengrid.c146
-rw-r--r--src/lib/elm_gengrid.c4
2 files changed, 76 insertions, 74 deletions
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index 064f36e95..d01f35dfb 100644
--- a/src/bin/test_gengrid.c
+++ b/src/bin/test_gengrid.c
@@ -36,12 +36,12 @@ struct _api_data
36}; 36};
37typedef struct _api_data api_data; 37typedef struct _api_data api_data;
38 38
39struct _show_data 39struct _Show_Data
40{ 40{
41 int winmode; 41 int winmode;
42 int scrollto; 42 int scrollto;
43}; 43};
44typedef struct _show_data show_data; 44typedef struct _Show_Data Show_Data;
45 45
46enum _api_state 46enum _api_state
47{ 47{
@@ -1001,15 +1001,15 @@ test_gengrid_item_styles(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1001static void 1001static void
1002_rd1_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) 1002_rd1_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1003{ 1003{
1004 show_data *s_data = data; 1004 Show_Data *sd = data;
1005 s_data->winmode = elm_radio_state_value_get(obj); 1005 sd->winmode = elm_radio_state_value_get(obj);
1006} 1006}
1007 1007
1008static void 1008static void
1009_rd2_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__) 1009_rd2_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1010{ 1010{
1011 show_data *s_data = data; 1011 Show_Data *sd = data;
1012 s_data->scrollto = elm_radio_state_value_get(obj); 1012 sd->scrollto = elm_radio_state_value_get(obj);
1013} 1013}
1014 1014
1015static void 1015static void
@@ -1020,11 +1020,11 @@ _bring_in_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info _
1020 int i, n; 1020 int i, n;
1021 char buf[PATH_MAX]; 1021 char buf[PATH_MAX];
1022 1022
1023 if(!data) return; 1023 if (!data) return;
1024 1024
1025 show_data *s_data = data; 1025 Show_Data *sd = data;
1026 1026
1027 if (s_data->winmode == 0) 1027 if (sd->winmode == 0)
1028 win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in"); 1028 win = elm_win_util_standard_add("horz bring_in", "Horz Bring_in");
1029 else 1029 else
1030 win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in"); 1030 win = elm_win_util_standard_add("vertical bring_in", "Vertical Bring_in");
@@ -1033,11 +1033,12 @@ _bring_in_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info _
1033 grid = elm_gengrid_add(win); 1033 grid = elm_gengrid_add(win);
1034 elm_gengrid_item_size_set(grid, 150, 150); 1034 elm_gengrid_item_size_set(grid, 150, 150);
1035 elm_gengrid_group_item_size_set(grid, 31, 31); 1035 elm_gengrid_group_item_size_set(grid, 31, 31);
1036 if (s_data->winmode == 0) 1036 if (sd->winmode == 0)
1037 elm_gengrid_horizontal_set(grid, EINA_TRUE); 1037 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1038 else if (s_data->winmode == 1) 1038 else if (sd->winmode == 1)
1039 elm_gengrid_horizontal_set(grid, EINA_FALSE); 1039 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1040 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1040 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1041 elm_win_resize_object_add(win, grid);
1041 elm_gengrid_align_set(grid, 0.1, 0.1); 1042 elm_gengrid_align_set(grid, 0.1, 0.1);
1042 1043
1043 gic = elm_gengrid_item_class_new(); 1044 gic = elm_gengrid_item_class_new();
@@ -1060,12 +1061,12 @@ _bring_in_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info _
1060 } 1061 }
1061 1062
1062 elm_gengrid_item_class_free(gic); 1063 elm_gengrid_item_class_free(gic);
1063 elm_gengrid_item_bring_in(ti[1430].item, s_data->scrollto); 1064 elm_gengrid_item_bring_in(ti[1430].item, sd->scrollto);
1064 evas_object_show(grid); 1065 evas_object_show(grid);
1065 elm_win_resize_object_add(win, grid); 1066
1066 if (s_data->winmode == 0) 1067 if (sd->winmode == 0)
1067 evas_object_resize(win, 600, 200); 1068 evas_object_resize(win, 600, 200);
1068 if (s_data->winmode == 1) 1069 if (sd->winmode == 1)
1069 evas_object_resize(win, 600, 400); 1070 evas_object_resize(win, 600, 400);
1070 evas_object_show(win); 1071 evas_object_show(win);
1071} 1072}
@@ -1077,25 +1078,27 @@ _show_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNU
1077 static Item_Data ti[10000]; 1078 static Item_Data ti[10000];
1078 int i, n; 1079 int i, n;
1079 char buf[PATH_MAX]; 1080 char buf[PATH_MAX];
1081 double scale = elm_config_scale_get();
1080 1082
1081 if(!data) return; 1083 if (!data) return;
1082 1084
1083 show_data *s_data = data; 1085 Show_Data *sd = data;
1084 1086
1085 if (s_data->winmode == 0) 1087 if (sd->winmode == 0)
1086 win = elm_win_util_standard_add("horz show", "Horz Show"); 1088 win = elm_win_util_standard_add("horz show", "Horz Show");
1087 else 1089 else
1088 win = elm_win_util_standard_add("vertical show", "Vertical Show"); 1090 win = elm_win_util_standard_add("vertical show", "Vertical Show");
1089 elm_win_autodel_set(win, EINA_TRUE); 1091 elm_win_autodel_set(win, EINA_TRUE);
1090 1092
1091 grid = elm_gengrid_add(win); 1093 grid = elm_gengrid_add(win);
1092 elm_gengrid_item_size_set(grid, 150, 150); 1094 elm_gengrid_item_size_set(grid, 150 * scale, 150 * scale);
1093 elm_gengrid_group_item_size_set(grid, 31, 31); 1095 elm_gengrid_group_item_size_set(grid, 31 * scale, 31 * scale);
1094 if (s_data->winmode == 0) 1096 if (sd->winmode == 0)
1095 elm_gengrid_horizontal_set(grid, EINA_TRUE); 1097 elm_gengrid_horizontal_set(grid, EINA_TRUE);
1096 else if (s_data->winmode == 1) 1098 else if (sd->winmode == 1)
1097 elm_gengrid_horizontal_set(grid, EINA_FALSE); 1099 elm_gengrid_horizontal_set(grid, EINA_FALSE);
1098 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1100 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1101 elm_win_resize_object_add(win, grid);
1099 elm_gengrid_align_set(grid, 0.1, 0.1); 1102 elm_gengrid_align_set(grid, 0.1, 0.1);
1100 1103
1101 gic = elm_gengrid_item_class_new(); 1104 gic = elm_gengrid_item_class_new();
@@ -1119,25 +1122,25 @@ _show_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNU
1119 1122
1120 elm_gengrid_item_class_free(gic); 1123 elm_gengrid_item_class_free(gic);
1121 evas_object_show(grid); 1124 evas_object_show(grid);
1122 elm_gengrid_item_show(ti[2579].item, s_data->scrollto); 1125 elm_gengrid_item_show(ti[2579].item, sd->scrollto);
1123 elm_win_resize_object_add(win, grid); 1126
1124 if (s_data->winmode == 0) 1127 if (sd->winmode == 0)
1125 evas_object_resize(win, 600, 200); 1128 evas_object_resize(win, 600, 200);
1126 if (s_data->winmode == 1) 1129 if (sd->winmode == 1)
1127 evas_object_resize(win, 600, 600); 1130 evas_object_resize(win, 600, 600);
1128 evas_object_show(win); 1131 evas_object_show(win);
1129} 1132}
1130 1133
1131Evas_Object * 1134static Evas_Object *
1132_window_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data) 1135_window_mode_frame_new(Evas_Object *win, void *data)
1133{ 1136{
1134 Evas_Object *fr, *bx, *rd; 1137 Evas_Object *fr, *bx, *rd, *rdg;
1135 show_data *s_data = data; 1138 Show_Data *sd = data;
1136 1139
1137 fr = elm_frame_add(win); 1140 fr = elm_frame_add(win);
1138 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1141 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1139 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 1142 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1140 elm_object_text_set(fr, "Window Mode Set"); 1143 elm_object_text_set(fr, "Direction");
1141 evas_object_show(fr); 1144 evas_object_show(fr);
1142 1145
1143 bx = elm_box_add(win); 1146 bx = elm_box_add(win);
@@ -1148,33 +1151,33 @@ _window_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1148 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1151 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1149 elm_radio_state_value_set(rd, 0); 1152 elm_radio_state_value_set(rd, 0);
1150 elm_object_text_set(rd, "horizontal"); 1153 elm_object_text_set(rd, "horizontal");
1151 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, s_data); 1154 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, sd);
1152 evas_object_show(rd); 1155 evas_object_show(rd);
1153 elm_box_pack_end(bx, rd); 1156 elm_box_pack_end(bx, rd);
1154 *rdg = rd; 1157 rdg = rd;
1155 1158
1156 rd = elm_radio_add(win); 1159 rd = elm_radio_add(win);
1157 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1160 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1158 elm_radio_state_value_set(rd, 1); 1161 elm_radio_state_value_set(rd, 1);
1159 elm_object_text_set(rd, "vertical"); 1162 elm_object_text_set(rd, "vertical");
1160 elm_radio_group_add(rd, *rdg); 1163 elm_radio_group_add(rd, rdg);
1161 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, s_data); 1164 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, sd);
1162 evas_object_show(rd); 1165 evas_object_show(rd);
1163 elm_box_pack_end(bx, rd); 1166 elm_box_pack_end(bx, rd);
1164 1167
1165 return fr; 1168 return fr;
1166} 1169}
1167 1170
1168Evas_Object * 1171static Evas_Object *
1169_scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data) 1172_scrollto_mode_frame_new(Evas_Object *win, void *data)
1170{ 1173{
1171 Evas_Object *fr, *bx, *rd; 1174 Evas_Object *fr, *bx, *rd, *rdg;
1172 show_data *s_data = data; 1175 Show_Data *sd = data;
1173 1176
1174 fr = elm_frame_add(win); 1177 fr = elm_frame_add(win);
1175 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1178 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1176 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 1179 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1177 elm_object_text_set(fr, "Scrollto Mode Set"); 1180 elm_object_text_set(fr, "Scrollto Mode");
1178 evas_object_show(fr); 1181 evas_object_show(fr);
1179 1182
1180 bx = elm_box_add(win); 1183 bx = elm_box_add(win);
@@ -1185,17 +1188,17 @@ _scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1185 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1188 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1186 elm_radio_state_value_set(rd, 0); 1189 elm_radio_state_value_set(rd, 0);
1187 elm_object_text_set(rd, "SCROLLTO_NONE"); 1190 elm_object_text_set(rd, "SCROLLTO_NONE");
1188 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1191 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1189 evas_object_show(rd); 1192 evas_object_show(rd);
1190 elm_box_pack_end(bx, rd); 1193 elm_box_pack_end(bx, rd);
1191 *rdg = rd; 1194 rdg = rd;
1192 1195
1193 rd = elm_radio_add(win); 1196 rd = elm_radio_add(win);
1194 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1197 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1195 elm_radio_state_value_set(rd, 1); 1198 elm_radio_state_value_set(rd, 1);
1196 elm_object_text_set(rd, "SCROLLTO_IN"); 1199 elm_object_text_set(rd, "SCROLLTO_IN");
1197 elm_radio_group_add(rd, *rdg); 1200 elm_radio_group_add(rd, rdg);
1198 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1201 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1199 evas_object_show(rd); 1202 evas_object_show(rd);
1200 elm_box_pack_end(bx, rd); 1203 elm_box_pack_end(bx, rd);
1201 1204
@@ -1203,8 +1206,8 @@ _scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1203 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1206 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1204 elm_radio_state_value_set(rd, 2); 1207 elm_radio_state_value_set(rd, 2);
1205 elm_object_text_set(rd, "SCROLLTO_TOP"); 1208 elm_object_text_set(rd, "SCROLLTO_TOP");
1206 elm_radio_group_add(rd, *rdg); 1209 elm_radio_group_add(rd, rdg);
1207 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1210 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1208 evas_object_show(rd); 1211 evas_object_show(rd);
1209 elm_box_pack_end(bx, rd); 1212 elm_box_pack_end(bx, rd);
1210 1213
@@ -1212,8 +1215,8 @@ _scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1212 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1215 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1213 elm_radio_state_value_set(rd, 4); 1216 elm_radio_state_value_set(rd, 4);
1214 elm_object_text_set(rd, "SCROLLTO_MIDDLE"); 1217 elm_object_text_set(rd, "SCROLLTO_MIDDLE");
1215 elm_radio_group_add(rd, *rdg); 1218 elm_radio_group_add(rd, rdg);
1216 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1219 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1217 evas_object_show(rd); 1220 evas_object_show(rd);
1218 elm_box_pack_end(bx, rd); 1221 elm_box_pack_end(bx, rd);
1219 1222
@@ -1223,45 +1226,44 @@ _scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1223void 1226void
1224test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1227test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1225{ 1228{
1226 Evas_Object *win, *bt, *bx, *bx2, *fr1, *fr2, *rd1 = NULL, *rd2 = NULL; 1229 Evas_Object *win, *bt, *bx, *bx2, *fr;
1227 api_data *api = calloc(1, sizeof(api_data)); 1230 Show_Data *sd = calloc(1, sizeof(Show_Data));
1228 show_data *s_data = calloc(1, sizeof(show_data));
1229 1231
1230 win = elm_win_util_standard_add("gengrid show/scroll_in", "GenGrid Show/Bring_in"); 1232 win = elm_win_util_standard_add("gengrid-show-bringin", "GenGrid Show/Bring_in");
1231 elm_win_autodel_set(win, EINA_TRUE); 1233 elm_win_autodel_set(win, EINA_TRUE);
1232 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); 1234 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, sd);
1233 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, s_data); 1235 evas_object_show(win);
1234 1236
1235 bx = elm_box_add(win); 1237 bx = elm_box_add(win);
1236 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1238 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1237 elm_win_resize_object_add(win, bx); 1239 elm_win_resize_object_add(win, bx);
1238 elm_box_horizontal_set(bx, EINA_TRUE);
1239 evas_object_show(bx); 1240 evas_object_show(bx);
1240 1241
1241 bx2 = elm_box_add(win); 1242 bx2 = elm_box_add(bx);
1242 evas_object_size_hint_weight_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1243 elm_win_resize_object_add(bx, bx2);
1244 elm_box_horizontal_set(bx2, EINA_TRUE); 1243 elm_box_horizontal_set(bx2, EINA_TRUE);
1244 elm_box_pack_end(bx, bx2);
1245 evas_object_show(bx2); 1245 evas_object_show(bx2);
1246 1246
1247 fr1 = _window_mode_frame_new(win, &rd1, s_data); 1247 fr = _window_mode_frame_new(bx2, sd);
1248 elm_box_pack_end(bx2, fr1); 1248 elm_box_pack_end(bx2, fr);
1249 1249
1250 fr2 = _scrollto_mode_frame_new(win, &rd2, s_data); 1250 fr = _scrollto_mode_frame_new(bx2, sd);
1251 elm_box_pack_end(bx2, fr2); 1251 elm_box_pack_end(bx2, fr);
1252 1252
1253 bt = elm_button_add(win); 1253 bx2 = elm_box_add(bx);
1254 elm_object_text_set(bt, "Region Show"); 1254 elm_box_horizontal_set(bx2, EINA_TRUE);
1255 evas_object_smart_callback_add(bt, "clicked", _show_clicked_cb, s_data); 1255 elm_box_pack_end(bx, bx2);
1256 elm_box_pack_end(bx, bt); 1256 evas_object_show(bx2);
1257
1258 bt = elm_button_add(bx2);
1259 elm_object_text_set(bt, "Show");
1260 evas_object_smart_callback_add(bt, "clicked", _show_clicked_cb, sd);
1261 elm_box_pack_end(bx2, bt);
1257 evas_object_show(bt); 1262 evas_object_show(bt);
1258 1263
1259 bt = elm_button_add(win); 1264 bt = elm_button_add(bx2);
1260 elm_object_text_set(bt, "Bring In"); 1265 elm_object_text_set(bt, "Bring In");
1261 evas_object_smart_callback_add(bt, "clicked", _bring_in_clicked_cb, s_data); 1266 evas_object_smart_callback_add(bt, "clicked", _bring_in_clicked_cb, sd);
1262 elm_box_pack_end(bx, bt); 1267 elm_box_pack_end(bx2, bt);
1263 evas_object_show(bt); 1268 evas_object_show(bt);
1264
1265 evas_object_resize(win, 300, 300);
1266 evas_object_show(win);
1267} 1269}
diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c
index 7ceebc7ab..e872e943a 100644
--- a/src/lib/elm_gengrid.c
+++ b/src/lib/elm_gengrid.c
@@ -131,7 +131,7 @@ _item_show_region(void *data)
131 } 131 }
132 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN) 132 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN)
133 { 133 {
134 it_xpos = 0; 134 it_xpos = 0;
135 } 135 }
136 it_ypos = y * sd->item_height + miny; 136 it_ypos = y * sd->item_height + miny;
137 it->x = x; 137 it->x = x;
@@ -158,7 +158,7 @@ _item_show_region(void *data)
158 } 158 }
159 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN) 159 else if (sd->s_type != ELM_GENGRID_ITEM_SCROLLTO_IN)
160 { 160 {
161 it_ypos = 0; 161 it_ypos = 0;
162 } 162 }
163 it_xpos = x * sd->item_width + minx; 163 it_xpos = x * sd->item_width + minx;
164 it->x = x; 164 it->x = x;