diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-08-29 12:00:08 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-06 14:29:22 -0700 |
commit | fe2a26225f3746381b36ad8b6c6a3ce7727bf655 (patch) | |
tree | 62507ffd6a28654a377469d35e21719ff7a12fdc /src/mbgl/style/layers/symbol_layer.cpp | |
parent | 3a48c60813b18c092c8d8d75c80a318bdd8859bb (diff) | |
download | qtlocation-mapboxgl-fe2a26225f3746381b36ad8b6c6a3ce7727bf655.tar.gz |
[core, ios, android, qt] Observe style layer mutations rather than requiring SDKs to use Map::update
This paves the way for updates to filter and layout properties to trigger a source reload, without each SDK having to participate in the implementation.
Diffstat (limited to 'src/mbgl/style/layers/symbol_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 78fbfda6dd..c9fd2c0988 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -50,6 +50,7 @@ const std::string& SymbolLayer::getSourceLayer() const { void SymbolLayer::setFilter(const Filter& filter) { impl->filter = filter; + impl->observer->onLayerFilterChanged(*this); } const Filter& SymbolLayer::getFilter() const { @@ -67,7 +68,10 @@ PropertyValue<SymbolPlacementType> SymbolLayer::getSymbolPlacement() const { } void SymbolLayer::setSymbolPlacement(PropertyValue<SymbolPlacementType> value) { + if (value == getSymbolPlacement()) + return; impl->layout.symbolPlacement.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultSymbolSpacing() { return { 250 }; @@ -78,7 +82,10 @@ PropertyValue<float> SymbolLayer::getSymbolSpacing() const { } void SymbolLayer::setSymbolSpacing(PropertyValue<float> value) { + if (value == getSymbolSpacing()) + return; impl->layout.symbolSpacing.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultSymbolAvoidEdges() { return { false }; @@ -89,7 +96,10 @@ PropertyValue<bool> SymbolLayer::getSymbolAvoidEdges() const { } void SymbolLayer::setSymbolAvoidEdges(PropertyValue<bool> value) { + if (value == getSymbolAvoidEdges()) + return; impl->layout.symbolAvoidEdges.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultIconAllowOverlap() { return { false }; @@ -100,7 +110,10 @@ PropertyValue<bool> SymbolLayer::getIconAllowOverlap() const { } void SymbolLayer::setIconAllowOverlap(PropertyValue<bool> value) { + if (value == getIconAllowOverlap()) + return; impl->layout.iconAllowOverlap.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultIconIgnorePlacement() { return { false }; @@ -111,7 +124,10 @@ PropertyValue<bool> SymbolLayer::getIconIgnorePlacement() const { } void SymbolLayer::setIconIgnorePlacement(PropertyValue<bool> value) { + if (value == getIconIgnorePlacement()) + return; impl->layout.iconIgnorePlacement.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultIconOptional() { return { false }; @@ -122,7 +138,10 @@ PropertyValue<bool> SymbolLayer::getIconOptional() const { } void SymbolLayer::setIconOptional(PropertyValue<bool> value) { + if (value == getIconOptional()) + return; impl->layout.iconOptional.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() { return { AlignmentType::Viewport }; @@ -133,7 +152,10 @@ PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const { } void SymbolLayer::setIconRotationAlignment(PropertyValue<AlignmentType> value) { + if (value == getIconRotationAlignment()) + return; impl->layout.iconRotationAlignment.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultIconSize() { return { 1 }; @@ -144,7 +166,10 @@ PropertyValue<float> SymbolLayer::getIconSize() const { } void SymbolLayer::setIconSize(PropertyValue<float> value) { + if (value == getIconSize()) + return; impl->layout.iconSize.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<IconTextFitType> SymbolLayer::getDefaultIconTextFit() { return { IconTextFitType::None }; @@ -155,7 +180,10 @@ PropertyValue<IconTextFitType> SymbolLayer::getIconTextFit() const { } void SymbolLayer::setIconTextFit(PropertyValue<IconTextFitType> value) { + if (value == getIconTextFit()) + return; impl->layout.iconTextFit.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::array<float, 4>> SymbolLayer::getDefaultIconTextFitPadding() { return { {{ 0, 0, 0, 0 }} }; @@ -166,7 +194,10 @@ PropertyValue<std::array<float, 4>> SymbolLayer::getIconTextFitPadding() const { } void SymbolLayer::setIconTextFitPadding(PropertyValue<std::array<float, 4>> value) { + if (value == getIconTextFitPadding()) + return; impl->layout.iconTextFitPadding.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::string> SymbolLayer::getDefaultIconImage() { return { "" }; @@ -177,7 +208,10 @@ PropertyValue<std::string> SymbolLayer::getIconImage() const { } void SymbolLayer::setIconImage(PropertyValue<std::string> value) { + if (value == getIconImage()) + return; impl->layout.iconImage.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultIconRotate() { return { 0 }; @@ -188,7 +222,10 @@ PropertyValue<float> SymbolLayer::getIconRotate() const { } void SymbolLayer::setIconRotate(PropertyValue<float> value) { + if (value == getIconRotate()) + return; impl->layout.iconRotate.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultIconPadding() { return { 2 }; @@ -199,7 +236,10 @@ PropertyValue<float> SymbolLayer::getIconPadding() const { } void SymbolLayer::setIconPadding(PropertyValue<float> value) { + if (value == getIconPadding()) + return; impl->layout.iconPadding.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultIconKeepUpright() { return { false }; @@ -210,7 +250,10 @@ PropertyValue<bool> SymbolLayer::getIconKeepUpright() const { } void SymbolLayer::setIconKeepUpright(PropertyValue<bool> value) { + if (value == getIconKeepUpright()) + return; impl->layout.iconKeepUpright.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconOffset() { return { {{ 0, 0 }} }; @@ -221,7 +264,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getIconOffset() const { } void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) { + if (value == getIconOffset()) + return; impl->layout.iconOffset.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() { return { AlignmentType::Undefined }; @@ -232,7 +278,10 @@ PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const { } void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) { + if (value == getTextPitchAlignment()) + return; impl->layout.textPitchAlignment.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() { return { AlignmentType::Viewport }; @@ -243,7 +292,10 @@ PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const { } void SymbolLayer::setTextRotationAlignment(PropertyValue<AlignmentType> value) { + if (value == getTextRotationAlignment()) + return; impl->layout.textRotationAlignment.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::string> SymbolLayer::getDefaultTextField() { return { "" }; @@ -254,7 +306,10 @@ PropertyValue<std::string> SymbolLayer::getTextField() const { } void SymbolLayer::setTextField(PropertyValue<std::string> value) { + if (value == getTextField()) + return; impl->layout.textField.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::vector<std::string>> SymbolLayer::getDefaultTextFont() { return { { "Open Sans Regular", "Arial Unicode MS Regular" } }; @@ -265,7 +320,10 @@ PropertyValue<std::vector<std::string>> SymbolLayer::getTextFont() const { } void SymbolLayer::setTextFont(PropertyValue<std::vector<std::string>> value) { + if (value == getTextFont()) + return; impl->layout.textFont.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextSize() { return { 16 }; @@ -276,7 +334,10 @@ PropertyValue<float> SymbolLayer::getTextSize() const { } void SymbolLayer::setTextSize(PropertyValue<float> value) { + if (value == getTextSize()) + return; impl->layout.textSize.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextMaxWidth() { return { 10 }; @@ -287,7 +348,10 @@ PropertyValue<float> SymbolLayer::getTextMaxWidth() const { } void SymbolLayer::setTextMaxWidth(PropertyValue<float> value) { + if (value == getTextMaxWidth()) + return; impl->layout.textMaxWidth.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextLineHeight() { return { 1.2 }; @@ -298,7 +362,10 @@ PropertyValue<float> SymbolLayer::getTextLineHeight() const { } void SymbolLayer::setTextLineHeight(PropertyValue<float> value) { + if (value == getTextLineHeight()) + return; impl->layout.textLineHeight.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextLetterSpacing() { return { 0 }; @@ -309,7 +376,10 @@ PropertyValue<float> SymbolLayer::getTextLetterSpacing() const { } void SymbolLayer::setTextLetterSpacing(PropertyValue<float> value) { + if (value == getTextLetterSpacing()) + return; impl->layout.textLetterSpacing.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() { return { TextJustifyType::Center }; @@ -320,7 +390,10 @@ PropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const { } void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) { + if (value == getTextJustify()) + return; impl->layout.textJustify.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() { return { TextAnchorType::Center }; @@ -331,7 +404,10 @@ PropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const { } void SymbolLayer::setTextAnchor(PropertyValue<TextAnchorType> value) { + if (value == getTextAnchor()) + return; impl->layout.textAnchor.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextMaxAngle() { return { 45 }; @@ -342,7 +418,10 @@ PropertyValue<float> SymbolLayer::getTextMaxAngle() const { } void SymbolLayer::setTextMaxAngle(PropertyValue<float> value) { + if (value == getTextMaxAngle()) + return; impl->layout.textMaxAngle.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextRotate() { return { 0 }; @@ -353,7 +432,10 @@ PropertyValue<float> SymbolLayer::getTextRotate() const { } void SymbolLayer::setTextRotate(PropertyValue<float> value) { + if (value == getTextRotate()) + return; impl->layout.textRotate.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextPadding() { return { 2 }; @@ -364,7 +446,10 @@ PropertyValue<float> SymbolLayer::getTextPadding() const { } void SymbolLayer::setTextPadding(PropertyValue<float> value) { + if (value == getTextPadding()) + return; impl->layout.textPadding.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultTextKeepUpright() { return { true }; @@ -375,7 +460,10 @@ PropertyValue<bool> SymbolLayer::getTextKeepUpright() const { } void SymbolLayer::setTextKeepUpright(PropertyValue<bool> value) { + if (value == getTextKeepUpright()) + return; impl->layout.textKeepUpright.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<TextTransformType> SymbolLayer::getDefaultTextTransform() { return { TextTransformType::None }; @@ -386,7 +474,10 @@ PropertyValue<TextTransformType> SymbolLayer::getTextTransform() const { } void SymbolLayer::setTextTransform(PropertyValue<TextTransformType> value) { + if (value == getTextTransform()) + return; impl->layout.textTransform.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextOffset() { return { {{ 0, 0 }} }; @@ -397,7 +488,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getTextOffset() const { } void SymbolLayer::setTextOffset(PropertyValue<std::array<float, 2>> value) { + if (value == getTextOffset()) + return; impl->layout.textOffset.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultTextAllowOverlap() { return { false }; @@ -408,7 +502,10 @@ PropertyValue<bool> SymbolLayer::getTextAllowOverlap() const { } void SymbolLayer::setTextAllowOverlap(PropertyValue<bool> value) { + if (value == getTextAllowOverlap()) + return; impl->layout.textAllowOverlap.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultTextIgnorePlacement() { return { false }; @@ -419,7 +516,10 @@ PropertyValue<bool> SymbolLayer::getTextIgnorePlacement() const { } void SymbolLayer::setTextIgnorePlacement(PropertyValue<bool> value) { + if (value == getTextIgnorePlacement()) + return; impl->layout.textIgnorePlacement.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<bool> SymbolLayer::getDefaultTextOptional() { return { false }; @@ -430,7 +530,10 @@ PropertyValue<bool> SymbolLayer::getTextOptional() const { } void SymbolLayer::setTextOptional(PropertyValue<bool> value) { + if (value == getTextOptional()) + return; impl->layout.textOptional.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } // Paint properties @@ -444,7 +547,10 @@ PropertyValue<float> SymbolLayer::getIconOpacity(const optional<std::string>& kl } void SymbolLayer::setIconOpacity(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getIconOpacity(klass)) + return; impl->paint.iconOpacity.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<Color> SymbolLayer::getDefaultIconColor() { @@ -456,7 +562,10 @@ PropertyValue<Color> SymbolLayer::getIconColor(const optional<std::string>& klas } void SymbolLayer::setIconColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getIconColor(klass)) + return; impl->paint.iconColor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<Color> SymbolLayer::getDefaultIconHaloColor() { @@ -468,7 +577,10 @@ PropertyValue<Color> SymbolLayer::getIconHaloColor(const optional<std::string>& } void SymbolLayer::setIconHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getIconHaloColor(klass)) + return; impl->paint.iconHaloColor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultIconHaloWidth() { @@ -480,7 +592,10 @@ PropertyValue<float> SymbolLayer::getIconHaloWidth(const optional<std::string>& } void SymbolLayer::setIconHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getIconHaloWidth(klass)) + return; impl->paint.iconHaloWidth.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultIconHaloBlur() { @@ -492,7 +607,10 @@ PropertyValue<float> SymbolLayer::getIconHaloBlur(const optional<std::string>& k } void SymbolLayer::setIconHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getIconHaloBlur(klass)) + return; impl->paint.iconHaloBlur.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultIconTranslate() { @@ -504,7 +622,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getIconTranslate(const optional } void SymbolLayer::setIconTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) { + if (value == getIconTranslate(klass)) + return; impl->paint.iconTranslate.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultIconTranslateAnchor() { @@ -516,7 +637,10 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getIconTranslateAnchor(const opt } void SymbolLayer::setIconTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) { + if (value == getIconTranslateAnchor(klass)) + return; impl->paint.iconTranslateAnchor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextOpacity() { @@ -528,7 +652,10 @@ PropertyValue<float> SymbolLayer::getTextOpacity(const optional<std::string>& kl } void SymbolLayer::setTextOpacity(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getTextOpacity(klass)) + return; impl->paint.textOpacity.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<Color> SymbolLayer::getDefaultTextColor() { @@ -540,7 +667,10 @@ PropertyValue<Color> SymbolLayer::getTextColor(const optional<std::string>& klas } void SymbolLayer::setTextColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getTextColor(klass)) + return; impl->paint.textColor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<Color> SymbolLayer::getDefaultTextHaloColor() { @@ -552,7 +682,10 @@ PropertyValue<Color> SymbolLayer::getTextHaloColor(const optional<std::string>& } void SymbolLayer::setTextHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) { + if (value == getTextHaloColor(klass)) + return; impl->paint.textHaloColor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextHaloWidth() { @@ -564,7 +697,10 @@ PropertyValue<float> SymbolLayer::getTextHaloWidth(const optional<std::string>& } void SymbolLayer::setTextHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getTextHaloWidth(klass)) + return; impl->paint.textHaloWidth.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<float> SymbolLayer::getDefaultTextHaloBlur() { @@ -576,7 +712,10 @@ PropertyValue<float> SymbolLayer::getTextHaloBlur(const optional<std::string>& k } void SymbolLayer::setTextHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) { + if (value == getTextHaloBlur(klass)) + return; impl->paint.textHaloBlur.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<std::array<float, 2>> SymbolLayer::getDefaultTextTranslate() { @@ -588,7 +727,10 @@ PropertyValue<std::array<float, 2>> SymbolLayer::getTextTranslate(const optional } void SymbolLayer::setTextTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) { + if (value == getTextTranslate(klass)) + return; impl->paint.textTranslate.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue<TranslateAnchorType> SymbolLayer::getDefaultTextTranslateAnchor() { @@ -600,7 +742,10 @@ PropertyValue<TranslateAnchorType> SymbolLayer::getTextTranslateAnchor(const opt } void SymbolLayer::setTextTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) { + if (value == getTextTranslateAnchor(klass)) + return; impl->paint.textTranslateAnchor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } } // namespace style |