diff options
Diffstat (limited to 'src/mbgl/map')
-rw-r--r-- | src/mbgl/map/map.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/map/map_impl.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/map/map_impl.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/map/map_options.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 28 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 8 |
8 files changed, 12 insertions, 77 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 5bc7a37332..8b90aee492 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -39,7 +39,6 @@ Map::Map(RendererFrontend& rendererFrontend, size, pixelRatio, options.mapMode(), - options.constrainMode(), options.viewportMode(), options.crossSourceCollisions())) {} @@ -348,17 +347,6 @@ NorthOrientation Map::getNorthOrientation() const { return impl->transform.getNorthOrientation(); } -#pragma mark - Constrain mode - -void Map::setConstrainMode(mbgl::ConstrainMode mode) { - impl->transform.setConstrainMode(mode); - impl->onUpdate(); -} - -ConstrainMode Map::getConstrainMode() const { - return impl->transform.getConstrainMode(); -} - #pragma mark - Viewport mode void Map::setViewportMode(mbgl::ViewportMode mode) { diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp index 04200c267f..15caa34af4 100644 --- a/src/mbgl/map/map_impl.cpp +++ b/src/mbgl/map/map_impl.cpp @@ -12,16 +12,13 @@ Map::Impl::Impl(Map& map_, Size size_, float pixelRatio_, MapMode mode_, - ConstrainMode constrainMode_, ViewportMode viewportMode_, bool crossSourceCollisions_) : map(map_), observer(mapObserver), rendererFrontend(frontend), fileSource(fileSource_), - transform(observer, - constrainMode_, - viewportMode_), + transform(observer, viewportMode_), mode(mode_), pixelRatio(pixelRatio_), crossSourceCollisions(crossSourceCollisions_), diff --git a/src/mbgl/map/map_impl.hpp b/src/mbgl/map/map_impl.hpp index 598b72907a..af64d8c0f6 100644 --- a/src/mbgl/map/map_impl.hpp +++ b/src/mbgl/map/map_impl.hpp @@ -34,7 +34,6 @@ public: float pixelRatio, MapMode, - ConstrainMode, ViewportMode, bool crossSourceCollisions); diff --git a/src/mbgl/map/map_options.cpp b/src/mbgl/map/map_options.cpp index 118fcaf3df..34586f364c 100644 --- a/src/mbgl/map/map_options.cpp +++ b/src/mbgl/map/map_options.cpp @@ -8,7 +8,6 @@ namespace mbgl { class MapOptions::Impl { public: MapMode mapMode = MapMode::Continuous; - ConstrainMode constrainMode = ConstrainMode::HeightOnly; ViewportMode viewportMode = ViewportMode::Default; std::string cachePath; std::string assetRoot; @@ -28,15 +27,6 @@ MapMode MapOptions::mapMode() const { return impl_->mapMode; } -MapOptions& MapOptions::withConstrainMode(ConstrainMode mode) { - impl_->constrainMode = mode; - return *this; -} - -ConstrainMode MapOptions::constrainMode() const { - return impl_->constrainMode; -} - MapOptions& MapOptions::withViewportMode(ViewportMode mode) { impl_->viewportMode = mode; return *this; diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index e60ce7a1bd..ea8d3fa482 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -37,9 +37,8 @@ static double _normalizeAngle(double angle, double anchorAngle) } Transform::Transform(MapObserver& observer_, - ConstrainMode constrainMode, ViewportMode viewportMode) - : observer(observer_), state(constrainMode, viewportMode) { + : observer(observer_), state(viewportMode) { } #pragma mark - Map View @@ -56,7 +55,7 @@ void Transform::resize(const Size size) { observer.onCameraWillChange(MapObserver::CameraChangeMode::Immediate); state.size = size; - state.constrain(state.scale, state.x, state.y); + state.constrain(state.scale, state.y); observer.onCameraDidChange(MapObserver::CameraChangeMode::Immediate); } @@ -405,24 +404,13 @@ double Transform::getPitch() const { void Transform::setNorthOrientation(NorthOrientation orientation) { state.orientation = orientation; - state.constrain(state.scale, state.x, state.y); + state.constrain(state.scale, state.y); } NorthOrientation Transform::getNorthOrientation() const { return state.getNorthOrientation(); } -#pragma mark - Constrain mode - -void Transform::setConstrainMode(mbgl::ConstrainMode mode) { - state.constrainMode = mode; - state.constrain(state.scale, state.x, state.y); -} - -ConstrainMode Transform::getConstrainMode() const { - return state.getConstrainMode(); -} - #pragma mark - Viewport mode void Transform::setViewportMode(mbgl::ViewportMode mode) { diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index c4e10ec797..e0cc5927d2 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -19,10 +19,9 @@ namespace mbgl { class Transform : private util::noncopyable { public: Transform(MapObserver& = MapObserver::nullObserver(), - ConstrainMode = ConstrainMode::HeightOnly, ViewportMode = ViewportMode::Default); - Transform(const TransformState &state_) : observer(MapObserver::nullObserver()), state(state_) {} + Transform(TransformState state_) : observer(MapObserver::nullObserver()), state(std::move(state_)) {} // Map view void resize(Size size); @@ -76,10 +75,6 @@ public: void setNorthOrientation(NorthOrientation); NorthOrientation getNorthOrientation() const; - // Constrain mode - void setConstrainMode(ConstrainMode); - ConstrainMode getConstrainMode() const; - // Viewport mode void setViewportMode(ViewportMode); ViewportMode getViewportMode() const; diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index e911067c5b..29152c10df 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -8,9 +8,8 @@ namespace mbgl { -TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewportMode_) - : constrainMode(constrainMode_) - , viewportMode(viewportMode_) +TransformState::TransformState(ViewportMode viewportMode_) + : viewportMode(viewportMode_) { } @@ -118,12 +117,6 @@ double TransformState::getNorthOrientationAngle() const { return angleOrientation; } -#pragma mark - Constrain mode - -ConstrainMode TransformState::getConstrainMode() const { - return constrainMode; -} - #pragma mark - ViewportMode ViewportMode TransformState::getViewportMode() const { @@ -204,9 +197,8 @@ void TransformState::setMinZoom(const double minZoom) { double TransformState::getMinZoom() const { double test_scale = min_scale; - double unused_x = x; double unused_y = y; - constrain(test_scale, unused_x, unused_y); + constrain(test_scale, unused_y); return scaleZoom(test_scale); } @@ -370,11 +362,7 @@ bool TransformState::rotatedNorth() const { return (orientation == NO::Leftwards || orientation == NO::Rightwards); } -void TransformState::constrain(double& scale_, double& x_, double& y_) const { - if (constrainMode == ConstrainMode::None) { - return; - } - +void TransformState::constrain(double& scale_, double& y_) const { // Constrain scale to avoid zooming out far enough to show off-world areas on the Y axis. const double ratioY = (rotatedNorth() ? size.width : size.height) / util::tileSize; scale_ = util::max(scale_, ratioY); @@ -382,12 +370,6 @@ void TransformState::constrain(double& scale_, double& x_, double& y_) const { // Constrain min/max pan to avoid showing off-world areas on the Y axis. double max_y = (scale_ * util::tileSize - (rotatedNorth() ? size.width : size.height)) / 2; y_ = std::max(-max_y, std::min(y_, max_y)); - - if (constrainMode == ConstrainMode::WidthAndHeight) { - // Constrain min/max pan to avoid showing off-world areas on the X axis. - double max_x = (scale_ * util::tileSize - (rotatedNorth() ? size.height : size.width)) / 2; - x_ = std::max(-max_x, std::min(x_, max_x)); - } } void TransformState::moveLatLng(const LatLng& latLng, const ScreenCoordinate& anchor) { @@ -421,7 +403,7 @@ void TransformState::setLatLngZoom(const LatLng& latLng, double zoom) { void TransformState::setScalePoint(const double newScale, const ScreenCoordinate &point) { double constrainedScale = newScale; ScreenCoordinate constrainedPoint = point; - constrain(constrainedScale, constrainedPoint.x, constrainedPoint.y); + constrain(constrainedScale, constrainedPoint.y); scale = constrainedScale; x = constrainedPoint.x; diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index be7c300803..8067a8e1d8 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -23,7 +23,7 @@ class TransformState { friend class RendererState; public: - TransformState(ConstrainMode = ConstrainMode::HeightOnly, ViewportMode = ViewportMode::Default); + TransformState(ViewportMode = ViewportMode::Default); // Matrix void matrixFor(mat4&, const UnwrappedTileID&) const; @@ -36,9 +36,6 @@ public: NorthOrientation getNorthOrientation() const; double getNorthOrientationAngle() const; - // Constrain mode - ConstrainMode getConstrainMode() const; - // Viewport mode ViewportMode getViewportMode() const; @@ -95,7 +92,7 @@ public: private: bool rotatedNorth() const; - void constrain(double& scale, double& x, double& y) const; + void constrain(double& scale, double& y) const; optional<LatLngBounds> bounds; @@ -120,7 +117,6 @@ private: void setScalePoint(const double scale, const ScreenCoordinate& point); private: - ConstrainMode constrainMode; ViewportMode viewportMode; // animation state |