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 edje_object_part_geometry_get(elm_layout_edje_get(obj), "map", &x2, &y2, &w, &h);
29 double scale_w = (double) w / ORIGIN_W;
30 double scale_h = (double) h / ORIGIN_H;
33 for (idx = 0; MAXIMUM_SELECTED_CITY > idx; idx++)
35 if (!city[idx].obj) continue;
36 evas_object_move(city[idx].obj,
37 (x + city[idx].ci.x) - (city[idx].w / 2),
38 (y + city[idx].ci.y) - (city[idx].h / 2));
39 evas_object_move(city[idx].obj,
40 (int)((double)city[idx].ci.x * scale_w) + x + x2 - (city[idx].w / 2),
41 (int)((double)city[idx].ci.y * scale_h) + y + y2 - (city[idx].h / 2));
46 map_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
49 for (idx = 0; MAXIMUM_SELECTED_CITY > idx; idx++)
51 evas_object_del(city[idx].obj);
57 create_momentic_layout(Evas_Object *parent, const char *full_path)
60 main_layout = elm_layout_add(parent);
61 elm_layout_file_set(main_layout, full_path, "main");
62 evas_object_size_hint_weight_set(main_layout, EVAS_HINT_EXPAND,
66 map_layout = elm_layout_add(main_layout);
67 elm_layout_file_set(map_layout, full_path, "map");
68 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_RESIZE, map_geom_cb, NULL);
69 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_MOVE, map_geom_cb, NULL);
70 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_DEL, map_del_cb, NULL);
71 elm_object_part_content_set(main_layout, "map", map_layout);
77 add_city_to_map(int idx, city_s *ci)
80 char full_path[PATH_LEN] = {0, };
82 if (idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
83 if (0 > idx) return EINA_FALSE;
84 if (city[idx].obj) return EINA_FALSE;
87 for (i = 0; i < MAXIMUM_SELECTED_CITY; i++)
89 if (city[i].ci.id == ci->id) return EINA_FALSE;
92 path = app_get_resource_path();
93 retv_if(!path, EINA_FALSE);
95 snprintf(full_path, sizeof(full_path), "%s/edje/city.edj", path);
98 Evas_Coord x, y, w, h, x2, y2, w2, h2;
99 evas_object_geometry_get(map_layout, &x, &y, &w, &h);
100 edje_object_part_geometry_get(elm_layout_edje_get(map_layout), "map", &x2, &y2, &w, &h);
101 double scale_w = (double) w / ORIGIN_W;
102 double scale_h = (double) h / ORIGIN_H;
105 snprintf(buf, sizeof(buf), "city%d", idx);
106 city[idx].obj = elm_layout_add(map_layout);
107 elm_layout_file_set(city[idx].obj, full_path, buf);
108 evas_object_smart_member_add(city[idx].obj, map_layout);
109 evas_object_show(city[idx].obj);
111 Evas_Object *edje = elm_layout_edje_get(city[idx].obj);
112 city[idx].w = atoi(edje_object_data_get(edje, "width"));
113 city[idx].h = atoi(edje_object_data_get(edje, "height"));
114 memcpy(&city[idx].ci, ci, sizeof(city_s));
116 evas_object_resize(city[idx].obj, city[idx].w, city[idx].h);
118 evas_object_move(city[idx].obj,
119 (int)((double)ci->x * scale_w) + x + x2 - (city[idx].w / 2),
120 (int)((double)ci->y * scale_h) + y + y2 - (city[idx].h / 2));
125 trans = elm_transit_add();
126 elm_transit_object_add(trans, city[idx].obj);
127 elm_transit_effect_zoom_add(trans, 3.0, 1.0);
128 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 255, 255, 255, 255);
129 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
130 elm_transit_duration_set(trans, 0.35);
131 elm_transit_go(trans);
134 Evas_Object *effect =
135 (Evas_Object *) edje_object_part_object_get(edje, "effect");
136 evas_object_render_op_set(effect, EVAS_RENDER_ADD);
137 trans = elm_transit_add();
138 elm_transit_object_add(trans, effect);
139 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 100, 100, 100, 100);
140 elm_transit_duration_set(trans, 1.25);
141 elm_transit_repeat_times_set(trans, -1);
142 elm_transit_auto_reverse_set(trans, EINA_TRUE);
143 elm_transit_go(trans);
149 trans_del_cb(void *data, Elm_Transit *trans)
151 int idx = (int) data;
152 evas_object_del(city[idx].obj);
153 city[idx].obj = NULL;
157 remove_city_from_map(int idx)
159 if (idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
160 if (0 > idx) return EINA_FALSE;
161 if (!city[idx].obj) return EINA_FALSE;
163 city[idx].ci.id = -1;
164 Elm_Transit *trans = elm_transit_add();
165 elm_transit_object_add(trans, city[idx].obj);
166 elm_transit_effect_zoom_add(trans, 1.0, 2.0);
167 elm_transit_effect_color_add(trans, 255, 255, 255, 255, 0, 0, 0, 0);
168 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
169 elm_transit_duration_set(trans, 0.35);
170 elm_transit_del_cb_set(trans, trans_del_cb, (void *)idx);
171 elm_transit_go(trans);
177 button_effect(Evas_Object *btn)
179 Elm_Transit *trans = elm_transit_add();
180 elm_transit_object_add(trans, btn);
181 elm_transit_effect_zoom_add(trans, 1.0, 0.9);
182 elm_transit_duration_set(trans, 0.4);
183 elm_transit_event_enabled_set(trans, EINA_TRUE);
184 elm_transit_auto_reverse_set(trans, EINA_TRUE);
185 elm_transit_repeat_times_set(trans, -1);
186 elm_transit_go(trans);
189 typedef struct part_info
196 item_geom_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
198 Evas_Object *rect1 = evas_object_data_get(obj, "part1");
199 Evas_Object *rect2 = evas_object_data_get(obj, "part2");
203 Evas_Coord x, y, w, h, x2, y2, w2, h2;
207 evas_object_geometry_get(obj, &x, &y, &w, &h);
208 edje_object_part_geometry_get(elm_layout_edje_get(obj), "graph", &x2, &y2, &w2, &h2);
210 pi = evas_object_data_get(rect1, "part_info");
213 xx = (double)(x + x2) + (((double)w2) * pi->p1);
214 evas_object_move(rect1, (int) xx, (y + y2));
215 evas_object_resize(rect1, (int) (((double)w2) * (pi->p2 - pi->p1)), h2);
219 pi = evas_object_data_get(rect2, "part_info");
222 xx = (double)(x + x2) + (((double)w2) * pi->p1);
223 evas_object_move(rect2, (int) xx, (y + y2));
224 evas_object_resize(rect2, (int) (((double)w2) * (pi->p2 - pi->p1)), h2);
228 item_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
230 Evas_Object *rect1 = evas_object_data_get(obj, "part1");
231 Evas_Object *rect2 = evas_object_data_get(obj, "part2");
232 part_info_s *p1 = evas_object_data_get(rect1, "p1");
233 part_info_s *p2 = evas_object_data_get(rect1, "p2");
236 evas_object_del(rect1);
237 evas_object_del(rect2);
241 set_time_range(Evas_Object *item, int idx, double p1, double p2, double p3, double p4)
243 if (!item) return EINA_FALSE;
244 if (idx < 0 || idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
257 evas_object_event_callback_del(item, EVAS_CALLBACK_MOVE, item_geom_cb);
258 evas_object_event_callback_del(item, EVAS_CALLBACK_RESIZE, item_geom_cb);
259 evas_object_event_callback_del(item, EVAS_CALLBACK_DEL, item_del_cb);
260 evas_object_event_callback_add(item, EVAS_CALLBACK_MOVE, item_geom_cb, NULL);
261 evas_object_event_callback_add(item, EVAS_CALLBACK_RESIZE, item_geom_cb, NULL);
262 evas_object_event_callback_add(item, EVAS_CALLBACK_DEL, item_del_cb, NULL);
265 rect = evas_object_data_get(item, "part1");
266 evas_object_del(rect);
267 rect = evas_object_data_get(item, "part2");
268 evas_object_del(rect);
270 Evas_Coord x, y, w, h, x2, y2, w2, h2;
277 rect = evas_object_rectangle_add(evas_object_evas_get(item));
281 evas_object_color_set(rect, 239, 81, 39, 255);
284 evas_object_color_set(rect, 63, 170, 150, 255);
287 evas_object_color_set(rect, 34, 138, 255, 255);
290 evas_object_color_set(rect, 255, 47, 213, 255);
293 evas_object_color_set(rect, 248, 176, 67, 255);
296 evas_object_color_set(rect, 255, 200, 0, 255);
299 evas_object_geometry_get(item, &x, &y, &w, &h);
300 edje_object_part_geometry_get(elm_layout_edje_get(item), "graph", &x2, &y2, &w2, &h2);
302 xx = x + x2 + (w2 * p1);
303 evas_object_show(rect);
305 evas_object_data_set(item, "part1", rect);
307 pi = calloc(1, sizeof(part_info_s));
312 evas_object_data_set(rect, "part_info", pi);
316 if ((p3 == 0 && p4 == 0)) return EINA_TRUE;
318 rect = evas_object_rectangle_add(evas_object_evas_get(item));
322 evas_object_color_set(rect, 239, 81, 39, 255);
325 evas_object_color_set(rect, 63, 170, 150, 255);
328 evas_object_color_set(rect, 34, 138, 255, 255);
331 evas_object_color_set(rect, 255, 47, 213, 255);
334 evas_object_color_set(rect, 248, 176, 67, 255);
337 evas_object_color_set(rect, 255, 200, 0, 255);
340 evas_object_geometry_get(item, &x, &y, &w, &h);
341 edje_object_part_geometry_get(elm_layout_edje_get(item), "graph", &x2, &y2, &w2, &h2);
342 xx = x + x2 + (w2 * p1);
343 evas_object_show(rect);
345 evas_object_data_set(item, "part2", rect);
347 pi = calloc(1, sizeof(part_info_s));
352 evas_object_data_set(rect, "part_info", pi);
360 set_marker(Evas_Object *item, int idx)
362 if (idx < 0 || idx >= MAXIMUM_SELECTED_CITY) return EINA_FALSE;
363 if (!item) return EINA_FALSE;
366 char full_path[PATH_LEN] = {0, };
367 path = app_get_resource_path();
368 retv_if(!path, EINA_FALSE);
370 snprintf(full_path, sizeof(full_path), "%s/edje/item2.edj", path);
373 Evas_Object *img = elm_image_add(item);
374 retv_if(!img, EINA_FALSE);
379 elm_image_file_set(img, full_path, "my_status");
382 elm_image_file_set(img, full_path, "location_mint");
385 elm_image_file_set(img, full_path, "location_blue");
388 elm_image_file_set(img, full_path, "location_pink");
391 elm_image_file_set(img, full_path, "location_orange");
394 elm_object_part_content_set(item, "mark", img);