// 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* BackgroundLayer::Impl::staticTypeInfo() noexcept { const static LayerTypeInfo typeInfo{"background", LayerTypeInfo::Source::NotRequired, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, LayerTypeInfo::FadingTiles::NotRequired, LayerTypeInfo::CrossTileIndex::NotRequired, LayerTypeInfo::TileKind::NotRequired}; return &typeInfo; } BackgroundLayer::BackgroundLayer(const std::string& layerID) : Layer(makeMutable(layerID, std::string())) { } BackgroundLayer::BackgroundLayer(Immutable impl_) : Layer(std::move(impl_)) { } BackgroundLayer::~BackgroundLayer() = default; const BackgroundLayer::Impl& BackgroundLayer::impl() const { return static_cast(*baseImpl); } Mutable BackgroundLayer::mutableImpl() const { return makeMutable(impl()); } std::unique_ptr BackgroundLayer::cloneRef(const std::string& id_) const { auto impl_ = mutableImpl(); impl_->id = id_; impl_->paint = BackgroundPaintProperties::Transitionable(); return std::make_unique(std::move(impl_)); } void BackgroundLayer::Impl::stringifyLayout(rapidjson::Writer&) const { } // Layout properties // Paint properties PropertyValue BackgroundLayer::getDefaultBackgroundColor() { return {Color::black()}; } const PropertyValue& BackgroundLayer::getBackgroundColor() const { return impl().paint.template get().value; } void BackgroundLayer::setBackgroundColor(const PropertyValue& value) { if (value == getBackgroundColor()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundColorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions BackgroundLayer::getBackgroundColorTransition() const { return impl().paint.template get().options; } PropertyValue BackgroundLayer::getDefaultBackgroundOpacity() { return {1}; } const PropertyValue& BackgroundLayer::getBackgroundOpacity() const { return impl().paint.template get().value; } void BackgroundLayer::setBackgroundOpacity(const PropertyValue& value) { if (value == getBackgroundOpacity()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundOpacityTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions BackgroundLayer::getBackgroundOpacityTransition() const { return impl().paint.template get().options; } PropertyValue BackgroundLayer::getDefaultBackgroundPattern() { return {{}}; } const PropertyValue& BackgroundLayer::getBackgroundPattern() const { return impl().paint.template get().value; } void BackgroundLayer::setBackgroundPattern(const PropertyValue& value) { if (value == getBackgroundPattern()) return; auto impl_ = mutableImpl(); impl_->paint.template get().value = value; baseImpl = std::move(impl_); observer->onLayerChanged(*this); } void BackgroundLayer::setBackgroundPatternTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->paint.template get().options = options; baseImpl = std::move(impl_); } TransitionOptions BackgroundLayer::getBackgroundPatternTransition() const { return impl().paint.template get().options; } using namespace conversion; namespace { constexpr uint8_t kPaintPropertyCount = 6u; enum class Property : uint8_t { BackgroundColor, BackgroundOpacity, BackgroundPattern, BackgroundColorTransition, BackgroundOpacityTransition, BackgroundPatternTransition, }; 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( {{"background-color", toUint8(Property::BackgroundColor)}, {"background-opacity", toUint8(Property::BackgroundOpacity)}, {"background-pattern", toUint8(Property::BackgroundPattern)}, {"background-color-transition", toUint8(Property::BackgroundColorTransition)}, {"background-opacity-transition", toUint8(Property::BackgroundOpacityTransition)}, {"background-pattern-transition", toUint8(Property::BackgroundPatternTransition)}}); StyleProperty getLayerProperty(const BackgroundLayer& layer, Property property) { switch (property) { case Property::BackgroundColor: return makeStyleProperty(layer.getBackgroundColor()); case Property::BackgroundOpacity: return makeStyleProperty(layer.getBackgroundOpacity()); case Property::BackgroundPattern: return makeStyleProperty(layer.getBackgroundPattern()); case Property::BackgroundColorTransition: return makeStyleProperty(layer.getBackgroundColorTransition()); case Property::BackgroundOpacityTransition: return makeStyleProperty(layer.getBackgroundOpacityTransition()); case Property::BackgroundPatternTransition: return makeStyleProperty(layer.getBackgroundPatternTransition()); } return {}; } StyleProperty getLayerProperty(const BackgroundLayer& 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 BackgroundLayer::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 BackgroundLayer::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::BackgroundColor) { Error error; const auto& typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setBackgroundColor(*typedValue); return nullopt; } if (property == Property::BackgroundOpacity) { Error error; const auto& typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setBackgroundOpacity(*typedValue); return nullopt; } if (property == Property::BackgroundPattern) { Error error; const auto& typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setBackgroundPattern(*typedValue); return nullopt; } Error error; optional transition = convert(value, error); if (!transition) { return error; } if (property == Property::BackgroundColorTransition) { setBackgroundColorTransition(*transition); return nullopt; } if (property == Property::BackgroundOpacityTransition) { setBackgroundOpacityTransition(*transition); return nullopt; } if (property == Property::BackgroundPatternTransition) { setBackgroundPatternTransition(*transition); return nullopt; } return Error{"layer doesn't support this property"}; } StyleProperty BackgroundLayer::getProperty(const std::string& name) const { return getLayerProperty(*this, name); } Mutable BackgroundLayer::mutableBaseImpl() const { return staticMutableCast(mutableImpl()); } } // namespace style } // namespace mbgl // clang-format on