From feae5e22ee4910a1508f2120c8131b2f8531bae8 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Thu, 4 May 2017 17:26:42 +0300 Subject: [core] generated accessor methods on light --- include/mbgl/style/conversion/light.hpp | 16 ++++---- include/mbgl/style/light.hpp | 72 ++++++++++++++++----------------- include/mbgl/style/light.hpp.ejs | 35 ++++++++++++++++ 3 files changed, 77 insertions(+), 46 deletions(-) create mode 100644 include/mbgl/style/light.hpp.ejs (limited to 'include/mbgl/style') 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>(*anchor, error); if (convertedAnchor) { - light.get().value = *convertedAnchor; + light.setAnchor(*convertedAnchor); } else { return {}; } @@ -39,7 +39,7 @@ public: optional transition = convert(*anchorTransition, error); if (transition) { - light.get().transition = *transition; + light.setAnchorTransition(*transition); } else { return {}; } @@ -51,7 +51,7 @@ public: convert>(*color, error); if (convertedColor) { - light.get().value = *convertedColor; + light.setColor(*convertedColor); } else { return {}; } @@ -62,7 +62,7 @@ public: optional transition = convert(*colorTransition, error); if (transition) { - light.get().transition = *transition; + light.setColorTransition(*transition); } else { return {}; } @@ -74,7 +74,7 @@ public: convert>(*position, error); if (convertedPosition) { - light.get().value = *convertedPosition; + light.setPosition(*convertedPosition); } else { return {}; } @@ -85,7 +85,7 @@ public: optional transition = convert(*positionTransition, error); if (transition) { - light.get().transition = *transition; + light.setPositionTransition(*transition); } else { return {}; } @@ -97,7 +97,7 @@ public: convert>(*intensity, error); if (convertedIntensity) { - light.get().value = *convertedIntensity; + light.setIntensity(*convertedIntensity); } else { return {}; } @@ -108,7 +108,7 @@ public: optional transition = convert(*intensityTransition, error); if (transition) { - light.get().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 #include #include -#include -#include -#include namespace mbgl { -namespace style { -template -class LightProperty { -public: - using Type = T; - using ValueType = PropertyValue; +class RenderLight; - PropertyValue value; - TransitionOptions transition; -}; - -struct LightAnchor : LightProperty { - static LightAnchorType defaultValue() { - return LightAnchorType::Viewport; - } -}; - -struct LightPosition : LightProperty { - static Position defaultValue() { - std::array default_ = { { 1.15, 210, 30 } }; - return Position{ { default_ } }; - } -}; +namespace style { -struct LightColor : LightProperty { - static Color defaultValue() { - return Color::white(); - } -}; +class Light { +public: -struct LightIntensity : LightProperty { - static float defaultValue() { - return 0.5; - } + static LightAnchorType getDefaultAnchor(); + PropertyValue getAnchor() const; + void setAnchor(PropertyValue); + void setAnchorTransition(const TransitionOptions&); + TransitionOptions getAnchorTransition() const; + + static Position getDefaultPosition(); + PropertyValue getPosition() const; + void setPosition(PropertyValue); + void setPositionTransition(const TransitionOptions&); + TransitionOptions getPositionTransition() const; + + static Color getDefaultColor(); + PropertyValue getColor() const; + void setColor(PropertyValue); + void setColorTransition(const TransitionOptions&); + TransitionOptions getColorTransition() const; + + static float getDefaultIntensity(); + PropertyValue getIntensity() const; + void setIntensity(PropertyValue); + void setIntensityTransition(const TransitionOptions&); + TransitionOptions getIntensityTransition() const; + +private: + IndexedTuple properties; + + friend class mbgl::RenderLight; }; -using LightProperties = TypeList; -class Light : public IndexedTuple {}; - } // 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 +#include +#include + +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 properties; + + friend class mbgl::RenderLight; +}; + +} // namespace style +} // namespace mbgl -- cgit v1.2.1