diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 3939ab1881b..c6eaac84b3a 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -95,15 +95,15 @@ class Map : private util::noncopyable { void resetPosition(optional = {}); // Scale - void scaleBy(double ds, optional = {}, const Duration& = Duration::zero()); - void setScale(double scale, optional = {}, const Duration& = Duration::zero()); + void scaleBy(double ds, optional = {}, const AnimationOptions& = {}); + void setScale(double scale, optional = {}, const AnimationOptions& = {}); double getScale() const; - void setZoom(double zoom, const Duration& = Duration::zero()); - void setZoom(double zoom, optional, const Duration& = Duration::zero()); - void setZoom(double zoom, optional, const Duration& = Duration::zero()); + void setZoom(double zoom, const AnimationOptions& = {}); + void setZoom(double zoom, optional, const AnimationOptions& = {}); + void setZoom(double zoom, optional, const AnimationOptions& = {}); double getZoom() const; - void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); - void setLatLngZoom(const LatLng&, double zoom, optional, const Duration& = Duration::zero()); + void setLatLngZoom(const LatLng&, double zoom, const AnimationOptions& = {}); + void setLatLngZoom(const LatLng&, double zoom, optional, const AnimationOptions& = {}); CameraOptions cameraForLatLngBounds(const LatLngBounds&, optional) const; CameraOptions cameraForLatLngs(const std::vector&, optional) const; void resetZoom(); diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp index 3f5f48561be..c9b3227bbae 100755 --- a/platform/android/src/jni.cpp +++ b/platform/android/src/jni.cpp @@ -558,7 +558,9 @@ void nativeScaleBy(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoub assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); mbgl::ScreenCoordinate center(cx, cy); - nativeMapView->getMap().scaleBy(ds, center, mbgl::Milliseconds(duration)); + mbgl::AnimationOptions animationOptions; + animationOptions.duration.emplace(mbgl::Milliseconds(duration)); + nativeMapView->getMap().scaleBy(ds, center, animationOptions); } void nativeSetScale(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble scale, @@ -566,7 +568,9 @@ void nativeSetScale(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdou assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); mbgl::ScreenCoordinate center(cx, cy); - nativeMapView->getMap().setScale(scale, center, mbgl::Milliseconds(duration)); + mbgl::AnimationOptions animationOptions; + animationOptions.duration.emplace(mbgl::Milliseconds(duration)); + nativeMapView->getMap().setScale(scale, center, animationOptions); } jdouble nativeGetScale(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) { @@ -578,7 +582,9 @@ jdouble nativeGetScale(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) { void nativeSetZoom(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble zoom, jlong duration) { assert(nativeMapViewPtr != 0); NativeMapView *nativeMapView = reinterpret_cast(nativeMapViewPtr); - nativeMapView->getMap().setZoom(zoom, mbgl::Milliseconds(duration)); + mbgl::AnimationOptions animationOptions; + animationOptions.duration.emplace(mbgl::Milliseconds(duration)); + nativeMapView->getMap().setZoom(zoom, animationOptions); } jdouble nativeGetZoom(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) { diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 247cc50b591..f5b8e035acc 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -520,15 +520,15 @@ void Map::resetPosition(optional padding) { #pragma mark - Scale -void Map::scaleBy(double ds, optional anchor, const Duration& duration) { +void Map::scaleBy(double ds, optional anchor, const AnimationOptions& animation) { impl->cameraMutated = true; - impl->transform.scaleBy(ds, anchor, duration); + impl->transform.scaleBy(ds, anchor, animation); impl->onUpdate(Update::RecalculateStyle); } -void Map::setScale(double scale, optional anchor, const Duration& duration) { +void Map::setScale(double scale, optional anchor, const AnimationOptions& animation) { impl->cameraMutated = true; - impl->transform.setScale(scale, anchor, duration); + impl->transform.setScale(scale, anchor, animation); impl->onUpdate(Update::RecalculateStyle); } @@ -536,20 +536,20 @@ double Map::getScale() const { return impl->transform.getScale(); } -void Map::setZoom(double zoom, const Duration& duration) { +void Map::setZoom(double zoom, const AnimationOptions& animation) { impl->cameraMutated = true; - setZoom(zoom, optional {}, duration); + setZoom(zoom, optional {}, animation); } -void Map::setZoom(double zoom, optional anchor, const Duration& duration) { +void Map::setZoom(double zoom, optional anchor, const AnimationOptions& animation) { impl->cameraMutated = true; - impl->transform.setZoom(zoom, anchor, duration); + impl->transform.setZoom(zoom, anchor, animation); impl->onUpdate(Update::RecalculateStyle); } -void Map::setZoom(double zoom, optional padding, const Duration& duration) { +void Map::setZoom(double zoom, optional padding, const AnimationOptions& animation) { impl->cameraMutated = true; - impl->transform.setZoom(zoom, padding, duration); + impl->transform.setZoom(zoom, padding, animation); impl->onUpdate(Update::RecalculateStyle); } @@ -557,14 +557,14 @@ double Map::getZoom() const { return impl->transform.getZoom(); } -void Map::setLatLngZoom(const LatLng& latLng, double zoom, const Duration& duration) { +void Map::setLatLngZoom(const LatLng& latLng, double zoom, const AnimationOptions& animation) { impl->cameraMutated = true; - setLatLngZoom(latLng, zoom, {}, duration); + setLatLngZoom(latLng, zoom, {}, animation); } -void Map::setLatLngZoom(const LatLng& latLng, double zoom, optional padding, const Duration& duration) { +void Map::setLatLngZoom(const LatLng& latLng, double zoom, optional padding, const AnimationOptions& animation) { impl->cameraMutated = true; - impl->transform.setLatLngZoom(latLng, zoom, padding, duration); + impl->transform.setLatLngZoom(latLng, zoom, padding, animation); impl->onUpdate(Update::RecalculateStyle); } diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index ba6111c32d6..70fe7eb4f5e 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -361,18 +361,18 @@ void Transform::setLatLng(const LatLng& latLng, optional ancho easeTo(camera, duration); } -void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const Duration& duration) { - setLatLngZoom(latLng, zoom, EdgeInsets {}, duration); +void Transform::setLatLngZoom(const LatLng& latLng, double zoom, const AnimationOptions& animation) { + setLatLngZoom(latLng, zoom, EdgeInsets {}, animation); } -void Transform::setLatLngZoom(const LatLng& latLng, double zoom, optional padding, const Duration& duration) { +void Transform::setLatLngZoom(const LatLng& latLng, double zoom, optional padding, const AnimationOptions& animation) { if (!latLng || std::isnan(zoom)) return; CameraOptions camera; camera.center = latLng; camera.padding = padding; camera.zoom = zoom; - easeTo(camera, duration); + easeTo(camera, animation); } LatLng Transform::getLatLng(optional padding) const { @@ -394,26 +394,26 @@ ScreenCoordinate Transform::getScreenCoordinate(optional padding) co #pragma mark - Zoom -void Transform::scaleBy(double ds, const Duration& duration) { - scaleBy(ds, optional {}, duration); +void Transform::scaleBy(double ds, const AnimationOptions& animation) { + scaleBy(ds, optional {}, animation); } -void Transform::scaleBy(double ds, optional anchor, const Duration& duration) { +void Transform::scaleBy(double ds, optional anchor, const AnimationOptions& animation) { if (std::isnan(ds)) return; double scale = util::clamp(state.scale * ds, state.min_scale, state.max_scale); - setScale(scale, anchor, duration); + setScale(scale, anchor, animation); } -void Transform::setZoom(double zoom, const Duration& duration) { - setZoom(zoom, optional {}, duration); +void Transform::setZoom(double zoom, const AnimationOptions& animation) { + setZoom(zoom, optional {}, animation); } -void Transform::setZoom(double zoom, optional anchor, const Duration& duration) { - setScale(state.zoomScale(zoom), anchor, duration); +void Transform::setZoom(double zoom, optional anchor, const AnimationOptions& animation) { + setScale(state.zoomScale(zoom), anchor, animation); } -void Transform::setZoom(double zoom, optional padding, const Duration& duration) { - setScale(state.zoomScale(zoom), padding, duration); +void Transform::setZoom(double zoom, optional padding, const AnimationOptions& animation) { + setScale(state.zoomScale(zoom), padding, animation); } double Transform::getZoom() const { @@ -424,22 +424,22 @@ double Transform::getScale() const { return state.scale; } -void Transform::setScale(double scale, const Duration& duration) { - setScale(scale, optional {}, duration); +void Transform::setScale(double scale, const AnimationOptions& animation) { + setScale(scale, optional {}, animation); } -void Transform::setScale(double scale, optional anchor, const Duration& duration) { +void Transform::setScale(double scale, optional anchor, const AnimationOptions& animation) { if (std::isnan(scale)) return; CameraOptions camera; camera.zoom = state.scaleZoom(scale); camera.anchor = anchor; - easeTo(camera, duration); + easeTo(camera, animation); } -void Transform::setScale(double scale, optional padding, const Duration& duration) { +void Transform::setScale(double scale, optional padding, const AnimationOptions& animation) { optional anchor; if (padding) anchor = getScreenCoordinate(padding); - setScale(scale, anchor, duration); + setScale(scale, anchor, animation); } void Transform::setMinZoom(const double minZoom) { diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index cbe1ad7b95d..b13e10a7d7e 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -48,8 +48,8 @@ class Transform : private util::noncopyable { void setLatLng(const LatLng&, const Duration& = Duration::zero()); void setLatLng(const LatLng&, optional, const Duration& = Duration::zero()); void setLatLng(const LatLng&, optional, const Duration& = Duration::zero()); - void setLatLngZoom(const LatLng&, double zoom, const Duration& = Duration::zero()); - void setLatLngZoom(const LatLng&, double zoom, optional, const Duration& = Duration::zero()); + void setLatLngZoom(const LatLng&, double zoom, const AnimationOptions& = {}); + void setLatLngZoom(const LatLng&, double zoom, optional, const AnimationOptions& = {}); LatLng getLatLng(optional = {}) const; ScreenCoordinate getScreenCoordinate(optional = {}) const; @@ -57,36 +57,36 @@ class Transform : private util::noncopyable { /** Scales the map, keeping the given point fixed within the view. @param ds The difference in scale factors to scale the map by. */ - void scaleBy(double ds, const Duration& = Duration::zero()); + void scaleBy(double ds, const AnimationOptions& = {}); /** Scales the map, keeping the given point fixed within the view. @param ds The difference in scale factors to scale the map by. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void scaleBy(double ds, optional anchor, const Duration& = Duration::zero()); + void scaleBy(double ds, optional anchor, const AnimationOptions& = {}); /** Sets the scale factor, keeping the given point fixed within the view. @param scale The new scale factor. */ - void setScale(double scale, const Duration& = Duration::zero()); + void setScale(double scale, const AnimationOptions& = {}); /** Sets the scale factor, keeping the given point fixed within the view. @param scale The new scale factor. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void setScale(double scale, optional anchor, const Duration& = Duration::zero()); + void setScale(double scale, optional anchor, const AnimationOptions& = {}); /** Sets the scale factor, keeping the center point fixed within the inset view. @param scale The new scale factor. @param padding The viewport padding that affects the fixed center point. */ - void setScale(double scale, optional padding, const Duration& = Duration::zero()); + void setScale(double scale, optional padding, const AnimationOptions& = {}); /** Sets the zoom level, keeping the given point fixed within the view. @param zoom The new zoom level. */ - void setZoom(double zoom, const Duration& = Duration::zero()); + void setZoom(double zoom, const AnimationOptions& = {}); /** Sets the zoom level, keeping the given point fixed within the view. @param zoom The new zoom level. @param anchor A point relative to the top-left corner of the view. If unspecified, the center point is fixed within the view. */ - void setZoom(double zoom, optional anchor, const Duration& = Duration::zero()); + void setZoom(double zoom, optional anchor, const AnimationOptions& = {}); /** Sets the zoom level, keeping the center point fixed within the inset view. @param zoom The new zoom level. @param padding The viewport padding that affects the fixed center point. */ - void setZoom(double zoom, optional padding, const Duration& = Duration::zero()); + void setZoom(double zoom, optional padding, const AnimationOptions& = {}); /** Returns the zoom level. */ double getZoom() const; /** Returns the scale factor. */