summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-05-04 17:26:42 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-05-08 19:39:55 +0300
commitfeae5e22ee4910a1508f2120c8131b2f8531bae8 (patch)
treeb5ca0ba87b42bcc732070485b5ccea2c3f832840 /src
parent20810f988a735e0d43f9abff9260ea0784cd218c (diff)
downloadqtlocation-mapboxgl-feae5e22ee4910a1508f2120c8131b2f8531bae8.tar.gz
[core] generated accessor methods on light
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/render_light.cpp2
-rw-r--r--src/mbgl/renderer/render_light.hpp2
-rw-r--r--src/mbgl/style/light.cpp115
-rw-r--r--src/mbgl/style/light.cpp.ejs42
-rw-r--r--src/mbgl/style/light_properties.hpp51
5 files changed, 209 insertions, 3 deletions
diff --git a/src/mbgl/renderer/render_light.cpp b/src/mbgl/renderer/render_light.cpp
index 6f154de2e2..faf89bf9e2 100644
--- a/src/mbgl/renderer/render_light.cpp
+++ b/src/mbgl/renderer/render_light.cpp
@@ -7,7 +7,7 @@ RenderLight::RenderLight(const style::Light light_)
}
void RenderLight::transition(const CascadeParameters& parameters) {
- transitioning = TransitioningLight(light, std::move(transitioning), parameters);
+ transitioning = TransitioningLight(light.properties, std::move(transitioning), parameters);
}
void RenderLight::evaluate(const PropertyEvaluationParameters& parameters) {
diff --git a/src/mbgl/renderer/render_light.hpp b/src/mbgl/renderer/render_light.hpp
index e609550445..1a813ab1f8 100644
--- a/src/mbgl/renderer/render_light.hpp
+++ b/src/mbgl/renderer/render_light.hpp
@@ -69,8 +69,6 @@ public:
using TransitioningLight = Transitioning<style::LightProperties>;
using EvaluatedLight = Evaluated<style::LightProperties>;
-class Painter;
-
class RenderLight {
public:
RenderLight(const style::Light);
diff --git a/src/mbgl/style/light.cpp b/src/mbgl/style/light.cpp
new file mode 100644
index 0000000000..0a9cbbee9a
--- /dev/null
+++ b/src/mbgl/style/light.cpp
@@ -0,0 +1,115 @@
+// This file is generated. Do not edit.
+
+#include <mbgl/style/light.hpp>
+#include <mbgl/style/light_impl.hpp>
+#include <mbgl/style/light_properties.hpp>
+
+namespace mbgl {
+namespace style {
+
+LightAnchorType Light::getDefaultAnchor() {
+ return LightAnchor::defaultValue();
+}
+
+PropertyValue<LightAnchorType> Light::getAnchor() const {
+ return properties.get<LightAnchor>().value;
+}
+
+void Light::setAnchor(PropertyValue<LightAnchorType> property) {
+ properties.get<LightAnchor>().value = property;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+void Light::setAnchorTransition(const TransitionOptions& transition) {
+ properties.get<LightAnchor>().transition = transition;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+TransitionOptions Light::getAnchorTransition() const {
+ return properties.get<LightAnchor>().transition;
+}
+
+Position Light::getDefaultPosition() {
+ return LightPosition::defaultValue();
+}
+
+PropertyValue<Position> Light::getPosition() const {
+ return properties.get<LightPosition>().value;
+}
+
+void Light::setPosition(PropertyValue<Position> property) {
+ properties.get<LightPosition>().value = property;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+void Light::setPositionTransition(const TransitionOptions& transition) {
+ properties.get<LightPosition>().transition = transition;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+TransitionOptions Light::getPositionTransition() const {
+ return properties.get<LightPosition>().transition;
+}
+
+Color Light::getDefaultColor() {
+ return LightColor::defaultValue();
+}
+
+PropertyValue<Color> Light::getColor() const {
+ return properties.get<LightColor>().value;
+}
+
+void Light::setColor(PropertyValue<Color> property) {
+ properties.get<LightColor>().value = property;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+void Light::setColorTransition(const TransitionOptions& transition) {
+ properties.get<LightColor>().transition = transition;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+TransitionOptions Light::getColorTransition() const {
+ return properties.get<LightColor>().transition;
+}
+
+float Light::getDefaultIntensity() {
+ return LightIntensity::defaultValue();
+}
+
+PropertyValue<float> Light::getIntensity() const {
+ return properties.get<LightIntensity>().value;
+}
+
+void Light::setIntensity(PropertyValue<float> property) {
+ properties.get<LightIntensity>().value = property;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+void Light::setIntensityTransition(const TransitionOptions& transition) {
+ properties.get<LightIntensity>().transition = transition;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+TransitionOptions Light::getIntensityTransition() const {
+ return properties.get<LightIntensity>().transition;
+}
+
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/light.cpp.ejs b/src/mbgl/style/light.cpp.ejs
new file mode 100644
index 0000000000..7d2e0ecc1e
--- /dev/null
+++ b/src/mbgl/style/light.cpp.ejs
@@ -0,0 +1,42 @@
+<%
+ const properties = locals.properties;
+-%>
+// This file is generated. Do not edit.
+
+#include <mbgl/style/light.hpp>
+#include <mbgl/style/light_impl.hpp>
+#include <mbgl/style/light_properties.hpp>
+
+namespace mbgl {
+namespace style {
+
+<% for (const property of properties) { -%>
+<%- evaluatedType(property) %> Light::getDefault<%- camelize(property.name) %>() {
+ return Light<%- camelize(property.name) %>::defaultValue();
+}
+
+<%- propertyValueType(property) %> Light::get<%- camelize(property.name) %>() const {
+ return properties.get<Light<%- camelize(property.name) %>>().value;
+}
+
+void Light::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> property) {
+ properties.get<Light<%- camelize(property.name) %>>().value = property;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+void Light::set<%- camelize(property.name) %>Transition(const TransitionOptions& transition) {
+ properties.get<Light<%- camelize(property.name) %>>().transition = transition;
+ if (observer) {
+ observer->onLightChanged(*this);
+ }
+}
+
+TransitionOptions Light::get<%- camelize(property.name) %>Transition() const {
+ return properties.get<Light<%- camelize(property.name) %>>().transition;
+}
+
+<% } -%>
+} // namespace style
+} // namespace mbgl
diff --git a/src/mbgl/style/light_properties.hpp b/src/mbgl/style/light_properties.hpp
new file mode 100644
index 0000000000..9f6088a633
--- /dev/null
+++ b/src/mbgl/style/light_properties.hpp
@@ -0,0 +1,51 @@
+#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>;
+
+ 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_ } };
+ }
+};
+
+struct LightColor : LightProperty<Color> {
+ static Color defaultValue() {
+ return Color::white();
+ }
+};
+
+struct LightIntensity : LightProperty<float> {
+ static float defaultValue() {
+ return 0.5;
+ }
+};
+
+using LightProperties = TypeList<LightAnchor, LightPosition, LightColor, LightIntensity>;
+
+} // namespace style
+} // namespace mbgl