summaryrefslogtreecommitdiff
path: root/src/mbgl/text/tagged_string.hpp
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-03-11 10:26:19 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-03-13 17:14:53 +0200
commit8be135231d9efe41a3b12037518d02b36104e8cf (patch)
treeefecd5380232f899aed2cd5824dc16f057f0469a /src/mbgl/text/tagged_string.hpp
parent8a51362bccbd6487dd1ed8518443b16ba6114fd8 (diff)
downloadqtlocation-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 'src/mbgl/text/tagged_string.hpp')
-rw-r--r--src/mbgl/text/tagged_string.hpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mbgl/text/tagged_string.hpp b/src/mbgl/text/tagged_string.hpp
index 476c2225f0..2607e10889 100644
--- a/src/mbgl/text/tagged_string.hpp
+++ b/src/mbgl/text/tagged_string.hpp
@@ -1,17 +1,23 @@
#pragma once
-#include <mbgl/text/glyph.hpp>
#include <mbgl/text/bidi.hpp>
+#include <mbgl/style/expression/formatted.hpp>
+#include <mbgl/util/font_stack.hpp>
namespace mbgl {
struct SectionOptions {
- SectionOptions(double scale_, FontStackHash fontStackHash_)
- : scale(scale_), fontStackHash(fontStackHash_)
+ SectionOptions(double scale_, FontStack fontStack_, optional<Color> textColor_ = nullopt)
+ : scale(scale_),
+ fontStackHash(FontStackHasher()(fontStack_)),
+ fontStack(std::move(fontStack_)),
+ textColor(std::move(textColor_))
{}
double scale;
FontStackHash fontStackHash;
+ FontStack fontStack;
+ optional<Color> textColor;
};
/**
@@ -71,7 +77,11 @@ struct TaggedString {
return styledText;
}
- void addSection(const std::u16string& text, double scale, FontStackHash fontStack);
+ void addSection(const std::u16string& text,
+ double scale,
+ FontStack fontStack,
+ optional<Color> textColor_ = nullopt);
+
const SectionOptions& sectionAt(std::size_t index) const {
return sections.at(index);
}
@@ -88,7 +98,7 @@ struct TaggedString {
void trim();
void verticalizePunctuation();
-
+
private:
StyledText styledText;
std::vector<SectionOptions> sections;