diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-10 15:15:24 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-08-13 12:39:44 -0700 |
commit | d886d3e4c04801e57340f98761cf76eec29e969d (patch) | |
tree | c68db21c3c34d5a23584136d0ccd74a5fedb8c50 /src | |
parent | 58202eaf80bdfe1273396d2abe6b1fee8fed937a (diff) | |
download | qtlocation-mapboxgl-d886d3e4c04801e57340f98761cf76eec29e969d.tar.gz |
[core] Factor out setVisibility conversion
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/layer.cpp | 19 | ||||
-rw-r--r-- | src/mbgl/style/layers/background_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/circle_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_extrusion_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/heatmap_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/hillshade_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/layer.cpp.ejs | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/line_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/raster_layer.cpp | 14 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 14 |
11 files changed, 29 insertions, 130 deletions
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp index 142fe313cf..31ff5bf47a 100644 --- a/src/mbgl/style/layer.cpp +++ b/src/mbgl/style/layer.cpp @@ -1,6 +1,7 @@ #include <mbgl/style/layer.hpp> #include <mbgl/style/layer_impl.hpp> #include <mbgl/style/layer_observer.hpp> +#include <mbgl/style/conversion/constant.hpp> namespace mbgl { namespace style { @@ -38,5 +39,23 @@ void Layer::setObserver(LayerObserver* observer_) { observer = observer_ ? observer_ : &nullObserver; } +optional<conversion::Error> Layer::setVisibility(const conversion::Convertible& value) { + using namespace conversion; + + if (isUndefined(value)) { + setVisibility(VisibilityType::Visible); + return nullopt; + } + + Error error; + optional<VisibilityType> visibility = convert<VisibilityType>(value, error); + if (!visibility) { + return error; + } + + setVisibility(*visibility); + return nullopt; +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index 88e175cb7c..e47b41daa8 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -273,19 +273,7 @@ optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const optional<Error> BackgroundLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index eb3227da37..1dae77547b 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -718,19 +718,7 @@ optional<Error> CircleLayer::setPaintProperty(const std::string& name, const Con optional<Error> CircleLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 33f5bbe87c..db90415daa 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -520,19 +520,7 @@ optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, co optional<Error> FillExtrusionLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index c2756dc90e..2da131b6b2 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -520,19 +520,7 @@ optional<Error> FillLayer::setPaintProperty(const std::string& name, const Conve optional<Error> FillLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index 69499e7d4a..df00558135 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -405,19 +405,7 @@ optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Co optional<Error> HeatmapLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp index 9ccdd1567b..fb96c681cc 100644 --- a/src/mbgl/style/layers/hillshade_layer.cpp +++ b/src/mbgl/style/layers/hillshade_layer.cpp @@ -430,19 +430,7 @@ optional<Error> HillshadeLayer::setPaintProperty(const std::string& name, const optional<Error> HillshadeLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 8a6db749cf..4e80a7bf74 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -257,19 +257,7 @@ case util::hashFNV1a("<%- property.name %>"): optional<Error> <%- camelize(type) %>Layer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index cc6bfdde37..c744adad95 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -732,19 +732,7 @@ optional<Error> LineLayer::setPaintProperty(const std::string& name, const Conve optional<Error> LineLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index da3f7f8a18..45d3240833 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -519,19 +519,7 @@ optional<Error> RasterLayer::setPaintProperty(const std::string& name, const Con optional<Error> RasterLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index e7cba19ea5..48af6b13aa 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -1432,19 +1432,7 @@ optional<Error> SymbolLayer::setPaintProperty(const std::string& name, const Con optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Convertible& value) { if (name == "visibility") { - if (isUndefined(value)) { - setVisibility(VisibilityType::Visible); - return nullopt; - } - - Error error; - optional<VisibilityType> visibility = convert<VisibilityType>(value, error); - if (!visibility) { - return error; - } - - setVisibility(*visibility); - return nullopt; + return Layer::setVisibility(value); } enum class Property { |