diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-03-11 10:26:19 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-03-13 17:14:53 +0200 |
commit | 8be135231d9efe41a3b12037518d02b36104e8cf (patch) | |
tree | efecd5380232f899aed2cd5824dc16f057f0469a /include/mbgl/style/expression/format_expression.hpp | |
parent | 8a51362bccbd6487dd1ed8518443b16ba6114fd8 (diff) | |
download | qtlocation-mapboxgl-8be135231d9efe41a3b12037518d02b36104e8cf.tar.gz |
[core] Add possibility of overriding paint properties inside format expression #14062
* [core] Add format override expression and formatted section to evaluation context
* [core] Add textColor to TaggedString's formatted section
* [core] Add FormatSectionOverrides and introduce overridable properties
* [core] Populate symbol layer paint properties for text sections
* [core] Add benchmark for style that uses text-color override
* [core] Add unit test for FormatOverrideExpression
* [core] Add unit test for FormatSectionOverrides
Diffstat (limited to 'include/mbgl/style/expression/format_expression.hpp')
-rw-r--r-- | include/mbgl/style/expression/format_expression.hpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/include/mbgl/style/expression/format_expression.hpp b/include/mbgl/style/expression/format_expression.hpp index b00674a88e..180df0139d 100644 --- a/include/mbgl/style/expression/format_expression.hpp +++ b/include/mbgl/style/expression/format_expression.hpp @@ -1,11 +1,7 @@ #pragma once #include <mbgl/style/expression/expression.hpp> -#include <mbgl/style/expression/formatted.hpp> #include <mbgl/style/expression/parsing_context.hpp> -#include <mbgl/style/conversion.hpp> - -#include <memory> namespace mbgl { namespace style { @@ -14,16 +10,18 @@ namespace expression { struct FormatExpressionSection { FormatExpressionSection(std::unique_ptr<Expression> text_, optional<std::unique_ptr<Expression>> fontScale_, - optional<std::unique_ptr<Expression>> textFont_); + optional<std::unique_ptr<Expression>> textFont_, + optional<std::unique_ptr<Expression>> textColor_); std::shared_ptr<Expression> text; optional<std::shared_ptr<Expression>> fontScale; optional<std::shared_ptr<Expression>> textFont; + optional<std::shared_ptr<Expression>> textColor; }; -class FormatExpression : public Expression { +class FormatExpression final : public Expression { public: - FormatExpression(std::vector<FormatExpressionSection> sections); + explicit FormatExpression(std::vector<FormatExpressionSection> sections); EvaluationResult evaluate(const EvaluationContext&) const override; static ParseResult parse(const mbgl::style::conversion::Convertible&, ParsingContext&); @@ -38,13 +36,12 @@ public: return { nullopt }; } + const std::vector<FormatExpressionSection>& getSections() const { return sections; } + mbgl::Value serialize() const override; std::string getOperator() const override { return "format"; } private: std::vector<FormatExpressionSection> sections; - std::unique_ptr<Expression> text; - optional<std::unique_ptr<Expression>> fontScale; - optional<std::unique_ptr<Expression>> textFont; }; } // namespace expression |