summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-12 22:21:12 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 17:11:49 +0200
commita01ecc92a079cb488d5f24d374d82e5fc34fe14b (patch)
treec3052da141be941a9dfa3d8aa1302b5cf678841d /include
parent5e3ef2e9e06afb2150b0977dbb2a1ef8e6ad2848 (diff)
downloadqtlocation-mapboxgl-a01ecc92a079cb488d5f24d374d82e5fc34fe14b.tar.gz
[core] Add image sections to format expression
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/expression/format_expression.hpp16
-rw-r--r--include/mbgl/style/expression/formatted.hpp27
2 files changed, 24 insertions, 19 deletions
diff --git a/include/mbgl/style/expression/format_expression.hpp b/include/mbgl/style/expression/format_expression.hpp
index 180df0139d..248a3cf6d4 100644
--- a/include/mbgl/style/expression/format_expression.hpp
+++ b/include/mbgl/style/expression/format_expression.hpp
@@ -8,12 +8,16 @@ namespace style {
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>> textColor_);
-
- std::shared_ptr<Expression> text;
+ explicit FormatExpressionSection(std::unique_ptr<Expression> content_);
+
+ void setTextSectionOptions(optional<std::unique_ptr<Expression>> fontScale_,
+ optional<std::unique_ptr<Expression>> textFont_,
+ optional<std::unique_ptr<Expression>> textColor_);
+
+ // Content can be expression that evaluates to String or Image.
+ std::shared_ptr<Expression> content;
+
+ // Text related section options.
optional<std::shared_ptr<Expression>> fontScale;
optional<std::shared_ptr<Expression>> textFont;
optional<std::shared_ptr<Expression>> textColor;
diff --git a/include/mbgl/style/expression/formatted.hpp b/include/mbgl/style/expression/formatted.hpp
index 09edad240f..d089e12d9d 100644
--- a/include/mbgl/style/expression/formatted.hpp
+++ b/include/mbgl/style/expression/formatted.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/expression/image.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/font_stack.hpp>
#include <mbgl/util/optional.hpp>
@@ -17,17 +18,19 @@ extern const char* const kFormattedSectionTextFont;
extern const char* const kFormattedSectionTextColor;
struct FormattedSection {
- FormattedSection(std::string text_,
- optional<double> fontScale_,
- optional<FontStack> fontStack_,
- optional<Color> textColor_)
- : text(std::move(text_))
- , fontScale(std::move(fontScale_))
- , fontStack(std::move(fontStack_))
- , textColor(std::move(textColor_))
- {}
+ explicit FormattedSection(std::string text_,
+ optional<double> fontScale_,
+ optional<FontStack> fontStack_,
+ optional<Color> textColor_)
+ : text(std::move(text_)),
+ fontScale(std::move(fontScale_)),
+ fontStack(std::move(fontStack_)),
+ textColor(std::move(textColor_)) {}
+
+ explicit FormattedSection(Image image_) : image(std::move(image_)) {}
std::string text;
+ optional<Image> image;
optional<double> fontScale;
optional<FontStack> fontStack;
optional<Color> textColor;
@@ -50,10 +53,8 @@ public:
std::string toString() const;
mbgl::Value toObject() const;
- bool empty() const {
- return sections.empty() || sections.at(0).text.empty();
- }
-
+ bool empty() const;
+
std::vector<FormattedSection> sections;
};