// clang-format off // This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`. #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { namespace style { // static const LayerTypeInfo* FillLayer::Impl::staticTypeInfo() noexcept { const static LayerTypeInfo typeInfo{"fill", LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::Required, LayerTypeInfo::FadingTiles::NotRequired, LayerTypeInfo::CrossTileIndex::NotRequired, LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } FillLayer::FillLayer(Immutable impl_) : Layer(std::move(impl_)) { } FillLayer::~FillLayer() = default; const FillLayer::Impl& FillLayer::impl() const { return static_cast(*baseImpl); } Mutable FillLayer::mutableImpl() const { return makeMutable(impl()); } std::unique_ptr FillLayer::cloneRef(const std::string& id_) const { auto impl_ = mutableImpl(); impl_->id = id_; impl_->paint = FillPaintProperties::Transitionable(); return std::make_unique(std::move(impl_)); } void FillLayer::Impl::stringifyLayout(rapidjson::Writer& writer) const { layout.stringify(writer); } // Layout properties PropertyValue FillLayer::getDefaultFillSortKey() { return FillSortKey::defaultValue(); } const PropertyValue& FillLayer::getFillSortKey() const { return impl().layout.get(); } void FillLayer::setFillSortKey(const PropertyValue& value) { if (value == getFillSortKey()) return; auto impl_ = mutableImpl(); impl_->layout.get() = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } // Paint properties PropertyValue FillLayer::getDefaultFillAntialias() { return {true}; } const PropertyValue& FillLayer::getFillAntialias() const { return impl().paint.template get().value; } void FillLayer::setFillAntialias(const PropertyValue& value) { if (value == getFillAntialias()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillAntialiasTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillAntialiasTransition() const { return impl().paint.template get().options; } PropertyValue FillLayer::getDefaultFillColor() { return {Color::black()}; } const PropertyValue& FillLayer::getFillColor() const { return impl().paint.template get().value; } void FillLayer::setFillColor(const PropertyValue& value) { if (value == getFillColor()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillColorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillColorTransition() const { return impl().paint.template get().options; } PropertyValue FillLayer::getDefaultFillOpacity() { return {1}; } const PropertyValue& FillLayer::getFillOpacity() const { return impl().paint.template get().value; } void FillLayer::setFillOpacity(const PropertyValue& value) { if (value == getFillOpacity()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillOpacityTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillOpacityTransition() const { return impl().paint.template get().options; } PropertyValue FillLayer::getDefaultFillOutlineColor() { return {{}}; } const PropertyValue& FillLayer::getFillOutlineColor() const { return impl().paint.template get().value; } void FillLayer::setFillOutlineColor(const PropertyValue& value) { if (value == getFillOutlineColor()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillOutlineColorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillOutlineColorTransition() const { return impl().paint.template get().options; } PropertyValue FillLayer::getDefaultFillPattern() { return {{}}; } const PropertyValue& FillLayer::getFillPattern() const { return impl().paint.template get().value; } void FillLayer::setFillPattern(const PropertyValue& value) { if (value == getFillPattern()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillPatternTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillPatternTransition() const { return impl().paint.template get().options; } PropertyValue> FillLayer::getDefaultFillTranslate() { return {{{0, 0}}}; } const PropertyValue>& FillLayer::getFillTranslate() const { return impl().paint.template get().value; } void FillLayer::setFillTranslate(const PropertyValue>& value) { if (value == getFillTranslate()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillTranslateTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillTranslateTransition() const { return impl().paint.template get().options; } PropertyValue FillLayer::getDefaultFillTranslateAnchor() { return {TranslateAnchorType::Map}; } const PropertyValue& FillLayer::getFillTranslateAnchor() const { return impl().paint.template get().value; } void FillLayer::setFillTranslateAnchor(const PropertyValue& value) { if (value == getFillTranslateAnchor()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void FillLayer::setFillTranslateAnchorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions FillLayer::getFillTranslateAnchorTransition() const { return impl().paint.template get().options; } using namespace conversion; namespace { constexpr uint8_t kPaintPropertyCount = 14u; enum class Property : uint8_t { FillAntialias, FillColor, FillOpacity, FillOutlineColor, FillPattern, FillTranslate, FillTranslateAnchor, FillAntialiasTransition, FillColorTransition, FillOpacityTransition, FillOutlineColorTransition, FillPatternTransition, FillTranslateTransition, FillTranslateAnchorTransition, FillSortKey = kPaintPropertyCount, }; template constexpr uint8_t toUint8(T t) noexcept { return uint8_t(mbgl::underlying_type(t)); } MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map( {{"fill-antialias", toUint8(Property::FillAntialias)}, {"fill-color", toUint8(Property::FillColor)}, {"fill-opacity", toUint8(Property::FillOpacity)}, {"fill-outline-color", toUint8(Property::FillOutlineColor)}, {"fill-pattern", toUint8(Property::FillPattern)}, {"fill-translate", toUint8(Property::FillTranslate)}, {"fill-translate-anchor", toUint8(Property::FillTranslateAnchor)}, {"fill-antialias-transition", toUint8(Property::FillAntialiasTransition)}, {"fill-color-transition", toUint8(Property::FillColorTransition)}, {"fill-opacity-transition", toUint8(Property::FillOpacityTransition)}, {"fill-outline-color-transition", toUint8(Property::FillOutlineColorTransition)}, {"fill-pattern-transition", toUint8(Property::FillPatternTransition)}, {"fill-translate-transition", toUint8(Property::FillTranslateTransition)}, {"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)}, {"fill-sort-key", toUint8(Property::FillSortKey)}}); StyleProperty getLayerProperty(const FillLayer& layer, Property property) { switch (property) { case Property::FillAntialias: return makeStyleProperty(layer.getFillAntialias()); case Property::FillColor: return makeStyleProperty(layer.getFillColor()); case Property::FillOpacity: return makeStyleProperty(layer.getFillOpacity()); case Property::FillOutlineColor: return makeStyleProperty(layer.getFillOutlineColor()); case Property::FillPattern: return makeStyleProperty(layer.getFillPattern()); case Property::FillTranslate: return makeStyleProperty(layer.getFillTranslate()); case Property::FillTranslateAnchor: return makeStyleProperty(layer.getFillTranslateAnchor()); case Property::FillAntialiasTransition: return makeStyleProperty(layer.getFillAntialiasTransition()); case Property::FillColorTransition: return makeStyleProperty(layer.getFillColorTransition()); case Property::FillOpacityTransition: return makeStyleProperty(layer.getFillOpacityTransition()); case Property::FillOutlineColorTransition: return makeStyleProperty(layer.getFillOutlineColorTransition()); case Property::FillPatternTransition: return makeStyleProperty(layer.getFillPatternTransition()); case Property::FillTranslateTransition: return makeStyleProperty(layer.getFillTranslateTransition()); case Property::FillTranslateAnchorTransition: return makeStyleProperty(layer.getFillTranslateAnchorTransition()); case Property::FillSortKey: return makeStyleProperty(layer.getFillSortKey()); } return {}; } StyleProperty getLayerProperty(const FillLayer& layer, const std::string& name) { const auto it = layerProperties.find(name.c_str()); if (it == layerProperties.end()) { return {}; } return getLayerProperty(layer, static_cast(it->second)); } } // namespace Value FillLayer::serialize() const { auto result = Layer::serialize(); assert(result.getObject()); for (const auto& property : layerProperties) { auto styleProperty = getLayerProperty(*this, static_cast(property.second)); if (styleProperty.getKind() == StyleProperty::Kind::Undefined) continue; serializeProperty(result, styleProperty, property.first.c_str(), property.second < kPaintPropertyCount); } return result; } optional FillLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast(it->second); if (property == Property::FillAntialias) { Error error; const auto& typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setFillAntialias(*typedValue); return nullopt; } if (property == Property::FillColor || property == Property::FillOutlineColor) { Error error; const auto& typedValue = convert>(value, error, true, false); if (!typedValue) { return error; } if (property == Property::FillColor) { setFillColor(*typedValue); return nullopt; } if (property == Property::FillOutlineColor) { setFillOutlineColor(*typedValue); return nullopt; } } if (property == Property::FillOpacity || property == Property::FillSortKey) { Error error; const auto& typedValue = convert>(value, error, true, false); if (!typedValue) { return error; } if (property == Property::FillOpacity) { setFillOpacity(*typedValue); return nullopt; } if (property == Property::FillSortKey) { setFillSortKey(*typedValue); return nullopt; } } if (property == Property::FillPattern) { Error error; const auto& typedValue = convert>(value, error, true, false); if (!typedValue) { return error; } setFillPattern(*typedValue); return nullopt; } if (property == Property::FillTranslate) { Error error; const auto& typedValue = convert>>(value, error, false, false); if (!typedValue) { return error; } setFillTranslate(*typedValue); return nullopt; } if (property == Property::FillTranslateAnchor) { Error error; const auto& typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setFillTranslateAnchor(*typedValue); return nullopt; } Error error; optional transition = convert(value, error); if (!transition) { return error; } if (property == Property::FillAntialiasTransition) { setFillAntialiasTransition(*transition); return nullopt; } if (property == Property::FillColorTransition) { setFillColorTransition(*transition); return nullopt; } if (property == Property::FillOpacityTransition) { setFillOpacityTransition(*transition); return nullopt; } if (property == Property::FillOutlineColorTransition) { setFillOutlineColorTransition(*transition); return nullopt; } if (property == Property::FillPatternTransition) { setFillPatternTransition(*transition); return nullopt; } if (property == Property::FillTranslateTransition) { setFillTranslateTransition(*transition); return nullopt; } if (property == Property::FillTranslateAnchorTransition) { setFillTranslateAnchorTransition(*transition); return nullopt; } return Error{"layer doesn't support this property"}; } StyleProperty FillLayer::getProperty(const std::string& name) const { return getLayerProperty(*this, name); } Mutable FillLayer::mutableBaseImpl() const { return staticMutableCast(mutableImpl()); } } // namespace style } // namespace mbgl // clang-format on