[core] generated accessor methods on light
This commit is contained in:
committed by
Ivo van Dongen
parent
20810f988a
commit
feae5e22ee
@@ -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 {};
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
class RenderLight;
|
||||
|
||||
namespace style {
|
||||
|
||||
template <class T>
|
||||
class LightProperty {
|
||||
class Light {
|
||||
public:
|
||||
using Type = T;
|
||||
using ValueType = PropertyValue<T>;
|
||||
|
||||
PropertyValue<T> value;
|
||||
TransitionOptions transition;
|
||||
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;
|
||||
};
|
||||
|
||||
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>;
|
||||
class Light : public IndexedTuple<LightProperties, LightProperties> {};
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
35
include/mbgl/style/light.hpp.ejs
Normal file
35
include/mbgl/style/light.hpp.ejs
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user