summaryrefslogtreecommitdiff
path: root/include/mbgl/style
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-06-15 18:30:39 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-06-15 18:30:39 -0700
commitbd0bf294bf1e350b184e54a824430c911dd66b9b (patch)
treed7c643cf197a8263fb1880ce73d034da253efe4c /include/mbgl/style
parente75e538ddbb1dad0baad02576df86f6b8eb1510f (diff)
downloadqtlocation-mapboxgl-bd0bf294bf1e350b184e54a824430c911dd66b9b.tar.gz
squash of #1655: shape annotations support for core & iOS
Diffstat (limited to 'include/mbgl/style')
-rw-r--r--include/mbgl/style/style_properties.hpp114
-rw-r--r--include/mbgl/style/types.hpp210
2 files changed, 324 insertions, 0 deletions
diff --git a/include/mbgl/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp
new file mode 100644
index 0000000000..9ab528586f
--- /dev/null
+++ b/include/mbgl/style/style_properties.hpp
@@ -0,0 +1,114 @@
+#ifndef MBGL_STYLE_STYLE_PROPERTIES
+#define MBGL_STYLE_STYLE_PROPERTIES
+
+#include <mbgl/util/variant.hpp>
+#include <mbgl/style/types.hpp>
+
+#include <array>
+#include <string>
+#include <type_traits>
+#include <memory>
+#include <vector>
+
+namespace mbgl {
+
+struct FillProperties {
+ FillProperties() {}
+ 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);
+ }
+};
+
+struct LineProperties {
+ inline LineProperties() {}
+ 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;
+ }
+};
+
+struct SymbolProperties {
+ inline SymbolProperties() {}
+
+ 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);
+ }
+};
+
+struct RasterProperties {
+ inline RasterProperties() {}
+ 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;
+ }
+};
+
+struct BackgroundProperties {
+ inline BackgroundProperties() {}
+ float opacity = 1.0f;
+ Color color = {{ 0, 0, 0, 1 }};
+ Faded<std::string> image;
+};
+
+typedef mapbox::util::variant<
+ FillProperties,
+ LineProperties,
+ SymbolProperties,
+ RasterProperties,
+ BackgroundProperties,
+ std::false_type
+> StyleProperties;
+
+template <typename T>
+const T &defaultStyleProperties();
+
+}
+
+#endif
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
new file mode 100644
index 0000000000..f6ffcd6865
--- /dev/null
+++ b/include/mbgl/style/types.hpp
@@ -0,0 +1,210 @@
+#ifndef MBGL_STYLE_TYPES
+#define MBGL_STYLE_TYPES
+
+#include <mbgl/util/enum.hpp>
+
+#include <string>
+#include <array>
+
+namespace mbgl {
+
+// Stores a premultiplied color, with all four channels ranging from 0..1
+typedef std::array<float, 4> Color;
+
+
+template <typename T>
+struct Faded {
+ T from;
+ float fromScale;
+ T to;
+ float toScale;
+ float t;
+};
+
+// -------------------------------------------------------------------------------------------------
+
+enum class StyleLayerType : uint8_t {
+ Unknown,
+ Fill,
+ Line,
+ Symbol,
+ Raster,
+ Background
+};
+
+MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, {
+ { StyleLayerType::Unknown, "unknown" },
+ { StyleLayerType::Fill, "fill" },
+ { StyleLayerType::Line, "line" },
+ { StyleLayerType::Symbol, "symbol" },
+ { StyleLayerType::Raster, "raster" },
+ { StyleLayerType::Background, "background" },
+ { StyleLayerType(-1), "unknown" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class SourceType : uint8_t {
+ Vector,
+ Raster,
+ GeoJSON,
+ Video,
+ Annotations
+};
+
+MBGL_DEFINE_ENUM_CLASS(SourceTypeClass, SourceType, {
+ { SourceType::Vector, "vector" },
+ { SourceType::Raster, "raster" },
+ { SourceType::GeoJSON, "geojson" },
+ { SourceType::Video, "video" },
+ { SourceType::Annotations, "annotations" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class VisibilityType : bool {
+ Visible,
+ None,
+};
+
+MBGL_DEFINE_ENUM_CLASS(VisibilityTypeClass, VisibilityType, {
+ { VisibilityType::Visible, "visible" },
+ { VisibilityType::None, "none" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class CapType : uint8_t {
+ Round,
+ Butt,
+ Square,
+};
+
+MBGL_DEFINE_ENUM_CLASS(CapTypeClass, CapType, {
+ { CapType::Round, "round" },
+ { CapType::Butt, "butt" },
+ { CapType::Square, "square" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class JoinType : uint8_t {
+ Miter,
+ Bevel,
+ Round,
+ FlipBevel
+};
+
+MBGL_DEFINE_ENUM_CLASS(JoinTypeClass, JoinType, {
+ { JoinType::Miter, "miter" },
+ { JoinType::Bevel, "bevel" },
+ { JoinType::Round, "round" },
+ { JoinType::FlipBevel, "flipbevel" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TranslateAnchorType : bool {
+ Map,
+ Viewport
+};
+
+MBGL_DEFINE_ENUM_CLASS(TranslateAnchorTypeClass, TranslateAnchorType, {
+ { TranslateAnchorType::Map, "map" },
+ { TranslateAnchorType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class RotateAnchorType : bool {
+ Map,
+ Viewport,
+};
+
+MBGL_DEFINE_ENUM_CLASS(RotateAnchorTypeClass, RotateAnchorType, {
+ { RotateAnchorType::Map, "map" },
+ { RotateAnchorType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class PlacementType : bool {
+ Point,
+ Line,
+};
+
+MBGL_DEFINE_ENUM_CLASS(PlacementTypeClass, PlacementType, {
+ { PlacementType::Point, "point" },
+ { PlacementType::Line, "line" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class RotationAlignmentType : bool {
+ Map,
+ Viewport,
+};
+
+MBGL_DEFINE_ENUM_CLASS(RotationAlignmentTypeClass, RotationAlignmentType, {
+ { RotationAlignmentType::Map, "map" },
+ { RotationAlignmentType::Viewport, "viewport" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextJustifyType : uint8_t {
+ Center,
+ Left,
+ Right
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextJustifyTypeClass, TextJustifyType, {
+ { TextJustifyType::Center, "center" },
+ { TextJustifyType::Left, "left" },
+ { TextJustifyType::Right, "right" },
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextAnchorType : uint8_t {
+ Center,
+ Left,
+ Right,
+ Top,
+ Bottom,
+ TopLeft,
+ TopRight,
+ BottomLeft,
+ BottomRight
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, {
+ { TextAnchorType::Center, "center" },
+ { TextAnchorType::Left, "left" },
+ { TextAnchorType::Right, "right" },
+ { TextAnchorType::Top, "top" },
+ { TextAnchorType::Bottom, "bottom" },
+ { TextAnchorType::TopLeft, "top-left" },
+ { TextAnchorType::TopRight, "top-right" },
+ { TextAnchorType::BottomLeft, "bottom-left" },
+ { TextAnchorType::BottomRight, "bottom-right" }
+});
+
+// -------------------------------------------------------------------------------------------------
+
+enum class TextTransformType : uint8_t {
+ None,
+ Uppercase,
+ Lowercase,
+};
+
+MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
+ { TextTransformType::None, "none" },
+ { TextTransformType::Uppercase, "uppercase" },
+ { TextTransformType::Lowercase, "lowercase" },
+});
+
+}
+
+#endif
+