1 #include <Elementary.h>
14 static Evas_Object *main_layout = NULL;
15 static Evas_Object *map_layout = NULL;
16 static city_data_s city[MAXIMUM_SELECTED_CITY] = {{{0, 0, 0, 0, 0, 0}, NULL},
17 {{0, 0, 0, 0, 0, 0}, NULL},
18 {{0, 0, 0, 0, 0, 0}, NULL},
19 {{0, 0, 0, 0, 0, 0}, NULL},
20 {{0, 0, 0, 0, 0, 0}, NULL}};
24 map_geom_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
26 Evas_Coord x, y, w, h, x2, y2, w2, h2;
27 evas_object_geometry_get(obj, &x, &y, &w, &h);
28 double scale_w = (double) w / ORIGIN_W;
29 double scale_h = (double) h / ORIGIN_H;
32 for (idx = 0; MAXIMUM_SELECTED_CITY > idx; idx++)
34 if (!city[idx].obj) continue;
35 evas_object_move(city[idx].obj,
36 (int)((double)city[idx].ci.x * scale_w) + x - (city[idx].w / 2),
37 (int)((double)city[idx].ci.y * scale_h) + y - (city[idx].h / 2));
42 map_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
45 for (idx = 0; MAXIMUM_SELECTED_CITY > idx; idx++)
47 evas_object_del(city[idx].obj);
53 create_momentic_layout(Evas_Object *parent, const char *full_path)
56 main_layout = elm_layout_add(parent);
57 elm_layout_file_set(main_layout, full_path, "main");
58 evas_object_size_hint_weight_set(main_layout, EVAS_HINT_EXPAND,
62 map_layout = elm_layout_add(main_layout);
63 elm_layout_file_set(map_layout, full_path, "map");
64 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_RESIZE, map_geom_cb, NULL);
65 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_MOVE, map_geom_cb, NULL);
66 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_DEL, map_del_cb, NULL);
67 elm_object_part_content_set(main_layout, "map", map_layout);
73 add_city_to_map(int idx, city_s *ci)
76 char full_path[PATH_LEN] = {0, };
78 retv_if(idx >= MAXIMUM_SELECTED_CITY, EINA_FALSE);
79 retv_if(0 > idx, EINA_FALSE);
82 for (i = 0; i < MAXIMUM_SELECTED_CITY; i++)
84 _D("HELLO, %d, %d", city[i].ci.id, ci->id);
85 retv_if(city[i].ci.id == ci->id, EINA_FALSE);
88 path = app_get_resource_path();
89 retv_if(!path, EINA_FALSE);
91 snprintf(full_path, sizeof(full_path), "%s/edje/city.edj", path);
94 Evas_Coord x, y, w, h, x2, y2, w2, h2;
95 evas_object_geometry_get(map_layout, &x, &y, &w, &h);
96 edje_object_part_geometry_get(elm_layout_edje_get(map_layout), "map", &x2, &y2, &w, &h);
97 double scale_w = (double) w / ORIGIN_W;
98 double scale_h = (double) h / ORIGIN_H;
101 snprintf(buf, sizeof(buf), "city%d", idx);
102 city[idx].obj = elm_layout_add(map_layout);
103 elm_layout_file_set(city[idx].obj, full_path, buf);
104 // evas_object_smart_member_add(city[idx].obj, map_layout);
105 evas_object_show(city[idx].obj);
107 Evas_Object *edje = elm_layout_edje_get(city[idx].obj);
108 city[idx].w = atoi(edje_object_data_get(edje, "width"));
109 city[idx].h = atoi(edje_object_data_get(edje, "height"));
110 memcpy(&city[idx].ci, ci, sizeof(city_s));
112 evas_object_resize(city[idx].obj, city[idx].w, city[idx].h);
114 evas_object_move(city[idx].obj,
115 (int)((double)ci->x * scale_w) + x + x2 - (city[idx].w / 2),
116 (int)((double)ci->y * scale_h) + y + y2 - (city[idx].h / 2));
121 trans = elm_transit_add();
122 elm_transit_object_add(trans, city[idx].obj);
123 elm_transit_effect_zoom_add(trans, 3.0, 1.0);
124 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 255, 255, 255, 255);
125 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
126 elm_transit_duration_set(trans, 0.35);
127 elm_transit_go(trans);
130 Evas_Object *effect =
131 (Evas_Object *) edje_object_part_object_get(edje, "effect");
132 evas_object_render_op_set(effect, EVAS_RENDER_ADD);
133 trans = elm_transit_add();
134 elm_transit_object_add(trans, effect);
135 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 100, 100, 100, 100);
136 elm_transit_duration_set(trans, 1.25);
137 elm_transit_repeat_times_set(trans, -1);
138 elm_transit_auto_reverse_set(trans, EINA_TRUE);
139 elm_transit_go(trans);
145 trans_del_cb(void *data, Elm_Transit *trans)
147 int idx = (int) data;
148 evas_object_del(city[idx].obj);
149 city[idx].obj = NULL;
153 remove_city_from_map(int idx)
155 _D("HELLO, idx:%d", idx);
156 if (idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
157 if (0 > idx) return EINA_FALSE;
158 if (!city[idx].obj) return EINA_FALSE;
160 city[idx].ci.id = -1;
161 Elm_Transit *trans = elm_transit_add();
162 elm_transit_object_add(trans, city[idx].obj);
163 elm_transit_effect_zoom_add(trans, 1.0, 2.0);
164 elm_transit_effect_color_add(trans, 255, 255, 255, 255, 0, 0, 0, 0);
165 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
166 elm_transit_duration_set(trans, 0.35);
167 elm_transit_del_cb_set(trans, trans_del_cb, (void *)idx);
168 elm_transit_go(trans);
174 button_effect(Evas_Object *btn)
176 Elm_Transit *trans = elm_transit_add();
177 elm_transit_object_add(trans, btn);
178 elm_transit_effect_zoom_add(trans, 1.0, 0.9);
179 elm_transit_duration_set(trans, 0.4);
180 elm_transit_event_enabled_set(trans, EINA_TRUE);
181 elm_transit_auto_reverse_set(trans, EINA_TRUE);
182 elm_transit_repeat_times_set(trans, -1);
183 elm_transit_go(trans);
186 typedef struct part_info
193 item_geom_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
195 Evas_Object *rect1 = evas_object_data_get(obj, "part1");
196 Evas_Object *rect2 = evas_object_data_get(obj, "part2");
200 Evas_Coord x, y, w, h, x2, y2, w2, h2;
204 evas_object_geometry_get(obj, &x, &y, &w, &h);
205 edje_object_part_geometry_get(elm_layout_edje_get(obj), "result_bar", &x2, &y2, &w2, &h2);
207 pi = evas_object_data_get(rect1, "part_info");
210 xx = (double)(x + x2) + (((double)w2) * pi->p1);
211 evas_object_move(rect1, (int) xx, (y + y2));
212 evas_object_resize(rect1, (int) (((double)w2) * (pi->p2 - pi->p1)), h2);
216 pi = evas_object_data_get(rect2, "part_info");
219 xx = (double)(x + x2) + (((double)w2) * pi->p1);
220 evas_object_move(rect2, (int) xx, (y + y2));
221 evas_object_resize(rect2, (int) (((double)w2) * (pi->p2 - pi->p1)), h2);
225 item_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
227 Evas_Object *rect1 = evas_object_data_get(obj, "part1");
228 Evas_Object *rect2 = evas_object_data_get(obj, "part2");
229 part_info_s *p1 = evas_object_data_get(rect1, "p1");
230 part_info_s *p2 = evas_object_data_get(rect1, "p2");
233 evas_object_del(rect1);
234 evas_object_del(rect2);
237 void unset_time_range(Evas_Object *item)
239 Evas_Object *rect = NULL;
243 rect = evas_object_data_get(item, "part1");
245 evas_object_del(rect);
247 rect = evas_object_data_get(item, "part2");
249 evas_object_del(rect);
253 set_time_range(Evas_Object *item, int idx, double p1, double p2, double p3, double p4)
255 retv_if(!item, EINA_FALSE);
256 retv_if(idx < 0 || idx >= 6, EINA_FALSE); /* FIXME */
269 evas_object_event_callback_del(item, EVAS_CALLBACK_MOVE, item_geom_cb);
270 evas_object_event_callback_del(item, EVAS_CALLBACK_RESIZE, item_geom_cb);
271 evas_object_event_callback_del(item, EVAS_CALLBACK_DEL, item_del_cb);
272 evas_object_event_callback_add(item, EVAS_CALLBACK_MOVE, item_geom_cb, NULL);
273 evas_object_event_callback_add(item, EVAS_CALLBACK_RESIZE, item_geom_cb, NULL);
274 evas_object_event_callback_add(item, EVAS_CALLBACK_DEL, item_del_cb, NULL);
277 rect = evas_object_data_get(item, "part1");
278 evas_object_del(rect);
279 rect = evas_object_data_get(item, "part2");
280 evas_object_del(rect);
282 Evas_Coord x, y, w, h, x2, y2, w2, h2;
289 rect = evas_object_rectangle_add(evas_object_evas_get(item));
290 evas_object_smart_member_add(rect, item);
294 evas_object_color_set(rect, 239, 81, 39, 255);
297 evas_object_color_set(rect, 63, 170, 150, 255);
300 evas_object_color_set(rect, 34, 138, 255, 255);
303 evas_object_color_set(rect, 255, 47, 213, 255);
306 evas_object_color_set(rect, 248, 176, 67, 255);
309 evas_object_color_set(rect, 255, 200, 0, 255);
312 evas_object_geometry_get(item, &x, &y, &w, &h);
313 edje_object_part_geometry_get(elm_layout_edje_get(item), "result_bar", &x2, &y2, &w2, &h2);
315 xx = x + x2 + (w2 * p1);
316 evas_object_show(rect);
318 evas_object_data_set(item, "part1", rect);
320 pi = calloc(1, sizeof(part_info_s));
325 evas_object_data_set(rect, "part_info", pi);
329 if ((p3 == 0 && p4 == 0)) return EINA_TRUE;
331 rect = evas_object_rectangle_add(evas_object_evas_get(item));
332 evas_object_smart_member_add(rect, item);
337 evas_object_color_set(rect, 239, 81, 39, 255);
340 evas_object_color_set(rect, 63, 170, 150, 255);
343 evas_object_color_set(rect, 34, 138, 255, 255);
346 evas_object_color_set(rect, 255, 47, 213, 255);
349 evas_object_color_set(rect, 248, 176, 67, 255);
352 evas_object_color_set(rect, 255, 200, 0, 255);
355 evas_object_geometry_get(item, &x, &y, &w, &h);
356 edje_object_part_geometry_get(elm_layout_edje_get(item), "result_bar", &x2, &y2, &w2, &h2);
357 xx = x + x2 + (w2 * p1);
358 evas_object_show(rect);
360 evas_object_data_set(item, "part2", rect);
362 pi = calloc(1, sizeof(part_info_s));
367 evas_object_data_set(rect, "part_info", pi);
375 set_marker(Evas_Object *item, int idx)
377 if (idx < 0 || idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
378 if (!item) return EINA_FALSE;
381 char full_path[PATH_LEN] = {0, };
382 path = app_get_resource_path();
383 retv_if(!path, EINA_FALSE);
385 snprintf(full_path, sizeof(full_path), "%s/edje/item2.edj", path);
388 Evas_Object *img = elm_image_add(item);
389 retv_if(!img, EINA_FALSE);
394 elm_image_file_set(img, full_path, "my_status");
397 elm_image_file_set(img, full_path, "location_mint");
400 elm_image_file_set(img, full_path, "location_blue");
403 elm_image_file_set(img, full_path, "location_pink");
406 elm_image_file_set(img, full_path, "location_orange");
409 elm_object_part_content_set(item, "mark", img);