diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-10-26 15:12:43 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-11-10 11:33:17 -0800 |
commit | 54e08b1f83504e12cbc19b08295d9f9ed5177ab5 (patch) | |
tree | 40513395d4d0ed2d9003ef30a708f21b2e83e5ab /include | |
parent | a5625675890213f94de7632d4ef152ade627c9a5 (diff) | |
download | qtlocation-mapboxgl-54e08b1f83504e12cbc19b08295d9f9ed5177ab5.tar.gz |
[core] Eliminate use of ClassProperties for paint
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/annotation/shape_annotation.hpp | 20 | ||||
-rw-r--r-- | include/mbgl/style/style_properties.hpp | 116 | ||||
-rw-r--r-- | include/mbgl/style/types.hpp | 3 |
3 files changed, 19 insertions, 120 deletions
diff --git a/include/mbgl/annotation/shape_annotation.hpp b/include/mbgl/annotation/shape_annotation.hpp index 90f2a96dd0..b220ef50cb 100644 --- a/include/mbgl/annotation/shape_annotation.hpp +++ b/include/mbgl/annotation/shape_annotation.hpp @@ -2,7 +2,7 @@ #define MBGL_ANNOTATION_SHAPE_ANNOTATION #include <mbgl/annotation/annotation.hpp> -#include <mbgl/style/style_properties.hpp> +#include <mbgl/style/types.hpp> #include <mbgl/util/geo.hpp> @@ -13,12 +13,24 @@ namespace mbgl { using AnnotationSegment = std::vector<LatLng>; using AnnotationSegments = std::vector<AnnotationSegment>; +struct FillAnnotationProperties { + float opacity = 1; + Color color = {{ 0, 0, 0, 1 }}; + Color outlineColor = {{ 0, 0, 0, -1 }}; +}; + +struct LineAnnotationProperties { + float opacity = 1; + float width = 1; + Color color = {{ 0, 0, 0, 1 }}; +}; + class ShapeAnnotation { public: using Properties = mapbox::util::variant< - FillPaintProperties, // creates a fill annotation - LinePaintProperties, // creates a line annotation - std::string>; // creates an annotation whose type and properties are sourced from a style layer + FillAnnotationProperties, // creates a fill annotation + LineAnnotationProperties, // creates a line annotation + std::string>; // creates an annotation whose type and properties are sourced from a style layer ShapeAnnotation(const AnnotationSegments& segments_, const Properties& properties_) : segments(segments_), properties(properties_) { diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp deleted file mode 100644 index 2571a77d94..0000000000 --- a/include/mbgl/style/style_properties.hpp +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef MBGL_STYLE_STYLE_PROPERTIES -#define MBGL_STYLE_STYLE_PROPERTIES - -#include <mbgl/style/types.hpp> - -#include <array> -#include <string> -#include <vector> - -namespace mbgl { - -class FillPaintProperties { -public: - bool antialias = true; - float opacity = 1.0f; - Color fill_color = {{ 0, 0, 0, 1 }}; - Color stroke_color = {{ 0, 0, 0, -1 }}; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - Faded<std::string> image; - - inline bool isVisible() const { - return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0); - } -}; - -class LinePaintProperties { -public: - float opacity = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - float width = 1; - float gap_width = 0; - float blur = 0; - Faded<std::vector<float>> dash_array; - float dash_line_width = 1; - Faded<std::string> image; - - inline bool isVisible() const { - return opacity > 0 && color[3] > 0 && width > 0; - } -}; - -class SymbolPaintProperties { -public: - struct { - float opacity = 1.0f; - float size = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - Color halo_color = {{ 0, 0, 0, 0 }}; - float halo_width = 0.0f; - float halo_blur = 0.0f; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translate_anchor = TranslateAnchorType::Map; - } icon; - - struct { - float opacity = 1.0f; - float size = 16.0f; - Color color = {{ 0, 0, 0, 1 }}; - Color halo_color = {{ 0, 0, 0, 0 }}; - float halo_width = 0.0f; - float halo_blur = 0.0f; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translate_anchor = TranslateAnchorType::Map; - } text; - - inline bool isVisible() const { - return (icon.opacity > 0 && (icon.color[3] > 0 || icon.halo_color[3] > 0) && icon.size > 0) || - (text.opacity > 0 && (text.color[3] > 0 || text.halo_color[3] > 0) && text.size > 0); - } -}; - -class CirclePaintProperties { -public: - float radius = 5.0f; - Color color = {{ 0, 0, 0, 1 }}; - float opacity = 1.0f; - std::array<float, 2> translate = {{ 0, 0 }}; - TranslateAnchorType translateAnchor = TranslateAnchorType::Map; - float blur = 0; - - inline bool isVisible() const { - return radius > 0 && color[3] > 0 && opacity > 0; - } -}; - -class RasterPaintProperties { -public: - float opacity = 1.0f; - float hue_rotate = 0.0f; - std::array<float, 2> brightness = {{ 0, 1 }}; - float saturation = 0.0f; - float contrast = 0.0f; - float fade = 0.0f; - - inline bool isVisible() const { - return opacity > 0; - } -}; - -class BackgroundPaintProperties { -public: - float opacity = 1.0f; - Color color = {{ 0, 0, 0, 1 }}; - Faded<std::string> image; - - inline bool isVisible() const { - return opacity > 0; - } -}; - -} - -#endif diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index adc13b386c..c3e8470886 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -14,6 +14,9 @@ typedef std::array<float, 4> Color; template <typename T> struct Faded { + Faded() = default; + Faded(const T& v) : to(v) {} + T from; float fromScale; T to; |