[core] generated accessor methods on light

This commit is contained in:
Ivo van Dongen
2017-05-04 17:26:42 +03:00
committed by Ivo van Dongen
parent 20810f988a
commit feae5e22ee
11 changed files with 332 additions and 69 deletions

View File

@@ -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) {

View File

@@ -69,8 +69,6 @@ public:
using TransitioningLight = Transitioning<style::LightProperties>;
using EvaluatedLight = Evaluated<style::LightProperties>;
class Painter;
class RenderLight {
public:
RenderLight(const style::Light);

115
src/mbgl/style/light.cpp Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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