summaryrefslogtreecommitdiff
path: root/src
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-05 16:37:26 +0900
commitd67f5ee94175fa1c12beecb3555bc03d0afb05fd (patch)
tree22015596721fbec4f73fd39e428868789e34a53e /src
parent6ad064cfe2b20f3ca77777e8333d73c836a4024e (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 Conflicts: src/bin/test_gengrid.c
Diffstat (limited to 'src')
-rw-r--r--src/bin/test_gengrid.c148
-rw-r--r--src/lib/elm_gengrid.c4
2 files changed, 78 insertions, 74 deletions
diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c
index b9dbe8c5e..f92fdcb5f 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
@@ -1022,9 +1022,9 @@ _bring_in_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info _
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();
1082
1083 if (!data) return;
1080 1084
1081 if(!data) return; 1085 Show_Data *sd = data;
1082
1083 show_data *s_data = 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,35 @@ _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
1159
1156 rd = elm_radio_add(win); 1160 rd = elm_radio_add(win);
1157 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1161 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1158 elm_radio_state_value_set(rd, 1); 1162 elm_radio_state_value_set(rd, 1);
1159 elm_object_text_set(rd, "vertical"); 1163 elm_object_text_set(rd, "vertical");
1160 elm_radio_group_add(rd, *rdg); 1164 elm_radio_group_add(rd, rdg);
1161 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, s_data); 1165 evas_object_smart_callback_add(rd, "changed", _rd1_changed_cb, sd);
1162 evas_object_show(rd); 1166 evas_object_show(rd);
1163 elm_box_pack_end(bx, rd); 1167 elm_box_pack_end(bx, rd);
1164 1168
1165 return fr; 1169 return fr;
1166} 1170}
1167 1171
1168Evas_Object * 1172static Evas_Object *
1169_scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data) 1173_scrollto_mode_frame_new(Evas_Object *win, void *data)
1170{ 1174{
1171 Evas_Object *fr, *bx, *rd; 1175 Evas_Object *fr, *bx, *rd, *rdg;
1172 show_data *s_data = data; 1176 Show_Data *sd = data;
1173 1177
1178
1174 fr = elm_frame_add(win); 1179 fr = elm_frame_add(win);
1175 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1180 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); 1181 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1177 elm_object_text_set(fr, "Scrollto Mode Set"); 1182 elm_object_text_set(fr, "Scrollto Mode");
1178 evas_object_show(fr); 1183 evas_object_show(fr);
1179 1184
1180 bx = elm_box_add(win); 1185 bx = elm_box_add(win);
@@ -1185,17 +1190,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); 1190 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1186 elm_radio_state_value_set(rd, 0); 1191 elm_radio_state_value_set(rd, 0);
1187 elm_object_text_set(rd, "SCROLLTO_NONE"); 1192 elm_object_text_set(rd, "SCROLLTO_NONE");
1188 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1193 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1189 evas_object_show(rd); 1194 evas_object_show(rd);
1190 elm_box_pack_end(bx, rd); 1195 elm_box_pack_end(bx, rd);
1191 *rdg = rd; 1196 rdg = rd;
1192 1197
1193 rd = elm_radio_add(win); 1198 rd = elm_radio_add(win);
1194 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1199 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1195 elm_radio_state_value_set(rd, 1); 1200 elm_radio_state_value_set(rd, 1);
1196 elm_object_text_set(rd, "SCROLLTO_IN"); 1201 elm_object_text_set(rd, "SCROLLTO_IN");
1197 elm_radio_group_add(rd, *rdg); 1202 elm_radio_group_add(rd, rdg);
1198 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1203 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1199 evas_object_show(rd); 1204 evas_object_show(rd);
1200 elm_box_pack_end(bx, rd); 1205 elm_box_pack_end(bx, rd);
1201 1206
@@ -1203,8 +1208,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); 1208 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1204 elm_radio_state_value_set(rd, 2); 1209 elm_radio_state_value_set(rd, 2);
1205 elm_object_text_set(rd, "SCROLLTO_TOP"); 1210 elm_object_text_set(rd, "SCROLLTO_TOP");
1206 elm_radio_group_add(rd, *rdg); 1211 elm_radio_group_add(rd, rdg);
1207 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1212 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1208 evas_object_show(rd); 1213 evas_object_show(rd);
1209 elm_box_pack_end(bx, rd); 1214 elm_box_pack_end(bx, rd);
1210 1215
@@ -1212,8 +1217,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); 1217 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1213 elm_radio_state_value_set(rd, 4); 1218 elm_radio_state_value_set(rd, 4);
1214 elm_object_text_set(rd, "SCROLLTO_MIDDLE"); 1219 elm_object_text_set(rd, "SCROLLTO_MIDDLE");
1215 elm_radio_group_add(rd, *rdg); 1220 elm_radio_group_add(rd, rdg);
1216 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, s_data); 1221 evas_object_smart_callback_add(rd, "changed", _rd2_changed_cb, sd);
1217 evas_object_show(rd); 1222 evas_object_show(rd);
1218 elm_box_pack_end(bx, rd); 1223 elm_box_pack_end(bx, rd);
1219 1224
@@ -1223,45 +1228,44 @@ _scrollto_mode_frame_new(Evas_Object *win, Evas_Object **rdg, void *data)
1223void 1228void
1224test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1229test_gengrid4(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1225{ 1230{
1226 Evas_Object *win, *bt, *bx, *bx2, *fr1, *fr2, *rd1 = NULL, *rd2 = NULL; 1231 Evas_Object *win, *bt, *bx, *bx2, *fr;
1227 api_data *api = calloc(1, sizeof(api_data)); 1232 Show_Data *sd = calloc(1, sizeof(Show_Data));
1228 show_data *s_data = calloc(1, sizeof(show_data));
1229 1233
1230 win = elm_win_util_standard_add("gengrid show/scroll_in", "GenGrid Show/Bring_in"); 1234 win = elm_win_util_standard_add("gengrid-show-bringin", "GenGrid Show/Bring_in");
1231 elm_win_autodel_set(win, EINA_TRUE); 1235 elm_win_autodel_set(win, EINA_TRUE);
1232 evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); 1236 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); 1237 evas_object_show(win);
1234 1238
1235 bx = elm_box_add(win); 1239 bx = elm_box_add(win);
1236 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1240 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1237 elm_win_resize_object_add(win, bx); 1241 elm_win_resize_object_add(win, bx);
1238 elm_box_horizontal_set(bx, EINA_TRUE);
1239 evas_object_show(bx); 1242 evas_object_show(bx);
1240 1243
1241 bx2 = elm_box_add(win); 1244 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); 1245 elm_box_horizontal_set(bx2, EINA_TRUE);
1246 elm_box_pack_end(bx, bx2);
1245 evas_object_show(bx2); 1247 evas_object_show(bx2);
1246 1248
1247 fr1 = _window_mode_frame_new(win, &rd1, s_data); 1249 fr = _window_mode_frame_new(bx2, sd);
1248 elm_box_pack_end(bx2, fr1); 1250 elm_box_pack_end(bx2, fr);
1249 1251
1250 fr2 = _scrollto_mode_frame_new(win, &rd2, s_data); 1252 fr = _scrollto_mode_frame_new(bx2, sd);
1251 elm_box_pack_end(bx2, fr2); 1253 elm_box_pack_end(bx2, fr);
1252 1254
1253 bt = elm_button_add(win); 1255 bx2 = elm_box_add(bx);
1254 elm_object_text_set(bt, "Region Show"); 1256 elm_box_horizontal_set(bx2, EINA_TRUE);
1255 evas_object_smart_callback_add(bt, "clicked", _show_clicked_cb, s_data); 1257 elm_box_pack_end(bx, bx2);
1256 elm_box_pack_end(bx, bt); 1258 evas_object_show(bx2);
1259
1260 bt = elm_button_add(bx2);
1261 elm_object_text_set(bt, "Show");
1262 evas_object_smart_callback_add(bt, "clicked", _show_clicked_cb, sd);
1263 elm_box_pack_end(bx2, bt);
1257 evas_object_show(bt); 1264 evas_object_show(bt);
1258 1265
1259 bt = elm_button_add(win); 1266 bt = elm_button_add(bx2);
1260 elm_object_text_set(bt, "Bring In"); 1267 elm_object_text_set(bt, "Bring In");
1261 evas_object_smart_callback_add(bt, "clicked", _bring_in_clicked_cb, s_data); 1268 evas_object_smart_callback_add(bt, "clicked", _bring_in_clicked_cb, sd);
1262 elm_box_pack_end(bx, bt); 1269 elm_box_pack_end(bx2, bt);
1263 evas_object_show(bt); 1270 evas_object_show(bt);
1264
1265 evas_object_resize(win, 300, 300);
1266 evas_object_show(win);
1267} 1271}
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;