From 1520a56813f82bbe875774fdc2b3df26392278d6 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 21 Apr 2017 13:35:34 -0700 Subject: [all] Promote Style to public API --- include/mbgl/map/map.hpp | 41 +++--------------------- include/mbgl/style/style.hpp | 75 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 36 deletions(-) create mode 100644 include/mbgl/style/style.hpp (limited to 'include') diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 33b40a8e77..85c95d6491 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -28,9 +27,7 @@ class Scheduler; namespace style { class Image; -class Source; -class Layer; -class Light; +class Style; } // namespace style class Map : private util::noncopyable { @@ -58,15 +55,15 @@ public: // Main render function. void render(View&); - // Styling - style::TransitionOptions getTransitionOptions() const; - void setTransitionOptions(const style::TransitionOptions&); - + // Style void setStyleURL(const std::string&); void setStyleJSON(const std::string&); std::string getStyleURL() const; std::string getStyleJSON() const; + style::Style& getStyle(); + const style::Style& getStyle() const; + // Transition void cancelTransitions(); void setGestureInProgress(bool); @@ -156,34 +153,6 @@ public: void updateAnnotation(AnnotationID, const Annotation&); void removeAnnotation(AnnotationID); - // Sources - std::vector getSources(); - style::Source* getSource(const std::string& sourceID); - void addSource(std::unique_ptr); - std::unique_ptr removeSource(const std::string& sourceID); - - // Layers - std::vector getLayers(); - style::Layer* getLayer(const std::string& layerID); - void addLayer(std::unique_ptr, const optional& beforeLayerID = {}); - std::unique_ptr removeLayer(const std::string& layerID); - - // Images - void addImage(std::unique_ptr); - void removeImage(const std::string&); - const style::Image* getImage(const std::string&); - - // Light - void setLight(std::unique_ptr); - style::Light* getLight(); - - // Defaults - std::string getStyleName() const; - LatLng getDefaultLatLng() const; - double getDefaultZoom() const; - double getDefaultBearing() const; - double getDefaultPitch() const; - // Feature queries std::vector queryRenderedFeatures(const ScreenCoordinate&, const RenderedQueryOptions& options = {}); std::vector queryRenderedFeatures(const ScreenBox&, const RenderedQueryOptions& options = {}); diff --git a/include/mbgl/style/style.hpp b/include/mbgl/style/style.hpp new file mode 100644 index 0000000000..82ff1b3078 --- /dev/null +++ b/include/mbgl/style/style.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace mbgl { + +class FileSource; +class Scheduler; + +namespace style { + +class Light; +class Image; +class Source; +class Layer; + +class Style { +public: + Style(Scheduler&, FileSource&, float pixelRatio); + ~Style(); + + // Defaults + std::string getName() const; + LatLng getDefaultLatLng() const; + double getDefaultZoom() const; + double getDefaultBearing() const; + double getDefaultPitch() const; + + // TransitionOptions + TransitionOptions getTransitionOptions() const; + void setTransitionOptions(const TransitionOptions&); + + // Light + Light* getLight(); + const Light* getLight() const; + + void setLight(std::unique_ptr); + + // Images + const Image* getImage(const std::string&) const; + void addImage(std::unique_ptr); + void removeImage(const std::string&); + + // Sources + std::vector< Source*> getSources(); + std::vector getSources() const; + + Source* getSource(const std::string&); + const Source* getSource(const std::string&) const; + + void addSource(std::unique_ptr); + std::unique_ptr removeSource(const std::string& sourceID); + + // Layers + std::vector< Layer*> getLayers(); + std::vector getLayers() const; + + Layer* getLayer(const std::string&); + const Layer* getLayer(const std::string&) const; + + void addLayer(std::unique_ptr, const optional& beforeLayerID = {}); + std::unique_ptr removeLayer(const std::string& layerID); + + // Private implementation + class Impl; + const std::unique_ptr impl; +}; + +} // namespace style +} // namespace mbgl -- cgit v1.2.1