* [core] Bump gl-js version * [core] Implement image expression * [core] Use new image expression * [core] Coerce image expression to / from string * [core] Serialize evaluated image * [core] Pass available images to layout * [core] Pass images to evaluation context * [core] Set available flag value based on image availability * [core] Allow image coercion to boolean to indicate image availability * [core] Coalesce image expression * [core] Add image expression to next build system * [core] Align serialization format and evaluated type with gl-js * [core] Add images to expression evaluation method * [core] Add support for Image expression to expression test runner * [core] Unskip image expression tests * [core] Update unit tests * [core] Use image expression in annotation manager * [core] Add string to ImageExpression conversion * [core] Add image expression to expression dsl * [core] Convert tokens for implicitly created Image literal * [core] Fix clang format * [core] Split generated style code lines that are over 120 characters * [core] Add unit test for image expression equality * [core] Add image property expression evaluation unit test * [core] Unskip image expression render test * [core] Skip 'in' expression tests * [core] Ignore fill-pattern/update-feature-state render test * [core] Rename Image::serialize to Image::toValue
79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <mbgl/style/conversion.hpp>
|
|
#include <mbgl/util/color.hpp>
|
|
#include <mbgl/util/font_stack.hpp>
|
|
#include <mbgl/util/optional.hpp>
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace mbgl {
|
|
namespace style {
|
|
namespace expression {
|
|
|
|
extern const char* const kFormattedSectionFontScale;
|
|
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_))
|
|
{}
|
|
|
|
std::string text;
|
|
optional<double> fontScale;
|
|
optional<FontStack> fontStack;
|
|
optional<Color> textColor;
|
|
};
|
|
|
|
class Formatted {
|
|
public:
|
|
Formatted() = default;
|
|
|
|
Formatted(const char* plainU8String) {
|
|
sections.emplace_back(std::string(plainU8String), nullopt, nullopt, nullopt);
|
|
}
|
|
|
|
Formatted(std::vector<FormattedSection> sections_)
|
|
: sections(std::move(sections_))
|
|
{}
|
|
|
|
bool operator==(const Formatted& ) const;
|
|
|
|
std::string toString() const;
|
|
mbgl::Value toObject() const;
|
|
|
|
bool empty() const {
|
|
return sections.empty() || sections.at(0).text.empty();
|
|
}
|
|
|
|
std::vector<FormattedSection> sections;
|
|
};
|
|
|
|
} // namespace expression
|
|
|
|
namespace conversion {
|
|
|
|
template <>
|
|
struct Converter<expression::Formatted> {
|
|
public:
|
|
optional<expression::Formatted> operator()(const Convertible& value, Error& error) const;
|
|
};
|
|
|
|
template <>
|
|
struct ValueFactory<expression::Formatted> {
|
|
static Value make(const expression::Formatted& formatted) { return formatted.toObject(); }
|
|
};
|
|
|
|
} // namespace conversion
|
|
|
|
} // namespace style
|
|
} // namespace mbgl
|