summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/fill_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/layers/fill_layer.cpp')
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 0511e06828..f35f62fb1d 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -90,58 +90,58 @@ TransitionOptions FillLayer::getFillAntialiasTransition() const {
return impl().paint.template get<FillAntialias>().options;
}
-PropertyValue<float> FillLayer::getDefaultFillOpacity() {
- return { 1 };
+PropertyValue<Color> FillLayer::getDefaultFillColor() {
+ return { Color::black() };
}
-const PropertyValue<float>& FillLayer::getFillOpacity() const {
- return impl().paint.template get<FillOpacity>().value;
+const PropertyValue<Color>& FillLayer::getFillColor() const {
+ return impl().paint.template get<FillColor>().value;
}
-void FillLayer::setFillOpacity(const PropertyValue<float>& value) {
- if (value == getFillOpacity())
+void FillLayer::setFillColor(const PropertyValue<Color>& value) {
+ if (value == getFillColor())
return;
auto impl_ = mutableImpl();
- impl_->paint.template get<FillOpacity>().value = value;
+ impl_->paint.template get<FillColor>().value = value;
baseImpl = std::move(impl_);
observer->onLayerChanged(*this);
}
-void FillLayer::setFillOpacityTransition(const TransitionOptions& options) {
+void FillLayer::setFillColorTransition(const TransitionOptions& options) {
auto impl_ = mutableImpl();
- impl_->paint.template get<FillOpacity>().options = options;
+ impl_->paint.template get<FillColor>().options = options;
baseImpl = std::move(impl_);
}
-TransitionOptions FillLayer::getFillOpacityTransition() const {
- return impl().paint.template get<FillOpacity>().options;
+TransitionOptions FillLayer::getFillColorTransition() const {
+ return impl().paint.template get<FillColor>().options;
}
-PropertyValue<Color> FillLayer::getDefaultFillColor() {
- return { Color::black() };
+PropertyValue<float> FillLayer::getDefaultFillOpacity() {
+ return { 1 };
}
-const PropertyValue<Color>& FillLayer::getFillColor() const {
- return impl().paint.template get<FillColor>().value;
+const PropertyValue<float>& FillLayer::getFillOpacity() const {
+ return impl().paint.template get<FillOpacity>().value;
}
-void FillLayer::setFillColor(const PropertyValue<Color>& value) {
- if (value == getFillColor())
+void FillLayer::setFillOpacity(const PropertyValue<float>& value) {
+ if (value == getFillOpacity())
return;
auto impl_ = mutableImpl();
- impl_->paint.template get<FillColor>().value = value;
+ impl_->paint.template get<FillOpacity>().value = value;
baseImpl = std::move(impl_);
observer->onLayerChanged(*this);
}
-void FillLayer::setFillColorTransition(const TransitionOptions& options) {
+void FillLayer::setFillOpacityTransition(const TransitionOptions& options) {
auto impl_ = mutableImpl();
- impl_->paint.template get<FillColor>().options = options;
+ impl_->paint.template get<FillOpacity>().options = options;
baseImpl = std::move(impl_);
}
-TransitionOptions FillLayer::getFillColorTransition() const {
- return impl().paint.template get<FillColor>().options;
+TransitionOptions FillLayer::getFillOpacityTransition() const {
+ return impl().paint.template get<FillOpacity>().options;
}
PropertyValue<Color> FillLayer::getDefaultFillOutlineColor() {
@@ -171,6 +171,33 @@ TransitionOptions FillLayer::getFillOutlineColorTransition() const {
return impl().paint.template get<FillOutlineColor>().options;
}
+PropertyValue<std::string> FillLayer::getDefaultFillPattern() {
+ return { "" };
+}
+
+const PropertyValue<std::string>& FillLayer::getFillPattern() const {
+ return impl().paint.template get<FillPattern>().value;
+}
+
+void FillLayer::setFillPattern(const PropertyValue<std::string>& value) {
+ if (value == getFillPattern())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<FillPattern>().value = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void FillLayer::setFillPatternTransition(const TransitionOptions& options) {
+ auto impl_ = mutableImpl();
+ impl_->paint.template get<FillPattern>().options = options;
+ baseImpl = std::move(impl_);
+}
+
+TransitionOptions FillLayer::getFillPatternTransition() const {
+ return impl().paint.template get<FillPattern>().options;
+}
+
PropertyValue<std::array<float, 2>> FillLayer::getDefaultFillTranslate() {
return { {{ 0, 0 }} };
}
@@ -225,68 +252,41 @@ TransitionOptions FillLayer::getFillTranslateAnchorTransition() const {
return impl().paint.template get<FillTranslateAnchor>().options;
}
-PropertyValue<std::string> FillLayer::getDefaultFillPattern() {
- return { "" };
-}
-
-const PropertyValue<std::string>& FillLayer::getFillPattern() const {
- return impl().paint.template get<FillPattern>().value;
-}
-
-void FillLayer::setFillPattern(const PropertyValue<std::string>& value) {
- if (value == getFillPattern())
- return;
- auto impl_ = mutableImpl();
- impl_->paint.template get<FillPattern>().value = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void FillLayer::setFillPatternTransition(const TransitionOptions& options) {
- auto impl_ = mutableImpl();
- impl_->paint.template get<FillPattern>().options = options;
- baseImpl = std::move(impl_);
-}
-
-TransitionOptions FillLayer::getFillPatternTransition() const {
- return impl().paint.template get<FillPattern>().options;
-}
-
using namespace conversion;
optional<Error> FillLayer::setPaintProperty(const std::string& name, const Convertible& value) {
enum class Property : uint8_t {
FillAntialias,
- FillOpacity,
FillColor,
+ FillOpacity,
FillOutlineColor,
+ FillPattern,
FillTranslate,
FillTranslateAnchor,
- FillPattern,
FillAntialiasTransition,
- FillOpacityTransition,
FillColorTransition,
+ FillOpacityTransition,
FillOutlineColorTransition,
+ FillPatternTransition,
FillTranslateTransition,
FillTranslateAnchorTransition,
- FillPatternTransition,
};
MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>({
{ "fill-antialias", static_cast<uint8_t>(Property::FillAntialias) },
- { "fill-opacity", static_cast<uint8_t>(Property::FillOpacity) },
{ "fill-color", static_cast<uint8_t>(Property::FillColor) },
+ { "fill-opacity", static_cast<uint8_t>(Property::FillOpacity) },
{ "fill-outline-color", static_cast<uint8_t>(Property::FillOutlineColor) },
+ { "fill-pattern", static_cast<uint8_t>(Property::FillPattern) },
{ "fill-translate", static_cast<uint8_t>(Property::FillTranslate) },
{ "fill-translate-anchor", static_cast<uint8_t>(Property::FillTranslateAnchor) },
- { "fill-pattern", static_cast<uint8_t>(Property::FillPattern) },
{ "fill-antialias-transition", static_cast<uint8_t>(Property::FillAntialiasTransition) },
- { "fill-opacity-transition", static_cast<uint8_t>(Property::FillOpacityTransition) },
{ "fill-color-transition", static_cast<uint8_t>(Property::FillColorTransition) },
+ { "fill-opacity-transition", static_cast<uint8_t>(Property::FillOpacityTransition) },
{ "fill-outline-color-transition", static_cast<uint8_t>(Property::FillOutlineColorTransition) },
+ { "fill-pattern-transition", static_cast<uint8_t>(Property::FillPatternTransition) },
{ "fill-translate-transition", static_cast<uint8_t>(Property::FillTranslateTransition) },
- { "fill-translate-anchor-transition", static_cast<uint8_t>(Property::FillTranslateAnchorTransition) },
- { "fill-pattern-transition", static_cast<uint8_t>(Property::FillPatternTransition) }
+ { "fill-translate-anchor-transition", static_cast<uint8_t>(Property::FillTranslateAnchorTransition) }
});
const auto it = properties.find(name.c_str());
@@ -309,18 +309,6 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
}
- if (property == Property::FillOpacity) {
- Error error;
- optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
- if (!typedValue) {
- return error;
- }
-
- setFillOpacity(*typedValue);
- return nullopt;
-
- }
-
if (property == Property::FillColor || property == Property::FillOutlineColor) {
Error error;
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
@@ -340,38 +328,50 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
}
- if (property == Property::FillTranslate) {
+ if (property == Property::FillOpacity) {
Error error;
- optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
+ optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
if (!typedValue) {
return error;
}
- setFillTranslate(*typedValue);
+ setFillOpacity(*typedValue);
return nullopt;
}
- if (property == Property::FillTranslateAnchor) {
+ if (property == Property::FillPattern) {
Error error;
- optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
+ optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, true, false);
if (!typedValue) {
return error;
}
- setFillTranslateAnchor(*typedValue);
+ setFillPattern(*typedValue);
return nullopt;
}
- if (property == Property::FillPattern) {
+ if (property == Property::FillTranslate) {
Error error;
- optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, true, false);
+ optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
if (!typedValue) {
return error;
}
- setFillPattern(*typedValue);
+ setFillTranslate(*typedValue);
+ return nullopt;
+
+ }
+
+ if (property == Property::FillTranslateAnchor) {
+ Error error;
+ optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setFillTranslateAnchor(*typedValue);
return nullopt;
}
@@ -388,13 +388,13 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
return nullopt;
}
- if (property == Property::FillOpacityTransition) {
- setFillOpacityTransition(*transition);
+ if (property == Property::FillColorTransition) {
+ setFillColorTransition(*transition);
return nullopt;
}
- if (property == Property::FillColorTransition) {
- setFillColorTransition(*transition);
+ if (property == Property::FillOpacityTransition) {
+ setFillOpacityTransition(*transition);
return nullopt;
}
@@ -403,6 +403,11 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
return nullopt;
}
+ if (property == Property::FillPatternTransition) {
+ setFillPatternTransition(*transition);
+ return nullopt;
+ }
+
if (property == Property::FillTranslateTransition) {
setFillTranslateTransition(*transition);
return nullopt;
@@ -413,11 +418,6 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve
return nullopt;
}
- if (property == Property::FillPatternTransition) {
- setFillPatternTransition(*transition);
- return nullopt;
- }
-
return Error { "layer doesn't support this property" };
}