summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-01-27 16:46:16 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-02-01 14:21:27 -0800
commit2c22ce3aaa55201cf5f71765cfd740dda877e521 (patch)
tree21c922b27900d653741d7902b1dd02902575ed63
parent72eacc5086666d83f4f4701b73454d68f32d5385 (diff)
map: use per canvas animator.
-rw-r--r--src/lib/elm_map.c78
-rw-r--r--src/lib/elm_widget_map.h2
2 files changed, 46 insertions, 34 deletions
diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c
index 35e01a9a0..f4b976e2c 100644
--- a/src/lib/elm_map.c
+++ b/src/lib/elm_map.c
@@ -55,6 +55,7 @@
55 55
56static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 56static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
57static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params); 57static Eina_Bool _key_action_zoom(Evas_Object *obj, const char *params);
58static Eina_Bool _zoom_animator_set(Elm_Map_Data *sd, void *callback);
58 59
59static const Elm_Action key_actions[] = { 60static const Elm_Action key_actions[] = {
60 {"move", _key_action_move}, 61 {"move", _key_action_move},
@@ -1142,55 +1143,41 @@ _zoom_do(Elm_Map_Data *sd,
1142} 1143}
1143 1144
1144static Eina_Bool 1145static Eina_Bool
1145_zoom_anim_cb(void *data) 1146_zoom_anim_cb(void *data,
1147 Eo *obj EINA_UNUSED,
1148 const Eo_Event_Description *desc EINA_UNUSED,
1149 void *event_info EINA_UNUSED)
1146{ 1150{
1147 ELM_MAP_DATA_GET(data, sd); 1151 ELM_MAP_DATA_GET(data, sd);
1148 1152
1149 if (sd->ani.zoom_cnt <= 0) 1153 if (sd->ani.zoom_cnt <= 0)
1150 { 1154 {
1151 sd->zoom_animator = NULL; 1155 _zoom_animator_set(sd, NULL);
1152 evas_object_smart_changed(sd->pan_obj); 1156 evas_object_smart_changed(sd->pan_obj);
1153 _calc_job(sd); 1157 _calc_job(sd);
1154
1155 return ECORE_CALLBACK_CANCEL;
1156 } 1158 }
1157 else 1159 else
1158 { 1160 {
1159 sd->ani.zoom += sd->ani.zoom_diff; 1161 sd->ani.zoom += sd->ani.zoom_diff;
1160 sd->ani.zoom_cnt--; 1162 sd->ani.zoom_cnt--;
1161 _zoom_do(sd, sd->ani.zoom); 1163 _zoom_do(sd, sd->ani.zoom);
1162
1163 return ECORE_CALLBACK_RENEW;
1164 } 1164 }
1165} 1165 return EO_CALLBACK_CONTINUE;
1166
1167static void
1168_zoom_with_animation(Elm_Map_Data *sd,
1169 double zoom,
1170 int cnt)
1171{
1172 if (cnt == 0) return;
1173
1174 sd->ani.zoom_cnt = cnt;
1175 sd->ani.zoom = sd->zoom;
1176 sd->ani.zoom_diff = (double)(zoom - sd->zoom) / cnt;
1177 ecore_animator_del(sd->zoom_animator);
1178 sd->zoom_animator = ecore_animator_add(_zoom_anim_cb, sd->obj);
1179} 1166}
1180 1167
1181static Eina_Bool 1168static Eina_Bool
1182_zoom_bring_anim_cb(void *data) 1169_zoom_bring_anim_cb(void *data,
1170 Eo *obj EINA_UNUSED,
1171 const Eo_Event_Description *desc EINA_UNUSED,
1172 void *event_info EINA_UNUSED)
1183{ 1173{
1184 ELM_MAP_DATA_GET(data, sd); 1174 ELM_MAP_DATA_GET(data, sd);
1185 1175
1186 if ((sd->ani.zoom_cnt <= 0) && (sd->ani.region_cnt <= 0)) 1176 if ((sd->ani.zoom_cnt <= 0) && (sd->ani.region_cnt <= 0))
1187 { 1177 {
1188 sd->zoom_animator = NULL; 1178 _zoom_animator_set(sd, NULL);
1189
1190 evas_object_smart_changed(sd->pan_obj); 1179 evas_object_smart_changed(sd->pan_obj);
1191 _calc_job(sd); 1180 _calc_job(sd);
1192
1193 return ECORE_CALLBACK_CANCEL;
1194 } 1181 }
1195 else 1182 else
1196 { 1183 {
@@ -1214,9 +1201,37 @@ _zoom_bring_anim_cb(void *data)
1214 eo_do(sd->obj, elm_interface_scrollable_content_region_show(x, y, w, h)); 1201 eo_do(sd->obj, elm_interface_scrollable_content_region_show(x, y, w, h));
1215 sd->ani.region_cnt--; 1202 sd->ani.region_cnt--;
1216 } 1203 }
1217
1218 return ECORE_CALLBACK_RENEW;
1219 } 1204 }
1205
1206 return EO_CALLBACK_CONTINUE;
1207}
1208
1209static Eina_Bool
1210_zoom_animator_set(Elm_Map_Data *sd,
1211 void *callback)
1212{
1213 Eina_Bool r = EINA_FALSE;
1214
1215 sd->zoom_animator = !!callback;
1216 eo_do(evas_object_evas_get(sd->obj),
1217 r = eo_event_callback_del(EVAS_CANVAS_EVENT_ANIMATOR_TICK, _zoom_anim_cb, sd->obj);
1218 r |= eo_event_callback_del(EVAS_CANVAS_EVENT_ANIMATOR_TICK, _zoom_bring_anim_cb, sd->obj);
1219 if (callback) eo_event_callback_add(EVAS_CANVAS_EVENT_ANIMATOR_TICK, callback, sd->obj));
1220
1221 return r;
1222}
1223
1224static void
1225_zoom_with_animation(Elm_Map_Data *sd,
1226 double zoom,
1227 int cnt)
1228{
1229 if (cnt == 0) return;
1230
1231 sd->ani.zoom_cnt = cnt;
1232 sd->ani.zoom = sd->zoom;
1233 sd->ani.zoom_diff = (double)(zoom - sd->zoom) / cnt;
1234 _zoom_animator_set(sd, _zoom_anim_cb);
1220} 1235}
1221 1236
1222static void 1237static void
@@ -1244,8 +1259,7 @@ _zoom_bring_with_animation(Elm_Map_Data *sd,
1244 sd->ani.lon_diff = (lon - tlon) / region_cnt; 1259 sd->ani.lon_diff = (lon - tlon) / region_cnt;
1245 sd->ani.lat_diff = (lat - tlat) / region_cnt; 1260 sd->ani.lat_diff = (lat - tlat) / region_cnt;
1246 1261
1247 ecore_animator_del(sd->zoom_animator); 1262 _zoom_animator_set(sd, _zoom_bring_anim_cb);
1248 sd->zoom_animator = ecore_animator_add(_zoom_bring_anim_cb, sd->obj);
1249} 1263}
1250 1264
1251static void 1265static void
@@ -4157,7 +4171,7 @@ _elm_map_evas_object_smart_del(Eo *obj, Elm_Map_Data *sd)
4157 eina_stringshare_del(sd->user_agent); 4171 eina_stringshare_del(sd->user_agent);
4158 eina_hash_free(sd->ua); 4172 eina_hash_free(sd->ua);
4159 ecore_timer_del(sd->zoom_timer); 4173 ecore_timer_del(sd->zoom_timer);
4160 ecore_animator_del(sd->zoom_animator); 4174 _zoom_animator_set(sd, NULL);
4161 4175
4162 _grid_all_clear(sd); 4176 _grid_all_clear(sd);
4163 // Removal of download list should be after grid clear. 4177 // Removal of download list should be after grid clear.
@@ -4352,10 +4366,8 @@ _elm_map_paused_set(Eo *obj, Elm_Map_Data *sd, Eina_Bool paused)
4352 sd->paused = !!paused; 4366 sd->paused = !!paused;
4353 if (sd->paused) 4367 if (sd->paused)
4354 { 4368 {
4355 if (sd->zoom_animator) 4369 if (_zoom_animator_set(sd, NULL))
4356 { 4370 {
4357 ecore_animator_del(sd->zoom_animator);
4358 sd->zoom_animator = NULL;
4359 _zoom_do(sd, sd->zoom); 4371 _zoom_do(sd, sd->zoom);
4360 } 4372 }
4361 edje_object_signal_emit(wd->resize_obj, 4373 edje_object_signal_emit(wd->resize_obj,
diff --git a/src/lib/elm_widget_map.h b/src/lib/elm_widget_map.h
index 61e70d19e..9d0652c4f 100644
--- a/src/lib/elm_widget_map.h
+++ b/src/lib/elm_widget_map.h
@@ -446,7 +446,6 @@ struct _Elm_Map_Data
446 } ani; 446 } ani;
447 447
448 Ecore_Timer *zoom_timer; 448 Ecore_Timer *zoom_timer;
449 Ecore_Animator *zoom_animator;
450 Ecore_Timer *loaded_timer; 449 Ecore_Timer *loaded_timer;
451 450
452 int try_num; 451 int try_num;
@@ -482,6 +481,7 @@ struct _Elm_Map_Data
482 Eina_Bool wheel_disabled : 1; 481 Eina_Bool wheel_disabled : 1;
483 Eina_Bool on_hold : 1; 482 Eina_Bool on_hold : 1;
484 Eina_Bool paused : 1; 483 Eina_Bool paused : 1;
484 Eina_Bool zoom_animator : 1;
485 485
486 Calc_Job calc_job; 486 Calc_Job calc_job;
487}; 487};