summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbluezery <ohpowel@gmail.com>2014-05-28 17:08:00 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-05-28 17:08:01 +0900
commit84c2351bc339eca22acb79c86acbee7a1322f8c0 (patch)
treebd08a590d339320615c00afa92ee62f076995553
parent16da42a144686d1b35e8b5317f12dc675426e7ed (diff)
elm_map: Add new elm_map_region_zoom_bring_in() API
Summary: By using this API, we can do region show & bring in concurrently. This needs some tuning more because some main layouting logic in map needs to be modified to support more smooth animation. I will spare my time to do that later. @feature Reviewers: Hermet, raster, stefan_schmidt Reviewed By: raster CC: Jaehyun Differential Revision: https://phab.enlightenment.org/D887
-rw-r--r--src/bin/test_map.c7
-rw-r--r--src/lib/elm_map.c88
-rw-r--r--src/lib/elm_map.eo20
-rw-r--r--src/lib/elm_widget_map.h7
4 files changed, 115 insertions, 7 deletions
diff --git a/src/bin/test_map.c b/src/bin/test_map.c
index 07da09a3e..108eb7a7f 100644
--- a/src/bin/test_map.c
+++ b/src/bin/test_map.c
@@ -488,6 +488,12 @@ _bring_seoul(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
488} 488}
489 489
490static void 490static void
491_bring_zoom_suwon(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
492{
493 elm_map_region_zoom_bring_in(data, 16, 126.977969, 37.566535);
494}
495
496static void
491_paused_set(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 497_paused_set(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
492{ 498{
493 elm_map_paused_set(data, EINA_TRUE); 499 elm_map_paused_set(data, EINA_TRUE);
@@ -770,6 +776,7 @@ _submenu_move_add(void *data, Elm_Object_Item *parent)
770 if ((!data) || (!parent)) return; 776 if ((!data) || (!parent)) return;
771 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", _show_urmatt, data); 777 elm_menu_item_add(menu, parent, NULL, "Show Urmatt", _show_urmatt, data);
772 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", _bring_seoul, data); 778 elm_menu_item_add(menu, parent, NULL, "Bring Seoul", _bring_seoul, data);
779 elm_menu_item_add(menu, parent, NULL, "Zoom & Bring Suwon", _bring_zoom_suwon, data);
773 780
774} 781}
775 782
diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c
index 393ba8d89..d66087409 100644
--- a/src/lib/elm_map.c
+++ b/src/lib/elm_map.c
@@ -26,6 +26,8 @@
26#define DEFAULT_TILE_SIZE 256 26#define DEFAULT_TILE_SIZE 256
27#define MARER_MAX_NUMBER 30 27#define MARER_MAX_NUMBER 30
28#define OVERLAY_GROUPING_SCALE 2 28#define OVERLAY_GROUPING_SCALE 2
29#define ZOOM_ANIM_CNT 75
30#define ZOOM_BRING_CNT 80
29 31
30#define CACHE_ROOT "/elm_map" 32#define CACHE_ROOT "/elm_map"
31#define CACHE_TILE_ROOT CACHE_ROOT "/%d/%d/%d" 33#define CACHE_TILE_ROOT CACHE_ROOT "/%d/%d/%d"
@@ -1135,7 +1137,7 @@ _zoom_anim_cb(void *data)
1135{ 1137{
1136 ELM_MAP_DATA_GET(data, sd); 1138 ELM_MAP_DATA_GET(data, sd);
1137 1139
1138 if (sd->ani.cnt <= 0) 1140 if (sd->ani.zoom_cnt <= 0)
1139 { 1141 {
1140 sd->zoom_animator = NULL; 1142 sd->zoom_animator = NULL;
1141 evas_object_smart_changed(sd->pan_obj); 1143 evas_object_smart_changed(sd->pan_obj);
@@ -1145,8 +1147,8 @@ _zoom_anim_cb(void *data)
1145 } 1147 }
1146 else 1148 else
1147 { 1149 {
1148 sd->ani.zoom += sd->ani.diff; 1150 sd->ani.zoom += sd->ani.zoom_diff;
1149 sd->ani.cnt--; 1151 sd->ani.zoom_cnt--;
1150 _zoom_do(sd, sd->ani.zoom); 1152 _zoom_do(sd, sd->ani.zoom);
1151 1153
1152 return ECORE_CALLBACK_RENEW; 1154 return ECORE_CALLBACK_RENEW;
@@ -1160,13 +1162,83 @@ _zoom_with_animation(Elm_Map_Data *sd,
1160{ 1162{
1161 if (cnt == 0) return; 1163 if (cnt == 0) return;
1162 1164
1163 sd->ani.cnt = cnt; 1165 sd->ani.zoom_cnt = cnt;
1164 sd->ani.zoom = sd->zoom; 1166 sd->ani.zoom = sd->zoom;
1165 sd->ani.diff = (double)(zoom - sd->zoom) / cnt; 1167 sd->ani.zoom_diff = (double)(zoom - sd->zoom) / cnt;
1166 ecore_animator_del(sd->zoom_animator); 1168 ecore_animator_del(sd->zoom_animator);
1167 sd->zoom_animator = ecore_animator_add(_zoom_anim_cb, sd->obj); 1169 sd->zoom_animator = ecore_animator_add(_zoom_anim_cb, sd->obj);
1168} 1170}
1169 1171
1172static Eina_Bool
1173_zoom_bring_anim_cb(void *data)
1174{
1175 ELM_MAP_DATA_GET(data, sd);
1176
1177 if ((sd->ani.zoom_cnt <= 0) && (sd->ani.region_cnt <= 0))
1178 {
1179 sd->zoom_animator = NULL;
1180
1181 evas_object_smart_changed(sd->pan_obj);
1182 _calc_job(sd);
1183
1184 return ECORE_CALLBACK_CANCEL;
1185 }
1186 else
1187 {
1188 Evas_Coord x, y, w, h;
1189 if (sd->ani.zoom_cnt > 0)
1190 {
1191 sd->ani.zoom += sd->ani.zoom_diff;
1192 _zoom_do(sd, sd->ani.zoom);
1193 sd->ani.zoom_cnt--;
1194 }
1195 if (sd->ani.region_cnt > 0)
1196 {
1197 sd->ani.lon += sd->ani.lon_diff;
1198 sd->ani.lat += sd->ani.lat_diff;
1199
1200 _region_to_coord_convert
1201 (sd, sd->ani.lon, sd->ani.lat, sd->size.w, &x, &y);
1202 _viewport_coord_get(sd, NULL, NULL, &w, &h);
1203 x = x - (w / 2);
1204 y = y - (h / 2);
1205 eo_do(sd->obj, elm_interface_scrollable_content_region_show(x, y, w, h));
1206 sd->ani.region_cnt--;
1207 }
1208
1209 return ECORE_CALLBACK_RENEW;
1210 }
1211}
1212
1213static void
1214_zoom_bring_with_animation(Elm_Map_Data *sd,
1215 double zoom,
1216 double lon,
1217 double lat,
1218 int zoom_cnt,
1219 int region_cnt)
1220{
1221 double tlon, tlat;
1222 Evas_Coord vx, vy, vw, vh;
1223 if ((zoom_cnt == 0) && (region_cnt == 0)) return;
1224
1225 sd->ani.zoom_cnt = zoom_cnt;
1226 sd->ani.zoom = sd->zoom;
1227 sd->ani.zoom_diff = (double)(zoom - sd->zoom) / zoom_cnt;
1228
1229 sd->ani.region_cnt = region_cnt;
1230 _viewport_coord_get(sd, &vx, &vy, &vw, &vh);
1231 _coord_to_region_convert
1232 (sd, vx + vw / 2, vy + vh / 2, sd->size.w, &tlon, &tlat);
1233 sd->ani.lon = tlon;
1234 sd->ani.lat = tlat;
1235 sd->ani.lon_diff = (lon - tlon) / region_cnt;
1236 sd->ani.lat_diff = (lat - tlat) / region_cnt;
1237
1238 ecore_animator_del(sd->zoom_animator);
1239 sd->zoom_animator = ecore_animator_add(_zoom_bring_anim_cb, sd->obj);
1240}
1241
1170static void 1242static void
1171_sizing_eval(Evas_Object *obj) 1243_sizing_eval(Evas_Object *obj)
1172{ 1244{
@@ -4223,6 +4295,12 @@ _elm_map_region_show(Eo *obj EINA_UNUSED, Elm_Map_Data *sd, double lon, double l
4223} 4295}
4224 4296
4225EOLIAN static void 4297EOLIAN static void
4298_elm_map_region_zoom_bring_in(Eo *obj EINA_UNUSED, Elm_Map_Data *sd, int zoom, double lon, double lat)
4299{
4300 _zoom_bring_with_animation(sd, zoom, lon, lat, ZOOM_ANIM_CNT, ZOOM_BRING_CNT);
4301}
4302
4303EOLIAN static void
4226_elm_map_region_get(Eo *obj EINA_UNUSED, Elm_Map_Data *sd, double *lon, double *lat) 4304_elm_map_region_get(Eo *obj EINA_UNUSED, Elm_Map_Data *sd, double *lon, double *lat)
4227{ 4305{
4228 double tlon, tlat; 4306 double tlon, tlat;
diff --git a/src/lib/elm_map.eo b/src/lib/elm_map.eo
index ca7810bcf..847a2518c 100644
--- a/src/lib/elm_map.eo
+++ b/src/lib/elm_map.eo
@@ -632,6 +632,26 @@ class Elm_Map (Elm_Widget, Elm_Interface_Scrollable)
632 @in double lat; /*@ Latitude to center at. */ 632 @in double lat; /*@ Latitude to center at. */
633 } 633 }
634 } 634 }
635 region_zoom_bring_in {
636 /*@
637 Animatedly set the zoom level of the map and bring in given coordinates
638 to the center of the map.
639
640 This causes map to zoom into specific zoom level and also move to the
641 given @p lat and @p lon coordinates and show it (by scrolling) in the
642 center of the viewport concurrently.
643
644 @see elm_map_region_bring_in()
645 @see elm_map_zoom_set()
646
647 @ingroup Map */
648
649 params {
650 @in int zoom; /*@ The zoom level to set. */
651 @in double lon; /*@ Longitude to center at. */
652 @in double lat; /*@ Latitude to center at. */
653 }
654 }
635 track_remove { 655 track_remove {
636 /*@ 656 /*@
637 Remove a track from the map 657 Remove a track from the map
diff --git a/src/lib/elm_widget_map.h b/src/lib/elm_widget_map.h
index 1e2f0548e..46e59358c 100644
--- a/src/lib/elm_widget_map.h
+++ b/src/lib/elm_widget_map.h
@@ -432,8 +432,11 @@ struct _Elm_Map_Data
432 struct 432 struct
433 { 433 {
434 double zoom; 434 double zoom;
435 double diff; 435 double zoom_diff;
436 int cnt; 436 double lon, lat;
437 double lon_diff, lat_diff;
438 int zoom_cnt;
439 int region_cnt;
437 } ani; 440 } ani;
438 441
439 Ecore_Timer *zoom_timer; 442 Ecore_Timer *zoom_timer;