From c902f9098b331302aaa1baac77d1575db624a132 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 26 Apr 2016 16:39:56 -0700 Subject: [core] Rationalize naming for style-related code --- include/mbgl/annotation/annotation.hpp | 3 +- include/mbgl/layer/background_layer.hpp | 41 ------ include/mbgl/layer/circle_layer.hpp | 59 -------- include/mbgl/layer/custom_layer.hpp | 69 ---------- include/mbgl/layer/fill_layer.hpp | 62 --------- include/mbgl/layer/line_layer.hpp | 87 ------------ include/mbgl/layer/raster_layer.hpp | 58 -------- include/mbgl/layer/symbol_layer.hpp | 180 ------------------------ include/mbgl/map/map.hpp | 15 +- include/mbgl/storage/offline.hpp | 4 +- include/mbgl/storage/resource.hpp | 2 +- include/mbgl/style/filter.hpp | 2 + include/mbgl/style/function.hpp | 27 ++++ include/mbgl/style/layer.hpp | 7 +- include/mbgl/style/layers/background_layer.hpp | 45 ++++++ include/mbgl/style/layers/circle_layer.hpp | 63 +++++++++ include/mbgl/style/layers/custom_layer.hpp | 71 ++++++++++ include/mbgl/style/layers/fill_layer.hpp | 66 +++++++++ include/mbgl/style/layers/line_layer.hpp | 91 ++++++++++++ include/mbgl/style/layers/raster_layer.hpp | 62 +++++++++ include/mbgl/style/layers/symbol_layer.hpp | 184 +++++++++++++++++++++++++ include/mbgl/style/property_transition.hpp | 17 --- include/mbgl/style/property_value.hpp | 38 +++++ include/mbgl/style/transition_options.hpp | 19 +++ include/mbgl/style/types.hpp | 41 +----- include/mbgl/util/color.hpp | 10 ++ include/mbgl/util/font_stack.hpp | 17 +++ 27 files changed, 714 insertions(+), 626 deletions(-) delete mode 100644 include/mbgl/layer/background_layer.hpp delete mode 100644 include/mbgl/layer/circle_layer.hpp delete mode 100644 include/mbgl/layer/custom_layer.hpp delete mode 100644 include/mbgl/layer/fill_layer.hpp delete mode 100644 include/mbgl/layer/line_layer.hpp delete mode 100644 include/mbgl/layer/raster_layer.hpp delete mode 100644 include/mbgl/layer/symbol_layer.hpp create mode 100644 include/mbgl/style/function.hpp create mode 100644 include/mbgl/style/layers/background_layer.hpp create mode 100644 include/mbgl/style/layers/circle_layer.hpp create mode 100644 include/mbgl/style/layers/custom_layer.hpp create mode 100644 include/mbgl/style/layers/fill_layer.hpp create mode 100644 include/mbgl/style/layers/line_layer.hpp create mode 100644 include/mbgl/style/layers/raster_layer.hpp create mode 100644 include/mbgl/style/layers/symbol_layer.hpp delete mode 100644 include/mbgl/style/property_transition.hpp create mode 100644 include/mbgl/style/property_value.hpp create mode 100644 include/mbgl/style/transition_options.hpp create mode 100644 include/mbgl/util/color.hpp create mode 100644 include/mbgl/util/font_stack.hpp (limited to 'include') diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp index 8b0c3026a8..6cb26e6a82 100644 --- a/include/mbgl/annotation/annotation.hpp +++ b/include/mbgl/annotation/annotation.hpp @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include #include #include diff --git a/include/mbgl/layer/background_layer.hpp b/include/mbgl/layer/background_layer.hpp deleted file mode 100644 index bba16d3839..0000000000 --- a/include/mbgl/layer/background_layer.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -namespace mbgl { - -class BackgroundLayer : public Layer { -public: - BackgroundLayer(const std::string& layerID); - ~BackgroundLayer() final; - - // Paint properties - - PropertyValue getBackgroundColor() const; - void setBackgroundColor(PropertyValue); - - PropertyValue getBackgroundPattern() const; - void setBackgroundPattern(PropertyValue); - - PropertyValue getBackgroundOpacity() const; - void setBackgroundOpacity(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - BackgroundLayer(const Impl&); - BackgroundLayer(const BackgroundLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Background; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/circle_layer.hpp b/include/mbgl/layer/circle_layer.hpp deleted file mode 100644 index 81f84d36a8..0000000000 --- a/include/mbgl/layer/circle_layer.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -namespace mbgl { - -class CircleLayer : public Layer { -public: - CircleLayer(const std::string& layerID); - ~CircleLayer() final; - - // Source - - void setSource(const std::string& sourceID, const std::string& sourceLayer); - const std::string& getSourceID() const; - const std::string& getSourceLayer() const; - - void setFilter(const Filter&); - const Filter& getFilter() const; - - // Paint properties - - PropertyValue getCircleRadius() const; - void setCircleRadius(PropertyValue); - - PropertyValue getCircleColor() const; - void setCircleColor(PropertyValue); - - PropertyValue getCircleBlur() const; - void setCircleBlur(PropertyValue); - - PropertyValue getCircleOpacity() const; - void setCircleOpacity(PropertyValue); - - PropertyValue> getCircleTranslate() const; - void setCircleTranslate(PropertyValue>); - - PropertyValue getCircleTranslateAnchor() const; - void setCircleTranslateAnchor(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - CircleLayer(const Impl&); - CircleLayer(const CircleLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Circle; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/custom_layer.hpp b/include/mbgl/layer/custom_layer.hpp deleted file mode 100644 index 9782d9593f..0000000000 --- a/include/mbgl/layer/custom_layer.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once - -#include - -namespace mbgl { - -/** - * Initialize any GL state needed by the custom layer. This method is called once, from the - * rendering thread, at a point when the GL context is active but before rendering for the - * first time. - * - * Resources that are acquired in this method must be released in the UninitializeFunction. - */ -using CustomLayerInitializeFunction = void (*)(void* context); - -/** - * Parameters that define the current camera position for a CustomLayerRenderFunction. - */ -struct CustomLayerRenderParameters { - double width; - double height; - double latitude; - double longitude; - double zoom; - double bearing; - double pitch; - double altitude; -}; - -/** - * Render the layer. This method is called once per frame. The implementation should not make - * any assumptions about the GL state (other than that the correct context is active). It may - * make changes to the state, and is not required to reset values such as the depth mask, stencil - * mask, and corresponding test flags to their original values. - */ -using CustomLayerRenderFunction = void (*)(void* context, const CustomLayerRenderParameters&); - -/** - * Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This - * method is called once, from the rendering thread, at a point when the GL context is active. - * - * Note that it may be called even when the InitializeFunction has not been called. - */ -using CustomLayerDeinitializeFunction = void (*)(void* context); - -class CustomLayer : public Layer { -public: - CustomLayer(const std::string& id, - CustomLayerInitializeFunction, - CustomLayerRenderFunction, - CustomLayerDeinitializeFunction, - void* context); - ~CustomLayer() final; - - // Private implementation - - class Impl; - Impl* impl; - - CustomLayer(const Impl&); - CustomLayer(const CustomLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Custom; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/fill_layer.hpp b/include/mbgl/layer/fill_layer.hpp deleted file mode 100644 index 10cf4f3bbd..0000000000 --- a/include/mbgl/layer/fill_layer.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -namespace mbgl { - -class FillLayer : public Layer { -public: - FillLayer(const std::string& layerID); - ~FillLayer() final; - - // Source - - void setSource(const std::string& sourceID, const std::string& sourceLayer); - const std::string& getSourceID() const; - const std::string& getSourceLayer() const; - - void setFilter(const Filter&); - const Filter& getFilter() const; - - // Paint properties - - PropertyValue getFillAntialias() const; - void setFillAntialias(PropertyValue); - - PropertyValue getFillOpacity() const; - void setFillOpacity(PropertyValue); - - PropertyValue getFillColor() const; - void setFillColor(PropertyValue); - - PropertyValue getFillOutlineColor() const; - void setFillOutlineColor(PropertyValue); - - PropertyValue> getFillTranslate() const; - void setFillTranslate(PropertyValue>); - - PropertyValue getFillTranslateAnchor() const; - void setFillTranslateAnchor(PropertyValue); - - PropertyValue getFillPattern() const; - void setFillPattern(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - FillLayer(const Impl&); - FillLayer(const FillLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Fill; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/line_layer.hpp b/include/mbgl/layer/line_layer.hpp deleted file mode 100644 index aeec363281..0000000000 --- a/include/mbgl/layer/line_layer.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -#include - -namespace mbgl { - -class LineLayer : public Layer { -public: - LineLayer(const std::string& layerID); - ~LineLayer() final; - - // Source - - void setSource(const std::string& sourceID, const std::string& sourceLayer); - const std::string& getSourceID() const; - const std::string& getSourceLayer() const; - - void setFilter(const Filter&); - const Filter& getFilter() const; - - // Layout properties - - PropertyValue getLineCap() const; - void setLineCap(PropertyValue); - - PropertyValue getLineJoin() const; - void setLineJoin(PropertyValue); - - PropertyValue getLineMiterLimit() const; - void setLineMiterLimit(PropertyValue); - - PropertyValue getLineRoundLimit() const; - void setLineRoundLimit(PropertyValue); - - // Paint properties - - PropertyValue getLineOpacity() const; - void setLineOpacity(PropertyValue); - - PropertyValue getLineColor() const; - void setLineColor(PropertyValue); - - PropertyValue> getLineTranslate() const; - void setLineTranslate(PropertyValue>); - - PropertyValue getLineTranslateAnchor() const; - void setLineTranslateAnchor(PropertyValue); - - PropertyValue getLineWidth() const; - void setLineWidth(PropertyValue); - - PropertyValue getLineGapWidth() const; - void setLineGapWidth(PropertyValue); - - PropertyValue getLineOffset() const; - void setLineOffset(PropertyValue); - - PropertyValue getLineBlur() const; - void setLineBlur(PropertyValue); - - PropertyValue> getLineDasharray() const; - void setLineDasharray(PropertyValue>); - - PropertyValue getLinePattern() const; - void setLinePattern(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - LineLayer(const Impl&); - LineLayer(const LineLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Line; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/raster_layer.hpp b/include/mbgl/layer/raster_layer.hpp deleted file mode 100644 index 7dc2532a2f..0000000000 --- a/include/mbgl/layer/raster_layer.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -namespace mbgl { - -class RasterLayer : public Layer { -public: - RasterLayer(const std::string& layerID); - ~RasterLayer() final; - - // Source - - void setSource(const std::string& sourceID); - const std::string& getSourceID() const; - - // Paint properties - - PropertyValue getRasterOpacity() const; - void setRasterOpacity(PropertyValue); - - PropertyValue getRasterHueRotate() const; - void setRasterHueRotate(PropertyValue); - - PropertyValue getRasterBrightnessMin() const; - void setRasterBrightnessMin(PropertyValue); - - PropertyValue getRasterBrightnessMax() const; - void setRasterBrightnessMax(PropertyValue); - - PropertyValue getRasterSaturation() const; - void setRasterSaturation(PropertyValue); - - PropertyValue getRasterContrast() const; - void setRasterContrast(PropertyValue); - - PropertyValue getRasterFadeDuration() const; - void setRasterFadeDuration(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - RasterLayer(const Impl&); - RasterLayer(const RasterLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Raster; -} - -} // namespace mbgl diff --git a/include/mbgl/layer/symbol_layer.hpp b/include/mbgl/layer/symbol_layer.hpp deleted file mode 100644 index 006506b3d8..0000000000 --- a/include/mbgl/layer/symbol_layer.hpp +++ /dev/null @@ -1,180 +0,0 @@ -// This file is generated. Do not edit. - -#pragma once - -#include -#include -#include - -#include - -namespace mbgl { - -class SymbolLayer : public Layer { -public: - SymbolLayer(const std::string& layerID); - ~SymbolLayer() final; - - // Source - - void setSource(const std::string& sourceID, const std::string& sourceLayer); - const std::string& getSourceID() const; - const std::string& getSourceLayer() const; - - void setFilter(const Filter&); - const Filter& getFilter() const; - - // Layout properties - - PropertyValue getSymbolPlacement() const; - void setSymbolPlacement(PropertyValue); - - PropertyValue getSymbolSpacing() const; - void setSymbolSpacing(PropertyValue); - - PropertyValue getSymbolAvoidEdges() const; - void setSymbolAvoidEdges(PropertyValue); - - PropertyValue getIconAllowOverlap() const; - void setIconAllowOverlap(PropertyValue); - - PropertyValue getIconIgnorePlacement() const; - void setIconIgnorePlacement(PropertyValue); - - PropertyValue getIconOptional() const; - void setIconOptional(PropertyValue); - - PropertyValue getIconRotationAlignment() const; - void setIconRotationAlignment(PropertyValue); - - PropertyValue getIconSize() const; - void setIconSize(PropertyValue); - - PropertyValue getIconImage() const; - void setIconImage(PropertyValue); - - PropertyValue getIconRotate() const; - void setIconRotate(PropertyValue); - - PropertyValue getIconPadding() const; - void setIconPadding(PropertyValue); - - PropertyValue getIconKeepUpright() const; - void setIconKeepUpright(PropertyValue); - - PropertyValue> getIconOffset() const; - void setIconOffset(PropertyValue>); - - PropertyValue getTextRotationAlignment() const; - void setTextRotationAlignment(PropertyValue); - - PropertyValue getTextField() const; - void setTextField(PropertyValue); - - PropertyValue> getTextFont() const; - void setTextFont(PropertyValue>); - - PropertyValue getTextSize() const; - void setTextSize(PropertyValue); - - PropertyValue getTextMaxWidth() const; - void setTextMaxWidth(PropertyValue); - - PropertyValue getTextLineHeight() const; - void setTextLineHeight(PropertyValue); - - PropertyValue getTextLetterSpacing() const; - void setTextLetterSpacing(PropertyValue); - - PropertyValue getTextJustify() const; - void setTextJustify(PropertyValue); - - PropertyValue getTextAnchor() const; - void setTextAnchor(PropertyValue); - - PropertyValue getTextMaxAngle() const; - void setTextMaxAngle(PropertyValue); - - PropertyValue getTextRotate() const; - void setTextRotate(PropertyValue); - - PropertyValue getTextPadding() const; - void setTextPadding(PropertyValue); - - PropertyValue getTextKeepUpright() const; - void setTextKeepUpright(PropertyValue); - - PropertyValue getTextTransform() const; - void setTextTransform(PropertyValue); - - PropertyValue> getTextOffset() const; - void setTextOffset(PropertyValue>); - - PropertyValue getTextAllowOverlap() const; - void setTextAllowOverlap(PropertyValue); - - PropertyValue getTextIgnorePlacement() const; - void setTextIgnorePlacement(PropertyValue); - - PropertyValue getTextOptional() const; - void setTextOptional(PropertyValue); - - // Paint properties - - PropertyValue getIconOpacity() const; - void setIconOpacity(PropertyValue); - - PropertyValue getIconColor() const; - void setIconColor(PropertyValue); - - PropertyValue getIconHaloColor() const; - void setIconHaloColor(PropertyValue); - - PropertyValue getIconHaloWidth() const; - void setIconHaloWidth(PropertyValue); - - PropertyValue getIconHaloBlur() const; - void setIconHaloBlur(PropertyValue); - - PropertyValue> getIconTranslate() const; - void setIconTranslate(PropertyValue>); - - PropertyValue getIconTranslateAnchor() const; - void setIconTranslateAnchor(PropertyValue); - - PropertyValue getTextOpacity() const; - void setTextOpacity(PropertyValue); - - PropertyValue getTextColor() const; - void setTextColor(PropertyValue); - - PropertyValue getTextHaloColor() const; - void setTextHaloColor(PropertyValue); - - PropertyValue getTextHaloWidth() const; - void setTextHaloWidth(PropertyValue); - - PropertyValue getTextHaloBlur() const; - void setTextHaloBlur(PropertyValue); - - PropertyValue> getTextTranslate() const; - void setTextTranslate(PropertyValue>); - - PropertyValue getTextTranslateAnchor() const; - void setTextTranslateAnchor(PropertyValue); - - // Private implementation - - class Impl; - Impl* const impl; - - SymbolLayer(const Impl&); - SymbolLayer(const SymbolLayer&) = delete; -}; - -template <> -inline bool Layer::is() const { - return type == Type::Symbol; -} - -} // namespace mbgl diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index aadfdf9ada..b44b53ff99 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -22,10 +22,13 @@ namespace mbgl { class FileSource; class View; class SpriteImage; -class Layer; struct CameraOptions; struct AnimationOptions; +namespace style { +class Layer; +} + class Map : private util::noncopyable { public: explicit Map(View&, FileSource&, @@ -47,9 +50,9 @@ public: void update(Update update); // Styling - void addClass(const std::string&, const PropertyTransition& = {}); - void removeClass(const std::string&, const PropertyTransition& = {}); - void setClasses(const std::vector&, const PropertyTransition& = {}); + void addClass(const std::string&, const style::TransitionOptions& = {}); + void removeClass(const std::string&, const style::TransitionOptions& = {}); + void setClasses(const std::vector&, const style::TransitionOptions& = {}); bool hasClass(const std::string&) const; std::vector getClasses() const; @@ -146,7 +149,7 @@ public: AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&); - void addLayer(std::unique_ptr, const optional& beforeLayerID = {}); + void addLayer(std::unique_ptr, const optional& beforeLayerID = {}); void removeLayer(const std::string& layerID); // Feature queries diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp index e0c5ba6247..990c8470bb 100644 --- a/include/mbgl/storage/offline.hpp +++ b/include/mbgl/storage/offline.hpp @@ -12,7 +12,7 @@ namespace mbgl { class TileID; -class SourceInfo; +class Tileset; /* * An offline region defined by a style URL, geographic bounding box, zoom range, and @@ -30,7 +30,7 @@ public: OfflineTilePyramidRegionDefinition(const std::string&, const LatLngBounds&, double, double, float); /* Private */ - std::vector tileCover(SourceType, uint16_t tileSize, const SourceInfo&) const; + std::vector tileCover(SourceType, uint16_t tileSize, const Tileset&) const; const std::string styleURL; const LatLngBounds bounds; diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp index 62ee549663..a75de380a1 100644 --- a/include/mbgl/storage/resource.hpp +++ b/include/mbgl/storage/resource.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include diff --git a/include/mbgl/style/filter.hpp b/include/mbgl/style/filter.hpp index 6ad6969fbf..9cf84f5e1d 100644 --- a/include/mbgl/style/filter.hpp +++ b/include/mbgl/style/filter.hpp @@ -7,6 +7,7 @@ #include namespace mbgl { +namespace style { typedef variant< class NullFilter, @@ -100,4 +101,5 @@ public: std::string key; }; +} // namespace style } // namespace mbgl diff --git a/include/mbgl/style/function.hpp b/include/mbgl/style/function.hpp new file mode 100644 index 0000000000..da2659c76a --- /dev/null +++ b/include/mbgl/style/function.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace style { + +template +class Function { +public: + using Stop = std::pair; + using Stops = std::vector; + + explicit Function(const Stops& stops_, float base_) + : base(base_), stops(stops_) {} + + float getBase() const { return base; } + const std::vector>& getStops() const { return stops; } + +private: + float base = 1; + std::vector> stops; +}; + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 4a40cc0cff..1f4a6fdf35 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -1,5 +1,4 @@ -#ifndef MBGL_LAYER -#define MBGL_LAYER +#pragma once #include #include @@ -7,6 +6,7 @@ #include namespace mbgl { +namespace style { /** * The runtime representation of a [layer](https://www.mapbox.com/mapbox-gl-style-spec/#layers) from the Mapbox Style @@ -79,6 +79,5 @@ protected: Layer(Type, std::unique_ptr); }; +} // namespace style } // namespace mbgl - -#endif diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp new file mode 100644 index 0000000000..2eb84ee499 --- /dev/null +++ b/include/mbgl/style/layers/background_layer.hpp @@ -0,0 +1,45 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +namespace mbgl { +namespace style { + +class BackgroundLayer : public Layer { +public: + BackgroundLayer(const std::string& layerID); + ~BackgroundLayer() final; + + // Paint properties + + PropertyValue getBackgroundColor() const; + void setBackgroundColor(PropertyValue); + + PropertyValue getBackgroundPattern() const; + void setBackgroundPattern(PropertyValue); + + PropertyValue getBackgroundOpacity() const; + void setBackgroundOpacity(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + BackgroundLayer(const Impl&); + BackgroundLayer(const BackgroundLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Background; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp new file mode 100644 index 0000000000..10d281b6ac --- /dev/null +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -0,0 +1,63 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +namespace mbgl { +namespace style { + +class CircleLayer : public Layer { +public: + CircleLayer(const std::string& layerID); + ~CircleLayer() final; + + // Source + + void setSource(const std::string& sourceID, const std::string& sourceLayer); + const std::string& getSourceID() const; + const std::string& getSourceLayer() const; + + void setFilter(const Filter&); + const Filter& getFilter() const; + + // Paint properties + + PropertyValue getCircleRadius() const; + void setCircleRadius(PropertyValue); + + PropertyValue getCircleColor() const; + void setCircleColor(PropertyValue); + + PropertyValue getCircleBlur() const; + void setCircleBlur(PropertyValue); + + PropertyValue getCircleOpacity() const; + void setCircleOpacity(PropertyValue); + + PropertyValue> getCircleTranslate() const; + void setCircleTranslate(PropertyValue>); + + PropertyValue getCircleTranslateAnchor() const; + void setCircleTranslateAnchor(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + CircleLayer(const Impl&); + CircleLayer(const CircleLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Circle; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp new file mode 100644 index 0000000000..d3867e2c4f --- /dev/null +++ b/include/mbgl/style/layers/custom_layer.hpp @@ -0,0 +1,71 @@ +#pragma once + +#include + +namespace mbgl { +namespace style { + +/** + * Initialize any GL state needed by the custom layer. This method is called once, from the + * rendering thread, at a point when the GL context is active but before rendering for the + * first time. + * + * Resources that are acquired in this method must be released in the UninitializeFunction. + */ +using CustomLayerInitializeFunction = void (*)(void* context); + +/** + * Parameters that define the current camera position for a CustomLayerRenderFunction. + */ +struct CustomLayerRenderParameters { + double width; + double height; + double latitude; + double longitude; + double zoom; + double bearing; + double pitch; + double altitude; +}; + +/** + * Render the layer. This method is called once per frame. The implementation should not make + * any assumptions about the GL state (other than that the correct context is active). It may + * make changes to the state, and is not required to reset values such as the depth mask, stencil + * mask, and corresponding test flags to their original values. + */ +using CustomLayerRenderFunction = void (*)(void* context, const CustomLayerRenderParameters&); + +/** + * Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This + * method is called once, from the rendering thread, at a point when the GL context is active. + * + * Note that it may be called even when the InitializeFunction has not been called. + */ +using CustomLayerDeinitializeFunction = void (*)(void* context); + +class CustomLayer : public Layer { +public: + CustomLayer(const std::string& id, + CustomLayerInitializeFunction, + CustomLayerRenderFunction, + CustomLayerDeinitializeFunction, + void* context); + ~CustomLayer() final; + + // Private implementation + + class Impl; + Impl* impl; + + CustomLayer(const Impl&); + CustomLayer(const CustomLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Custom; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp new file mode 100644 index 0000000000..a14bf4a390 --- /dev/null +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -0,0 +1,66 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +namespace mbgl { +namespace style { + +class FillLayer : public Layer { +public: + FillLayer(const std::string& layerID); + ~FillLayer() final; + + // Source + + void setSource(const std::string& sourceID, const std::string& sourceLayer); + const std::string& getSourceID() const; + const std::string& getSourceLayer() const; + + void setFilter(const Filter&); + const Filter& getFilter() const; + + // Paint properties + + PropertyValue getFillAntialias() const; + void setFillAntialias(PropertyValue); + + PropertyValue getFillOpacity() const; + void setFillOpacity(PropertyValue); + + PropertyValue getFillColor() const; + void setFillColor(PropertyValue); + + PropertyValue getFillOutlineColor() const; + void setFillOutlineColor(PropertyValue); + + PropertyValue> getFillTranslate() const; + void setFillTranslate(PropertyValue>); + + PropertyValue getFillTranslateAnchor() const; + void setFillTranslateAnchor(PropertyValue); + + PropertyValue getFillPattern() const; + void setFillPattern(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + FillLayer(const Impl&); + FillLayer(const FillLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Fill; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp new file mode 100644 index 0000000000..fb9e37811a --- /dev/null +++ b/include/mbgl/style/layers/line_layer.hpp @@ -0,0 +1,91 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +#include + +namespace mbgl { +namespace style { + +class LineLayer : public Layer { +public: + LineLayer(const std::string& layerID); + ~LineLayer() final; + + // Source + + void setSource(const std::string& sourceID, const std::string& sourceLayer); + const std::string& getSourceID() const; + const std::string& getSourceLayer() const; + + void setFilter(const Filter&); + const Filter& getFilter() const; + + // Layout properties + + PropertyValue getLineCap() const; + void setLineCap(PropertyValue); + + PropertyValue getLineJoin() const; + void setLineJoin(PropertyValue); + + PropertyValue getLineMiterLimit() const; + void setLineMiterLimit(PropertyValue); + + PropertyValue getLineRoundLimit() const; + void setLineRoundLimit(PropertyValue); + + // Paint properties + + PropertyValue getLineOpacity() const; + void setLineOpacity(PropertyValue); + + PropertyValue getLineColor() const; + void setLineColor(PropertyValue); + + PropertyValue> getLineTranslate() const; + void setLineTranslate(PropertyValue>); + + PropertyValue getLineTranslateAnchor() const; + void setLineTranslateAnchor(PropertyValue); + + PropertyValue getLineWidth() const; + void setLineWidth(PropertyValue); + + PropertyValue getLineGapWidth() const; + void setLineGapWidth(PropertyValue); + + PropertyValue getLineOffset() const; + void setLineOffset(PropertyValue); + + PropertyValue getLineBlur() const; + void setLineBlur(PropertyValue); + + PropertyValue> getLineDasharray() const; + void setLineDasharray(PropertyValue>); + + PropertyValue getLinePattern() const; + void setLinePattern(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + LineLayer(const Impl&); + LineLayer(const LineLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Line; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp new file mode 100644 index 0000000000..6d0c7dd91c --- /dev/null +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -0,0 +1,62 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +namespace mbgl { +namespace style { + +class RasterLayer : public Layer { +public: + RasterLayer(const std::string& layerID); + ~RasterLayer() final; + + // Source + + void setSource(const std::string& sourceID); + const std::string& getSourceID() const; + + // Paint properties + + PropertyValue getRasterOpacity() const; + void setRasterOpacity(PropertyValue); + + PropertyValue getRasterHueRotate() const; + void setRasterHueRotate(PropertyValue); + + PropertyValue getRasterBrightnessMin() const; + void setRasterBrightnessMin(PropertyValue); + + PropertyValue getRasterBrightnessMax() const; + void setRasterBrightnessMax(PropertyValue); + + PropertyValue getRasterSaturation() const; + void setRasterSaturation(PropertyValue); + + PropertyValue getRasterContrast() const; + void setRasterContrast(PropertyValue); + + PropertyValue getRasterFadeDuration() const; + void setRasterFadeDuration(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + RasterLayer(const Impl&); + RasterLayer(const RasterLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Raster; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp new file mode 100644 index 0000000000..3806310c95 --- /dev/null +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -0,0 +1,184 @@ +// This file is generated. Do not edit. + +#pragma once + +#include +#include +#include + +#include + +#include + +namespace mbgl { +namespace style { + +class SymbolLayer : public Layer { +public: + SymbolLayer(const std::string& layerID); + ~SymbolLayer() final; + + // Source + + void setSource(const std::string& sourceID, const std::string& sourceLayer); + const std::string& getSourceID() const; + const std::string& getSourceLayer() const; + + void setFilter(const Filter&); + const Filter& getFilter() const; + + // Layout properties + + PropertyValue getSymbolPlacement() const; + void setSymbolPlacement(PropertyValue); + + PropertyValue getSymbolSpacing() const; + void setSymbolSpacing(PropertyValue); + + PropertyValue getSymbolAvoidEdges() const; + void setSymbolAvoidEdges(PropertyValue); + + PropertyValue getIconAllowOverlap() const; + void setIconAllowOverlap(PropertyValue); + + PropertyValue getIconIgnorePlacement() const; + void setIconIgnorePlacement(PropertyValue); + + PropertyValue getIconOptional() const; + void setIconOptional(PropertyValue); + + PropertyValue getIconRotationAlignment() const; + void setIconRotationAlignment(PropertyValue); + + PropertyValue getIconSize() const; + void setIconSize(PropertyValue); + + PropertyValue getIconImage() const; + void setIconImage(PropertyValue); + + PropertyValue getIconRotate() const; + void setIconRotate(PropertyValue); + + PropertyValue getIconPadding() const; + void setIconPadding(PropertyValue); + + PropertyValue getIconKeepUpright() const; + void setIconKeepUpright(PropertyValue); + + PropertyValue> getIconOffset() const; + void setIconOffset(PropertyValue>); + + PropertyValue getTextRotationAlignment() const; + void setTextRotationAlignment(PropertyValue); + + PropertyValue getTextField() const; + void setTextField(PropertyValue); + + PropertyValue> getTextFont() const; + void setTextFont(PropertyValue>); + + PropertyValue getTextSize() const; + void setTextSize(PropertyValue); + + PropertyValue getTextMaxWidth() const; + void setTextMaxWidth(PropertyValue); + + PropertyValue getTextLineHeight() const; + void setTextLineHeight(PropertyValue); + + PropertyValue getTextLetterSpacing() const; + void setTextLetterSpacing(PropertyValue); + + PropertyValue getTextJustify() const; + void setTextJustify(PropertyValue); + + PropertyValue getTextAnchor() const; + void setTextAnchor(PropertyValue); + + PropertyValue getTextMaxAngle() const; + void setTextMaxAngle(PropertyValue); + + PropertyValue getTextRotate() const; + void setTextRotate(PropertyValue); + + PropertyValue getTextPadding() const; + void setTextPadding(PropertyValue); + + PropertyValue getTextKeepUpright() const; + void setTextKeepUpright(PropertyValue); + + PropertyValue getTextTransform() const; + void setTextTransform(PropertyValue); + + PropertyValue> getTextOffset() const; + void setTextOffset(PropertyValue>); + + PropertyValue getTextAllowOverlap() const; + void setTextAllowOverlap(PropertyValue); + + PropertyValue getTextIgnorePlacement() const; + void setTextIgnorePlacement(PropertyValue); + + PropertyValue getTextOptional() const; + void setTextOptional(PropertyValue); + + // Paint properties + + PropertyValue getIconOpacity() const; + void setIconOpacity(PropertyValue); + + PropertyValue getIconColor() const; + void setIconColor(PropertyValue); + + PropertyValue getIconHaloColor() const; + void setIconHaloColor(PropertyValue); + + PropertyValue getIconHaloWidth() const; + void setIconHaloWidth(PropertyValue); + + PropertyValue getIconHaloBlur() const; + void setIconHaloBlur(PropertyValue); + + PropertyValue> getIconTranslate() const; + void setIconTranslate(PropertyValue>); + + PropertyValue getIconTranslateAnchor() const; + void setIconTranslateAnchor(PropertyValue); + + PropertyValue getTextOpacity() const; + void setTextOpacity(PropertyValue); + + PropertyValue getTextColor() const; + void setTextColor(PropertyValue); + + PropertyValue getTextHaloColor() const; + void setTextHaloColor(PropertyValue); + + PropertyValue getTextHaloWidth() const; + void setTextHaloWidth(PropertyValue); + + PropertyValue getTextHaloBlur() const; + void setTextHaloBlur(PropertyValue); + + PropertyValue> getTextTranslate() const; + void setTextTranslate(PropertyValue>); + + PropertyValue getTextTranslateAnchor() const; + void setTextTranslateAnchor(PropertyValue); + + // Private implementation + + class Impl; + Impl* const impl; + + SymbolLayer(const Impl&); + SymbolLayer(const SymbolLayer&) = delete; +}; + +template <> +inline bool Layer::is() const { + return type == Type::Symbol; +} + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/property_transition.hpp b/include/mbgl/style/property_transition.hpp deleted file mode 100644 index b9a301feea..0000000000 --- a/include/mbgl/style/property_transition.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include - -namespace mbgl { - -class PropertyTransition { -public: - PropertyTransition(const optional& duration_ = {}, const optional& delay_ = {}) - : duration(duration_), delay(delay_) {} - - optional duration; - optional delay; -}; - -} // namespace mbgl diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp new file mode 100644 index 0000000000..d8f83a0fb3 --- /dev/null +++ b/include/mbgl/style/property_value.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace style { + +class Undefined {}; + +template +class PropertyValue { +private: + using Value = variant>; + Value value; + +public: + PropertyValue() : value() {} + PropertyValue( T constant) : value(constant) {} + PropertyValue(Function function) : value(function) {} + + bool isUndefined() const { return value.which() == 0; } + bool isConstant() const { return value.which() == 1; } + bool isFunction() const { return value.which() == 2; } + + const T & asConstant() const { return value.template get< T >(); } + const Function& asFunction() const { return value.template get>(); } + + explicit operator bool() const { return !isUndefined(); }; + + template + static auto visit(const PropertyValue& value, Visitor&& visitor) { + return Value::visit(value.value, visitor); + } +}; + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/transition_options.hpp b/include/mbgl/style/transition_options.hpp new file mode 100644 index 0000000000..87faff21f8 --- /dev/null +++ b/include/mbgl/style/transition_options.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +namespace mbgl { +namespace style { + +class TransitionOptions { +public: + TransitionOptions(const optional& duration_ = {}, const optional& delay_ = {}) + : duration(duration_), delay(delay_) {} + + optional duration; + optional delay; +}; + +} // namespace style +} // namespace mbgl diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index 56f3570357..27b524a800 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -2,44 +2,9 @@ #include -#include -#include -#include -#include - namespace mbgl { -// Stores a premultiplied color, with all four channels ranging from 0..1 -using Color = std::array; - -// An array of font names -using FontStack = std::vector; - -std::string fontStackToString(const FontStack&); - -struct FontStackHash { - std::size_t operator()(const FontStack&) const; -}; - -template -class Function { -public: - using Stop = std::pair; - using Stops = std::vector; - - explicit Function(const Stops& stops_, float base_) - : base(base_), stops(stops_) {} - - float getBase() const { return base; } - const std::vector>& getStops() const { return stops; } - -private: - float base = 1; - std::vector> stops; -}; - -// ------------------------------------------------------------------------------------------------- - +// TODO: should be in public source.hpp header and style namespace enum class SourceType : uint8_t { Vector, Raster, @@ -56,7 +21,7 @@ MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, { { SourceType::Annotations, "annotations" }, }); -// ------------------------------------------------------------------------------------------------- +namespace style { enum class VisibilityType : bool { Visible, @@ -122,5 +87,5 @@ enum class TextTransformType : uint8_t { Lowercase, }; +} // namespace style } // namespace mbgl - diff --git a/include/mbgl/util/color.hpp b/include/mbgl/util/color.hpp new file mode 100644 index 0000000000..d7fe61c640 --- /dev/null +++ b/include/mbgl/util/color.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace mbgl { + +// Stores a premultiplied color, with all four channels ranging from 0..1 +using Color = std::array; + +} // namespace mbgl diff --git a/include/mbgl/util/font_stack.hpp b/include/mbgl/util/font_stack.hpp new file mode 100644 index 0000000000..d0b431e9ea --- /dev/null +++ b/include/mbgl/util/font_stack.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +namespace mbgl { + +// An array of font names +using FontStack = std::vector; + +std::string fontStackToString(const FontStack&); + +struct FontStackHash { + std::size_t operator()(const FontStack&) const; +}; + +} // namespace mbgl -- cgit v1.2.1