From cadc617c762d453cca2c9bac41f9c1db984c5fac Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 25 Apr 2016 13:59:09 -0700 Subject: [core] Introduce PropertyValue PropertyValue represents the three possible types of style property value: undefined, constant, or function. --- include/mbgl/layer/background_layer.hpp | 13 +-- include/mbgl/layer/circle_layer.hpp | 25 ++--- include/mbgl/layer/fill_layer.hpp | 29 ++--- include/mbgl/layer/line_layer.hpp | 57 +++++----- include/mbgl/layer/raster_layer.hpp | 29 ++--- include/mbgl/layer/symbol_layer.hpp | 181 ++++++++++++++++---------------- include/mbgl/style/types.hpp | 3 - 7 files changed, 170 insertions(+), 167 deletions(-) (limited to 'include') diff --git a/include/mbgl/layer/background_layer.hpp b/include/mbgl/layer/background_layer.hpp index 79f24990e6..211597f6ea 100644 --- a/include/mbgl/layer/background_layer.hpp +++ b/include/mbgl/layer/background_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include namespace mbgl { @@ -13,14 +14,14 @@ public: // Paint properties - Function getBackgroundColor() const; - void setBackgroundColor(Function); + PropertyValue getBackgroundColor() const; + void setBackgroundColor(PropertyValue); - Function getBackgroundPattern() const; - void setBackgroundPattern(Function); + PropertyValue getBackgroundPattern() const; + void setBackgroundPattern(PropertyValue); - Function getBackgroundOpacity() const; - void setBackgroundOpacity(Function); + PropertyValue getBackgroundOpacity() const; + void setBackgroundOpacity(PropertyValue); // Private implementation diff --git a/include/mbgl/layer/circle_layer.hpp b/include/mbgl/layer/circle_layer.hpp index 14b9da895f..28e5c2fa7a 100644 --- a/include/mbgl/layer/circle_layer.hpp +++ b/include/mbgl/layer/circle_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include namespace mbgl { @@ -19,23 +20,23 @@ public: // Paint properties - Function getCircleRadius() const; - void setCircleRadius(Function); + PropertyValue getCircleRadius() const; + void setCircleRadius(PropertyValue); - Function getCircleColor() const; - void setCircleColor(Function); + PropertyValue getCircleColor() const; + void setCircleColor(PropertyValue); - Function getCircleBlur() const; - void setCircleBlur(Function); + PropertyValue getCircleBlur() const; + void setCircleBlur(PropertyValue); - Function getCircleOpacity() const; - void setCircleOpacity(Function); + PropertyValue getCircleOpacity() const; + void setCircleOpacity(PropertyValue); - Function> getCircleTranslate() const; - void setCircleTranslate(Function>); + PropertyValue> getCircleTranslate() const; + void setCircleTranslate(PropertyValue>); - Function getCircleTranslateAnchor() const; - void setCircleTranslateAnchor(Function); + PropertyValue getCircleTranslateAnchor() const; + void setCircleTranslateAnchor(PropertyValue); // Private implementation diff --git a/include/mbgl/layer/fill_layer.hpp b/include/mbgl/layer/fill_layer.hpp index dc0752f9e2..76c043957d 100644 --- a/include/mbgl/layer/fill_layer.hpp +++ b/include/mbgl/layer/fill_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include namespace mbgl { @@ -19,26 +20,26 @@ public: // Paint properties - Function getFillAntialias() const; - void setFillAntialias(Function); + PropertyValue getFillAntialias() const; + void setFillAntialias(PropertyValue); - Function getFillOpacity() const; - void setFillOpacity(Function); + PropertyValue getFillOpacity() const; + void setFillOpacity(PropertyValue); - Function getFillColor() const; - void setFillColor(Function); + PropertyValue getFillColor() const; + void setFillColor(PropertyValue); - Function getFillOutlineColor() const; - void setFillOutlineColor(Function); + PropertyValue getFillOutlineColor() const; + void setFillOutlineColor(PropertyValue); - Function> getFillTranslate() const; - void setFillTranslate(Function>); + PropertyValue> getFillTranslate() const; + void setFillTranslate(PropertyValue>); - Function getFillTranslateAnchor() const; - void setFillTranslateAnchor(Function); + PropertyValue getFillTranslateAnchor() const; + void setFillTranslateAnchor(PropertyValue); - Function getFillPattern() const; - void setFillPattern(Function); + PropertyValue getFillPattern() const; + void setFillPattern(PropertyValue); // Private implementation diff --git a/include/mbgl/layer/line_layer.hpp b/include/mbgl/layer/line_layer.hpp index 0f898d3c69..b438799116 100644 --- a/include/mbgl/layer/line_layer.hpp +++ b/include/mbgl/layer/line_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include #include @@ -21,49 +22,49 @@ public: // Layout properties - Function getLineCap() const; - void setLineCap(Function); + PropertyValue getLineCap() const; + void setLineCap(PropertyValue); - Function getLineJoin() const; - void setLineJoin(Function); + PropertyValue getLineJoin() const; + void setLineJoin(PropertyValue); - Function getLineMiterLimit() const; - void setLineMiterLimit(Function); + PropertyValue getLineMiterLimit() const; + void setLineMiterLimit(PropertyValue); - Function getLineRoundLimit() const; - void setLineRoundLimit(Function); + PropertyValue getLineRoundLimit() const; + void setLineRoundLimit(PropertyValue); // Paint properties - Function getLineOpacity() const; - void setLineOpacity(Function); + PropertyValue getLineOpacity() const; + void setLineOpacity(PropertyValue); - Function getLineColor() const; - void setLineColor(Function); + PropertyValue getLineColor() const; + void setLineColor(PropertyValue); - Function> getLineTranslate() const; - void setLineTranslate(Function>); + PropertyValue> getLineTranslate() const; + void setLineTranslate(PropertyValue>); - Function getLineTranslateAnchor() const; - void setLineTranslateAnchor(Function); + PropertyValue getLineTranslateAnchor() const; + void setLineTranslateAnchor(PropertyValue); - Function getLineWidth() const; - void setLineWidth(Function); + PropertyValue getLineWidth() const; + void setLineWidth(PropertyValue); - Function getLineGapWidth() const; - void setLineGapWidth(Function); + PropertyValue getLineGapWidth() const; + void setLineGapWidth(PropertyValue); - Function getLineOffset() const; - void setLineOffset(Function); + PropertyValue getLineOffset() const; + void setLineOffset(PropertyValue); - Function getLineBlur() const; - void setLineBlur(Function); + PropertyValue getLineBlur() const; + void setLineBlur(PropertyValue); - Function> getLineDasharray() const; - void setLineDasharray(Function>); + PropertyValue> getLineDasharray() const; + void setLineDasharray(PropertyValue>); - Function getLinePattern() const; - void setLinePattern(Function); + PropertyValue getLinePattern() const; + void setLinePattern(PropertyValue); // Private implementation diff --git a/include/mbgl/layer/raster_layer.hpp b/include/mbgl/layer/raster_layer.hpp index 9dc27a274a..5d747737c0 100644 --- a/include/mbgl/layer/raster_layer.hpp +++ b/include/mbgl/layer/raster_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include namespace mbgl { @@ -18,26 +19,26 @@ public: // Paint properties - Function getRasterOpacity() const; - void setRasterOpacity(Function); + PropertyValue getRasterOpacity() const; + void setRasterOpacity(PropertyValue); - Function getRasterHueRotate() const; - void setRasterHueRotate(Function); + PropertyValue getRasterHueRotate() const; + void setRasterHueRotate(PropertyValue); - Function getRasterBrightnessMin() const; - void setRasterBrightnessMin(Function); + PropertyValue getRasterBrightnessMin() const; + void setRasterBrightnessMin(PropertyValue); - Function getRasterBrightnessMax() const; - void setRasterBrightnessMax(Function); + PropertyValue getRasterBrightnessMax() const; + void setRasterBrightnessMax(PropertyValue); - Function getRasterSaturation() const; - void setRasterSaturation(Function); + PropertyValue getRasterSaturation() const; + void setRasterSaturation(PropertyValue); - Function getRasterContrast() const; - void setRasterContrast(Function); + PropertyValue getRasterContrast() const; + void setRasterContrast(PropertyValue); - Function getRasterFadeDuration() const; - void setRasterFadeDuration(Function); + PropertyValue getRasterFadeDuration() const; + void setRasterFadeDuration(PropertyValue); // Private implementation diff --git a/include/mbgl/layer/symbol_layer.hpp b/include/mbgl/layer/symbol_layer.hpp index f9b2956390..2339515201 100644 --- a/include/mbgl/layer/symbol_layer.hpp +++ b/include/mbgl/layer/symbol_layer.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include #include @@ -21,142 +22,142 @@ public: // Layout properties - Function getSymbolPlacement() const; - void setSymbolPlacement(Function); + PropertyValue getSymbolPlacement() const; + void setSymbolPlacement(PropertyValue); - Function getSymbolSpacing() const; - void setSymbolSpacing(Function); + PropertyValue getSymbolSpacing() const; + void setSymbolSpacing(PropertyValue); - Function getSymbolAvoidEdges() const; - void setSymbolAvoidEdges(Function); + PropertyValue getSymbolAvoidEdges() const; + void setSymbolAvoidEdges(PropertyValue); - Function getIconAllowOverlap() const; - void setIconAllowOverlap(Function); + PropertyValue getIconAllowOverlap() const; + void setIconAllowOverlap(PropertyValue); - Function getIconIgnorePlacement() const; - void setIconIgnorePlacement(Function); + PropertyValue getIconIgnorePlacement() const; + void setIconIgnorePlacement(PropertyValue); - Function getIconOptional() const; - void setIconOptional(Function); + PropertyValue getIconOptional() const; + void setIconOptional(PropertyValue); - Function getIconRotationAlignment() const; - void setIconRotationAlignment(Function); + PropertyValue getIconRotationAlignment() const; + void setIconRotationAlignment(PropertyValue); - Function getIconSize() const; - void setIconSize(Function); + PropertyValue getIconSize() const; + void setIconSize(PropertyValue); - Function getIconImage() const; - void setIconImage(Function); + PropertyValue getIconImage() const; + void setIconImage(PropertyValue); - Function getIconRotate() const; - void setIconRotate(Function); + PropertyValue getIconRotate() const; + void setIconRotate(PropertyValue); - Function getIconPadding() const; - void setIconPadding(Function); + PropertyValue getIconPadding() const; + void setIconPadding(PropertyValue); - Function getIconKeepUpright() const; - void setIconKeepUpright(Function); + PropertyValue getIconKeepUpright() const; + void setIconKeepUpright(PropertyValue); - Function> getIconOffset() const; - void setIconOffset(Function>); + PropertyValue> getIconOffset() const; + void setIconOffset(PropertyValue>); - Function getTextRotationAlignment() const; - void setTextRotationAlignment(Function); + PropertyValue getTextRotationAlignment() const; + void setTextRotationAlignment(PropertyValue); - Function getTextField() const; - void setTextField(Function); + PropertyValue getTextField() const; + void setTextField(PropertyValue); - Function> getTextFont() const; - void setTextFont(Function>); + PropertyValue> getTextFont() const; + void setTextFont(PropertyValue>); - Function getTextSize() const; - void setTextSize(Function); + PropertyValue getTextSize() const; + void setTextSize(PropertyValue); - Function getTextMaxWidth() const; - void setTextMaxWidth(Function); + PropertyValue getTextMaxWidth() const; + void setTextMaxWidth(PropertyValue); - Function getTextLineHeight() const; - void setTextLineHeight(Function); + PropertyValue getTextLineHeight() const; + void setTextLineHeight(PropertyValue); - Function getTextLetterSpacing() const; - void setTextLetterSpacing(Function); + PropertyValue getTextLetterSpacing() const; + void setTextLetterSpacing(PropertyValue); - Function getTextJustify() const; - void setTextJustify(Function); + PropertyValue getTextJustify() const; + void setTextJustify(PropertyValue); - Function getTextAnchor() const; - void setTextAnchor(Function); + PropertyValue getTextAnchor() const; + void setTextAnchor(PropertyValue); - Function getTextMaxAngle() const; - void setTextMaxAngle(Function); + PropertyValue getTextMaxAngle() const; + void setTextMaxAngle(PropertyValue); - Function getTextRotate() const; - void setTextRotate(Function); + PropertyValue getTextRotate() const; + void setTextRotate(PropertyValue); - Function getTextPadding() const; - void setTextPadding(Function); + PropertyValue getTextPadding() const; + void setTextPadding(PropertyValue); - Function getTextKeepUpright() const; - void setTextKeepUpright(Function); + PropertyValue getTextKeepUpright() const; + void setTextKeepUpright(PropertyValue); - Function getTextTransform() const; - void setTextTransform(Function); + PropertyValue getTextTransform() const; + void setTextTransform(PropertyValue); - Function> getTextOffset() const; - void setTextOffset(Function>); + PropertyValue> getTextOffset() const; + void setTextOffset(PropertyValue>); - Function getTextAllowOverlap() const; - void setTextAllowOverlap(Function); + PropertyValue getTextAllowOverlap() const; + void setTextAllowOverlap(PropertyValue); - Function getTextIgnorePlacement() const; - void setTextIgnorePlacement(Function); + PropertyValue getTextIgnorePlacement() const; + void setTextIgnorePlacement(PropertyValue); - Function getTextOptional() const; - void setTextOptional(Function); + PropertyValue getTextOptional() const; + void setTextOptional(PropertyValue); // Paint properties - Function getIconOpacity() const; - void setIconOpacity(Function); + PropertyValue getIconOpacity() const; + void setIconOpacity(PropertyValue); - Function getIconColor() const; - void setIconColor(Function); + PropertyValue getIconColor() const; + void setIconColor(PropertyValue); - Function getIconHaloColor() const; - void setIconHaloColor(Function); + PropertyValue getIconHaloColor() const; + void setIconHaloColor(PropertyValue); - Function getIconHaloWidth() const; - void setIconHaloWidth(Function); + PropertyValue getIconHaloWidth() const; + void setIconHaloWidth(PropertyValue); - Function getIconHaloBlur() const; - void setIconHaloBlur(Function); + PropertyValue getIconHaloBlur() const; + void setIconHaloBlur(PropertyValue); - Function> getIconTranslate() const; - void setIconTranslate(Function>); + PropertyValue> getIconTranslate() const; + void setIconTranslate(PropertyValue>); - Function getIconTranslateAnchor() const; - void setIconTranslateAnchor(Function); + PropertyValue getIconTranslateAnchor() const; + void setIconTranslateAnchor(PropertyValue); - Function getTextOpacity() const; - void setTextOpacity(Function); + PropertyValue getTextOpacity() const; + void setTextOpacity(PropertyValue); - Function getTextColor() const; - void setTextColor(Function); + PropertyValue getTextColor() const; + void setTextColor(PropertyValue); - Function getTextHaloColor() const; - void setTextHaloColor(Function); + PropertyValue getTextHaloColor() const; + void setTextHaloColor(PropertyValue); - Function getTextHaloWidth() const; - void setTextHaloWidth(Function); + PropertyValue getTextHaloWidth() const; + void setTextHaloWidth(PropertyValue); - Function getTextHaloBlur() const; - void setTextHaloBlur(Function); + PropertyValue getTextHaloBlur() const; + void setTextHaloBlur(PropertyValue); - Function> getTextTranslate() const; - void setTextTranslate(Function>); + PropertyValue> getTextTranslate() const; + void setTextTranslate(PropertyValue>); - Function getTextTranslateAnchor() const; - void setTextTranslateAnchor(Function); + PropertyValue getTextTranslateAnchor() const; + void setTextTranslateAnchor(PropertyValue); // Private implementation diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index ea09ccfb0c..56f3570357 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -27,9 +27,6 @@ public: using Stop = std::pair; using Stops = std::vector; - Function(const T& constant) - : stops({{ 0, constant }}) {} - explicit Function(const Stops& stops_, float base_) : base(base_), stops(stops_) {} -- cgit v1.2.1