From a7c3b8b6f589cbe78744ac5eb4e1c1b2214c0c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 26 May 2014 11:58:37 +0200 Subject: [PATCH] derive properties from a generic class --- include/llmr/style/properties.hpp | 96 ++++++++++--------------------- 1 file changed, 29 insertions(+), 67 deletions(-) diff --git a/include/llmr/style/properties.hpp b/include/llmr/style/properties.hpp index 616936ea8..f96c2cec9 100644 --- a/include/llmr/style/properties.hpp +++ b/include/llmr/style/properties.hpp @@ -84,16 +84,26 @@ struct FunctionProperty { template inline T evaluate(float z) const { return function(z, values); } }; -struct IconClass { +struct GenericClass { boost::optional enabled; boost::optional> translate; boost::optional translate_transition; boost::optional translateAnchor; + boost::optional opacity; + boost::optional opacity_transition; +}; + +struct GenericProperties { + bool enabled = true; + std::array translate = {{ 0, 0 }}; + TranslateAnchor translateAnchor = TranslateAnchor::Map; + float opacity = 1.0; +}; + +struct IconClass : public GenericClass { boost::optional size; boost::optional color; boost::optional color_transition; - boost::optional opacity; - boost::optional opacity_transition; boost::optional image; boost::optional radius; boost::optional radius_transition; @@ -101,23 +111,15 @@ struct IconClass { boost::optional blur_transition; }; -struct IconProperties { - bool enabled = true; - std::array translate = {{ 0, 0 }}; - TranslateAnchor translateAnchor = TranslateAnchor::Map; +struct IconProperties : public GenericProperties { float size = 0; Color color = {{ 1, 1, 1, 1 }}; - float opacity = 1.0; std::string image; float radius = 0; float blur = 0; }; -struct LineClass { - boost::optional enabled; - boost::optional> translate; - boost::optional translate_transition; - boost::optional translateAnchor; +struct LineClass : public GenericClass { boost::optional width; boost::optional width_transition; boost::optional offset; @@ -126,58 +128,40 @@ struct LineClass { boost::optional color_transition; boost::optional> dash_array; boost::optional dash_array_transition; - boost::optional opacity; - boost::optional opacity_transition; }; -struct LineProperties { - bool enabled = true; - std::array translate = {{ 0, 0 }}; - TranslateAnchor translateAnchor = TranslateAnchor::Map; +struct LineProperties : public GenericProperties { float width = 0; float offset = 0; Color color = {{ 0, 0, 0, 1 }}; std::array dash_array = {{ 1, -1 }}; - float opacity = 1.0; }; -struct FillClass { - boost::optional enabled; - boost::optional> translate; - boost::optional translate_transition; - boost::optional translateAnchor; +struct FillClass : public GenericClass { boost::optional winding; boost::optional antialias; boost::optional fill_color; boost::optional fill_color_transition; boost::optional stroke_color; boost::optional stroke_color_transition; - boost::optional opacity; - boost::optional opacity_transition; boost::optional image; boost::optional prerendered; boost::optional blur; }; -struct FillProperties { - bool enabled = true; - std::array translate = {{ 0, 0 }}; - TranslateAnchor translateAnchor = TranslateAnchor::Map; +struct FillProperties : public GenericProperties { Winding winding = Winding::NonZero; bool antialias = true; Color fill_color = {{ 0, 0, 0, 1 }}; Color stroke_color = {{ 0, 0, 0, 1 }}; - float opacity = 1.0; bool prerendered = false; + float prerenderBuffer = 1.0f / 32.0f; + uint16_t prerenderSize = 256; float blur = 0.0f; std::string image; }; -struct TextClass { - boost::optional enabled; - boost::optional> translate; - boost::optional translate_transition; - boost::optional translateAnchor; +struct TextClass : public GenericClass { boost::optional color; boost::optional color_transition; boost::optional halo; @@ -189,14 +173,9 @@ struct TextClass { boost::optional size; boost::optional rotate; boost::optional always_visible; - boost::optional opacity; - boost::optional opacity_transition; }; -struct TextProperties { - bool enabled = true; - std::array translate = {{ 0, 0 }}; - TranslateAnchor translateAnchor = TranslateAnchor::Map; +struct TextProperties : public GenericProperties { Color color = {{ 0, 0, 0, 1 }}; Color halo = {{ 1, 1, 1, 0.75 }}; float halo_radius = 0.25f; @@ -204,45 +183,28 @@ struct TextProperties { float size = 12.0f; float rotate = 0.0f; bool always_visible = false; - float opacity = 1.0; }; -struct BackgroundClass { +struct BackgroundClass : public GenericClass { boost::optional color; boost::optional color_transition; - boost::optional opacity; - boost::optional opacity_transition; }; -struct BackgroundProperties { +struct BackgroundProperties : public GenericProperties { Color color = {{ 1, 1, 1, 1 }}; - float opacity = 1.0; }; -struct RasterClass { - boost::optional enabled; - boost::optional> translate; - boost::optional translate_transition; - boost::optional opacity; - boost::optional opacity_transition; +struct RasterClass : public GenericClass { }; -struct RasterProperties { - bool enabled = true; - std::array translate = {{ 0, 0 }}; - float opacity = 1.0; +struct RasterProperties : public GenericProperties { }; -struct CompositeClass { - boost::optional enabled; - boost::optional opacity; - boost::optional opacity_transition; +struct CompositeClass : public GenericClass { }; -struct CompositeProperties { - inline CompositeProperties() {} - bool enabled = true; - float opacity = 1.0; +struct CompositeProperties : public GenericProperties { + inline CompositeProperties() : GenericProperties() {} };