From fe2a26225f3746381b36ad8b6c6a3ce7727bf655 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 29 Aug 2016 12:00:08 -0700 Subject: [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. --- src/mbgl/style/layers/line_layer.cpp | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/mbgl/style/layers/line_layer.cpp') diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index dbf4b682ba..100ee7247f 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -50,6 +50,7 @@ const std::string& LineLayer::getSourceLayer() const { void LineLayer::setFilter(const Filter& filter) { impl->filter = filter; + impl->observer->onLayerFilterChanged(*this); } const Filter& LineLayer::getFilter() const { @@ -67,7 +68,10 @@ PropertyValue LineLayer::getLineCap() const { } void LineLayer::setLineCap(PropertyValue value) { + if (value == getLineCap()) + return; impl->layout.lineCap.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineJoin() { return { LineJoinType::Miter }; @@ -78,7 +82,10 @@ PropertyValue LineLayer::getLineJoin() const { } void LineLayer::setLineJoin(PropertyValue value) { + if (value == getLineJoin()) + return; impl->layout.lineJoin.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineMiterLimit() { return { 2 }; @@ -89,7 +96,10 @@ PropertyValue LineLayer::getLineMiterLimit() const { } void LineLayer::setLineMiterLimit(PropertyValue value) { + if (value == getLineMiterLimit()) + return; impl->layout.lineMiterLimit.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineRoundLimit() { return { 1 }; @@ -100,7 +110,10 @@ PropertyValue LineLayer::getLineRoundLimit() const { } void LineLayer::setLineRoundLimit(PropertyValue value) { + if (value == getLineRoundLimit()) + return; impl->layout.lineRoundLimit.set(value); + impl->observer->onLayerLayoutPropertyChanged(*this); } // Paint properties @@ -114,7 +127,10 @@ PropertyValue LineLayer::getLineOpacity(const optional& klas } void LineLayer::setLineOpacity(PropertyValue value, const optional& klass) { + if (value == getLineOpacity(klass)) + return; impl->paint.lineOpacity.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineColor() { @@ -126,7 +142,10 @@ PropertyValue LineLayer::getLineColor(const optional& klass) } void LineLayer::setLineColor(PropertyValue value, const optional& klass) { + if (value == getLineColor(klass)) + return; impl->paint.lineColor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue> LineLayer::getDefaultLineTranslate() { @@ -138,7 +157,10 @@ PropertyValue> LineLayer::getLineTranslate(const optional> value, const optional& klass) { + if (value == getLineTranslate(klass)) + return; impl->paint.lineTranslate.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineTranslateAnchor() { @@ -150,7 +172,10 @@ PropertyValue LineLayer::getLineTranslateAnchor(const optio } void LineLayer::setLineTranslateAnchor(PropertyValue value, const optional& klass) { + if (value == getLineTranslateAnchor(klass)) + return; impl->paint.lineTranslateAnchor.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineWidth() { @@ -162,7 +187,10 @@ PropertyValue LineLayer::getLineWidth(const optional& klass) } void LineLayer::setLineWidth(PropertyValue value, const optional& klass) { + if (value == getLineWidth(klass)) + return; impl->paint.lineWidth.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineGapWidth() { @@ -174,7 +202,10 @@ PropertyValue LineLayer::getLineGapWidth(const optional& kla } void LineLayer::setLineGapWidth(PropertyValue value, const optional& klass) { + if (value == getLineGapWidth(klass)) + return; impl->paint.lineGapWidth.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineOffset() { @@ -186,7 +217,10 @@ PropertyValue LineLayer::getLineOffset(const optional& klass } void LineLayer::setLineOffset(PropertyValue value, const optional& klass) { + if (value == getLineOffset(klass)) + return; impl->paint.lineOffset.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLineBlur() { @@ -198,7 +232,10 @@ PropertyValue LineLayer::getLineBlur(const optional& klass) } void LineLayer::setLineBlur(PropertyValue value, const optional& klass) { + if (value == getLineBlur(klass)) + return; impl->paint.lineBlur.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue> LineLayer::getDefaultLineDasharray() { @@ -210,7 +247,10 @@ PropertyValue> LineLayer::getLineDasharray(const optional> value, const optional& klass) { + if (value == getLineDasharray(klass)) + return; impl->paint.lineDasharray.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } PropertyValue LineLayer::getDefaultLinePattern() { @@ -222,7 +262,10 @@ PropertyValue LineLayer::getLinePattern(const optional } void LineLayer::setLinePattern(PropertyValue value, const optional& klass) { + if (value == getLinePattern(klass)) + return; impl->paint.linePattern.set(value, klass); + impl->observer->onLayerPaintPropertyChanged(*this); } } // namespace style -- cgit v1.2.1