diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-26 00:00:37 +0200 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-28 16:41:15 +0200 |
commit | 1cc1d4ea08ae02c3cc9b4dd1474845456c17d1bc (patch) | |
tree | d7de92e01ef1b1bf654ff8784534e534608a352f /src | |
parent | 11afef7825d622a237fa026e45e6d61b4de94068 (diff) | |
download | qtlocation-mapboxgl-1cc1d4ea08ae02c3cc9b4dd1474845456c17d1bc.tar.gz |
[core] Add setter/getter for size property in MapOptions
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/map/map_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/map/map_impl.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/map/map_options.cpp | 10 |
4 files changed, 16 insertions, 19 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 06c637b232..cfec9952b5 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -29,12 +29,11 @@ using namespace style; Map::Map(RendererFrontend& frontend, MapObserver& observer, - const Size size, const float pixelRatio, Scheduler& scheduler, const MapOptions& mapOptions, const ResourceOptions& resourceOptions) - : impl(std::make_unique<Impl>(frontend, observer, scheduler, size, pixelRatio, + : impl(std::make_unique<Impl>(frontend, observer, scheduler, pixelRatio, FileSource::getSharedFileSource(resourceOptions), mapOptions)) {} Map::Map(std::unique_ptr<Impl> impl_) : impl(std::move(impl_)) {} @@ -308,47 +307,36 @@ BoundOptions Map::getBounds() const { .withMaxZoom(impl->transform.getState().getMaxZoom()); } -#pragma mark - Size +#pragma mark - Map options void Map::setSize(const Size size) { impl->transform.resize(size); impl->onUpdate(); } -Size Map::getSize() const { - return impl->transform.getState().getSize(); -} - -#pragma mark - North Orientation - void Map::setNorthOrientation(NorthOrientation orientation) { impl->transform.setNorthOrientation(orientation); impl->onUpdate(); } -#pragma mark - Constrain mode - void Map::setConstrainMode(mbgl::ConstrainMode mode) { impl->transform.setConstrainMode(mode); impl->onUpdate(); } -#pragma mark - Viewport mode - void Map::setViewportMode(mbgl::ViewportMode mode) { impl->transform.setViewportMode(mode); impl->onUpdate(); } -#pragma mark - Map options - MapOptions Map::getMapOptions() const { return std::move(MapOptions() .withMapMode(impl->mode) .withConstrainMode(impl->transform.getConstrainMode()) .withViewportMode(impl->transform.getViewportMode()) .withCrossSourceCollisions(impl->crossSourceCollisions) - .withNorthOrientation(impl->transform.getNorthOrientation())); + .withNorthOrientation(impl->transform.getNorthOrientation()) + .withSize(impl->transform.getState().getSize())); } #pragma mark - Projection mode diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp index cdc8c231e4..afaa05229c 100644 --- a/src/mbgl/map/map_impl.cpp +++ b/src/mbgl/map/map_impl.cpp @@ -10,7 +10,6 @@ namespace mbgl { Map::Impl::Impl(RendererFrontend& frontend_, MapObserver& observer_, Scheduler& scheduler_, - Size size_, float pixelRatio_, std::shared_ptr<FileSource> fileSource_, const MapOptions& mapOptions) @@ -27,7 +26,7 @@ Map::Impl::Impl(RendererFrontend& frontend_, transform.setNorthOrientation(mapOptions.northOrientation()); style->impl->setObserver(this); rendererFrontend.setObserver(*this); - transform.resize(size_); + transform.resize(mapOptions.size()); } Map::Impl::~Impl() { diff --git a/src/mbgl/map/map_impl.hpp b/src/mbgl/map/map_impl.hpp index 13ffdc02ae..90b0a721ca 100644 --- a/src/mbgl/map/map_impl.hpp +++ b/src/mbgl/map/map_impl.hpp @@ -30,7 +30,7 @@ struct StillImageRequest { class Map::Impl : public style::Observer, public RendererObserver { public: - Impl(RendererFrontend&, MapObserver&, Scheduler&, Size size, float pixelRatio, std::shared_ptr<FileSource>, const MapOptions&); + Impl(RendererFrontend&, MapObserver&, Scheduler&, float pixelRatio, std::shared_ptr<FileSource>, const MapOptions&); ~Impl() final; // StyleObserver diff --git a/src/mbgl/map/map_options.cpp b/src/mbgl/map/map_options.cpp index b4ad38ac7f..98cabb2550 100644 --- a/src/mbgl/map/map_options.cpp +++ b/src/mbgl/map/map_options.cpp @@ -9,6 +9,7 @@ public: ViewportMode viewportMode = ViewportMode::Default; NorthOrientation orientation = NorthOrientation::Upwards; bool crossSourceCollisions = true; + Size size; }; // These requires the complete type of Impl. @@ -61,4 +62,13 @@ NorthOrientation MapOptions::northOrientation() const { return impl_->orientation; } +MapOptions& MapOptions::withSize(Size size_) { + impl_->size = size_; + return *this; +} + +Size MapOptions::size() const { + return impl_->size; +} + } // namespace mbgl |