1 #include <Elementary.h>
14 static Evas_Object *main_layout = NULL;
15 static Evas_Object *map_layout = NULL;
16 static city_data_s city[CITY_MAX] = {{{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}};
23 map_geom_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
25 Evas_Coord x, y, w, h, x2, y2, w2, h2;
26 evas_object_geometry_get(obj, &x, &y, &w, &h);
27 edje_object_part_geometry_get(elm_layout_edje_get(obj), "map", &x2, &y2, &w, &h);
28 double scale_w = (double) w / ORIGIN_W;
29 double scale_h = (double) h / ORIGIN_H;
32 for (idx = 0; CITY_MAX > idx; idx++)
34 if (!city[idx].obj) continue;
35 evas_object_move(city[idx].obj,
36 (x + city[idx].ci.x) - (city[idx].w / 2),
37 (y + city[idx].ci.y) - (city[idx].h / 2));
38 evas_object_move(city[idx].obj,
39 (int)((double)city[idx].ci.x * scale_w) + x + x2 - (city[idx].w / 2),
40 (int)((double)city[idx].ci.y * scale_h) + y + y2 - (city[idx].h / 2));
45 map_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
48 for (idx = 0; CITY_MAX > idx; idx++)
50 evas_object_del(city[idx].obj);
56 create_momentic_layout(Evas_Object *parent, const char *full_path)
59 main_layout = elm_layout_add(parent);
60 elm_layout_file_set(main_layout, full_path, "main");
61 evas_object_size_hint_weight_set(main_layout, EVAS_HINT_EXPAND,
65 map_layout = elm_layout_add(main_layout);
66 elm_layout_file_set(map_layout, full_path, "map");
67 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_RESIZE, map_geom_cb, NULL);
68 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_MOVE, map_geom_cb, NULL);
69 evas_object_event_callback_add(map_layout, EVAS_CALLBACK_DEL, map_del_cb, NULL);
70 elm_object_part_content_set(main_layout, "map", map_layout);
76 add_city_to_map(int idx, city_s *ci)
79 char full_path[PATH_LEN] = {0, };
81 if (idx >= CITY_MAX) return EINA_FALSE;
82 if (0 > idx) return EINA_FALSE;
83 if (city[idx].obj) return EINA_FALSE;
86 for (i = 0; i < CITY_MAX; i++)
88 if (city[i].ci.id == ci->id) return EINA_FALSE;
91 path = app_get_resource_path();
92 retv_if(!path, EINA_FALSE);
94 snprintf(full_path, sizeof(full_path), "%s/edje/city.edj", path);
97 Evas_Coord x, y, w, h, x2, y2, w2, h2;
98 evas_object_geometry_get(map_layout, &x, &y, &w, &h);
99 edje_object_part_geometry_get(elm_layout_edje_get(map_layout), "map", &x2, &y2, &w, &h);
100 double scale_w = (double) w / ORIGIN_W;
101 double scale_h = (double) h / ORIGIN_H;
104 snprintf(buf, sizeof(buf), "city%d", idx);
105 city[idx].obj = elm_layout_add(map_layout);
106 elm_layout_file_set(city[idx].obj, full_path, buf);
107 evas_object_smart_member_add(city[idx].obj, map_layout);
108 evas_object_show(city[idx].obj);
110 Evas_Object *edje = elm_layout_edje_get(city[idx].obj);
111 city[idx].w = atoi(edje_object_data_get(edje, "width"));
112 city[idx].h = atoi(edje_object_data_get(edje, "height"));
113 memcpy(&city[idx].ci, ci, sizeof(city_s));
115 evas_object_resize(city[idx].obj, city[idx].w, city[idx].h);
117 evas_object_move(city[idx].obj,
118 (int)((double)ci->x * scale_w) + x + x2 - (city[idx].w / 2),
119 (int)((double)ci->y * scale_h) + y + y2 - (city[idx].h / 2));
124 trans = elm_transit_add();
125 elm_transit_object_add(trans, city[idx].obj);
126 elm_transit_effect_zoom_add(trans, 3.0, 1.0);
127 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 255, 255, 255, 255);
128 elm_transit_tween_mode_set(trans, ELM_TRANSIT_TWEEN_MODE_DECELERATE);
129 elm_transit_duration_set(trans, 0.35);
130 elm_transit_go(trans);
133 Evas_Object *effect =
134 (Evas_Object *) edje_object_part_object_get(edje, "effect");
135 evas_object_render_op_set(effect, EVAS_RENDER_ADD);
136 trans = elm_transit_add();
137 elm_transit_object_add(trans, effect);
138 elm_transit_effect_color_add(trans, 0, 0, 0, 0, 100, 100, 100, 100);
139 elm_transit_duration_set(trans, 1.25);
140 elm_transit_repeat_times_set(trans, -1);
141 elm_transit_auto_reverse_set(trans, EINA_TRUE);
142 elm_transit_go(trans);
148 trans_del_cb(void *data, Elm_Transit *trans)
150 int idx = (int) data;
151 evas_object_del(city[idx].obj);
152 city[idx].obj = NULL;
156 remove_city_from_map(int idx)
158 if (idx >= CITY_MAX) return EINA_FALSE;
159 if (0 > idx) return EINA_FALSE;
160 if (!city[idx].obj) return EINA_FALSE;
162 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);