diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/style/conversion/light.hpp | 16 | ||||
-rw-r--r-- | include/mbgl/style/light.hpp | 72 | ||||
-rw-r--r-- | include/mbgl/style/light.hpp.ejs | 35 |
3 files changed, 77 insertions, 46 deletions
diff --git a/include/mbgl/style/conversion/light.hpp b/include/mbgl/style/conversion/light.hpp index 631ed04ccb..30bb906037 100644 --- a/include/mbgl/style/conversion/light.hpp +++ b/include/mbgl/style/conversion/light.hpp @@ -28,7 +28,7 @@ public: convert<PropertyValue<LightAnchorType>>(*anchor, error); if (convertedAnchor) { - light.get<LightAnchor>().value = *convertedAnchor; + light.setAnchor(*convertedAnchor); } else { return {}; } @@ -39,7 +39,7 @@ public: optional<TransitionOptions> transition = convert<TransitionOptions>(*anchorTransition, error); if (transition) { - light.get<LightAnchor>().transition = *transition; + light.setAnchorTransition(*transition); } else { return {}; } @@ -51,7 +51,7 @@ public: convert<PropertyValue<Color>>(*color, error); if (convertedColor) { - light.get<LightColor>().value = *convertedColor; + light.setColor(*convertedColor); } else { return {}; } @@ -62,7 +62,7 @@ public: optional<TransitionOptions> transition = convert<TransitionOptions>(*colorTransition, error); if (transition) { - light.get<LightColor>().transition = *transition; + light.setColorTransition(*transition); } else { return {}; } @@ -74,7 +74,7 @@ public: convert<PropertyValue<Position>>(*position, error); if (convertedPosition) { - light.get<LightPosition>().value = *convertedPosition; + light.setPosition(*convertedPosition); } else { return {}; } @@ -85,7 +85,7 @@ public: optional<TransitionOptions> transition = convert<TransitionOptions>(*positionTransition, error); if (transition) { - light.get<LightPosition>().transition = *transition; + light.setPositionTransition(*transition); } else { return {}; } @@ -97,7 +97,7 @@ public: convert<PropertyValue<float>>(*intensity, error); if (convertedIntensity) { - light.get<LightIntensity>().value = *convertedIntensity; + light.setIntensity(*convertedIntensity); } else { return {}; } @@ -108,7 +108,7 @@ public: optional<TransitionOptions> transition = convert<TransitionOptions>(*intensityTransition, error); if (transition) { - light.get<LightIntensity>().transition = *transition; + light.setIntensityTransition(*transition); } else { return {}; } diff --git a/include/mbgl/style/light.hpp b/include/mbgl/style/light.hpp index bec8e6ddeb..7942d0d237 100644 --- a/include/mbgl/style/light.hpp +++ b/include/mbgl/style/light.hpp @@ -1,52 +1,48 @@ -#pragma once +// This file is generated. Do not edit. +#pragma once #include <mbgl/style/property_value.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/style/types.hpp> -#include <mbgl/style/position.hpp> -#include <mbgl/util/color.hpp> -#include <mbgl/util/indexed_tuple.hpp> namespace mbgl { -namespace style { -template <class T> -class LightProperty { -public: - using Type = T; - using ValueType = PropertyValue<T>; +class RenderLight; - PropertyValue<T> value; - TransitionOptions transition; -}; - -struct LightAnchor : LightProperty<LightAnchorType> { - static LightAnchorType defaultValue() { - return LightAnchorType::Viewport; - } -}; - -struct LightPosition : LightProperty<Position> { - static Position defaultValue() { - std::array<float, 3> default_ = { { 1.15, 210, 30 } }; - return Position{ { default_ } }; - } -}; +namespace style { -struct LightColor : LightProperty<Color> { - static Color defaultValue() { - return Color::white(); - } -}; +class Light { +public: -struct LightIntensity : LightProperty<float> { - static float defaultValue() { - return 0.5; - } + static LightAnchorType getDefaultAnchor(); + PropertyValue<LightAnchorType> getAnchor() const; + void setAnchor(PropertyValue<LightAnchorType>); + void setAnchorTransition(const TransitionOptions&); + TransitionOptions getAnchorTransition() const; + + static Position getDefaultPosition(); + PropertyValue<Position> getPosition() const; + void setPosition(PropertyValue<Position>); + void setPositionTransition(const TransitionOptions&); + TransitionOptions getPositionTransition() const; + + static Color getDefaultColor(); + PropertyValue<Color> getColor() const; + void setColor(PropertyValue<Color>); + void setColorTransition(const TransitionOptions&); + TransitionOptions getColorTransition() const; + + static float getDefaultIntensity(); + PropertyValue<float> getIntensity() const; + void setIntensity(PropertyValue<float>); + void setIntensityTransition(const TransitionOptions&); + TransitionOptions getIntensityTransition() const; + +private: + IndexedTuple<LightProperties, LightProperties> properties; + + friend class mbgl::RenderLight; }; -using LightProperties = TypeList<LightAnchor, LightPosition, LightColor, LightIntensity>; -class Light : public IndexedTuple<LightProperties, LightProperties> {}; - } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/light.hpp.ejs b/include/mbgl/style/light.hpp.ejs new file mode 100644 index 0000000000..40f85b66b5 --- /dev/null +++ b/include/mbgl/style/light.hpp.ejs @@ -0,0 +1,35 @@ +<% + const properties = locals.properties; +-%> +// This file is generated. Do not edit. + +#pragma once +#include <mbgl/style/property_value.hpp> +#include <mbgl/style/transition_options.hpp> +#include <mbgl/style/types.hpp> + +namespace mbgl { + +class RenderLight; + +namespace style { + +class Light { +public: + +<% for (const property of properties) { -%> + static <%- evaluatedType(property) %> getDefault<%- camelize(property.name) %>(); + <%- propertyValueType(property) %> get<%- camelize(property.name) %>() const; + void set<%- camelize(property.name) %>(<%- propertyValueType(property) %>); + void set<%- camelize(property.name) %>Transition(const TransitionOptions&); + TransitionOptions get<%- camelize(property.name) %>Transition() const; + +<% } -%> +private: + IndexedTuple<LightProperties, LightProperties> properties; + + friend class mbgl::RenderLight; +}; + +} // namespace style +} // namespace mbgl |