summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-06-14 13:55:51 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-08-13 13:32:56 +0300
commit075d458403ba2c7367f06e5fc66c2a00c788634a (patch)
tree4be32175b3d9bb7475214012a534818f585dfac3
parentfc94852b284708407d8ad00b516dc5d30c6c561b (diff)
downloadqtlocation-mapboxgl-075d458403ba2c7367f06e5fc66c2a00c788634a.tar.gz
[core] Add style bindings for "text-writing-mode" layout property
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp4
-rw-r--r--include/mbgl/style/types.hpp5
-rw-r--r--src/mbgl/style/conversion/constant.cpp1
-rw-r--r--src/mbgl/style/conversion/function.cpp2
-rw-r--r--src/mbgl/style/conversion/property_value.cpp1
-rw-r--r--src/mbgl/style/expression/value.cpp3
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp32
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp8
-rw-r--r--src/mbgl/style/types.cpp5
9 files changed, 59 insertions, 2 deletions
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 2493df6046..853c0b282e 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -186,6 +186,10 @@ public:
const PropertyValue<std::vector<TextVariableAnchorType>>& getTextVariableAnchor() const;
void setTextVariableAnchor(const PropertyValue<std::vector<TextVariableAnchorType>>&);
+ static PropertyValue<std::vector<TextWritingModeType>> getDefaultTextWritingMode();
+ const PropertyValue<std::vector<TextWritingModeType>>& getTextWritingMode() const;
+ void setTextWritingMode(const PropertyValue<std::vector<TextWritingModeType>>&);
+
// Paint properties
static PropertyValue<Color> getDefaultIconColor();
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index 13a2e50f01..5d88dafb33 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -115,6 +115,11 @@ enum class IconTextFitType : uint8_t {
Height
};
+enum class TextWritingModeType : uint8_t {
+ Horizontal,
+ Vertical
+};
+
enum class LightAnchorType: bool {
Map,
Viewport
diff --git a/src/mbgl/style/conversion/constant.cpp b/src/mbgl/style/conversion/constant.cpp
index 0fcaab433b..ffdb17858d 100644
--- a/src/mbgl/style/conversion/constant.cpp
+++ b/src/mbgl/style/conversion/constant.cpp
@@ -86,6 +86,7 @@ template optional<TextTransformType> Converter<TextTransformType>::operator()(co
template optional<TranslateAnchorType> Converter<TranslateAnchorType>::operator()(const Convertible&, Error&) const;
template optional<VisibilityType> Converter<VisibilityType>::operator()(const Convertible&, Error&) const;
template optional<std::vector<TextVariableAnchorType>> Converter<std::vector<TextVariableAnchorType>>::operator()(const Convertible&, Error&) const;
+template optional<std::vector<TextWritingModeType>> Converter<std::vector<TextWritingModeType>>::operator()(const Convertible&, Error&) const;
optional<Color> Converter<Color>::operator()(const Convertible& value, Error& error) const {
optional<std::string> string = toString(value);
diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp
index 086bc4e277..646c1983a2 100644
--- a/src/mbgl/style/conversion/function.cpp
+++ b/src/mbgl/style/conversion/function.cpp
@@ -152,6 +152,8 @@ template optional<PropertyExpression<TranslateAnchorType>>
template optional<PropertyExpression<Formatted>>
convertFunctionToExpression<Formatted>(const Convertible&, Error&, bool);
+template optional<PropertyExpression<std::vector<TextWritingModeType>>>
+ convertFunctionToExpression<std::vector<TextWritingModeType>>(const Convertible&, Error&, bool);
// Ad-hoc Converters for double and int64_t. We should replace float with double wholesale,
// and promote the int64_t Converter to general use (and it should check that the input is
diff --git a/src/mbgl/style/conversion/property_value.cpp b/src/mbgl/style/conversion/property_value.cpp
index 6e1d747324..5c2f720a60 100644
--- a/src/mbgl/style/conversion/property_value.cpp
+++ b/src/mbgl/style/conversion/property_value.cpp
@@ -80,6 +80,7 @@ template optional<PropertyValue<TextJustifyType>> Converter<PropertyValue<TextJu
template optional<PropertyValue<TextTransformType>> Converter<PropertyValue<TextTransformType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
template optional<PropertyValue<TranslateAnchorType>> Converter<PropertyValue<TranslateAnchorType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
template optional<PropertyValue<mbgl::style::expression::Formatted>> Converter<PropertyValue<mbgl::style::expression::Formatted>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
+template optional<PropertyValue<std::vector<TextWritingModeType>>> Converter<PropertyValue<std::vector<TextWritingModeType>>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const;
} // namespace conversion
} // namespace style
diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp
index 7e11efaa09..6d18f1b9bd 100644
--- a/src/mbgl/style/expression/value.cpp
+++ b/src/mbgl/style/expression/value.cpp
@@ -374,6 +374,9 @@ template struct ValueConverter<HillshadeIlluminationAnchorType>;
template type::Type valueTypeToExpressionType<LightAnchorType>();
template struct ValueConverter<LightAnchorType>;
+template type::Type valueTypeToExpressionType<std::vector<TextWritingModeType>>();
+template struct ValueConverter<std::vector<TextWritingModeType>>;
+
} // namespace expression
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 6748fbd4aa..4b335ead3c 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -701,6 +701,22 @@ void SymbolLayer::setTextVariableAnchor(const PropertyValue<std::vector<TextVari
baseImpl = std::move(impl_);
observer->onLayerChanged(*this);
}
+PropertyValue<std::vector<TextWritingModeType>> SymbolLayer::getDefaultTextWritingMode() {
+ return TextWritingMode::defaultValue();
+}
+
+const PropertyValue<std::vector<TextWritingModeType>>& SymbolLayer::getTextWritingMode() const {
+ return impl().layout.get<TextWritingMode>();
+}
+
+void SymbolLayer::setTextWritingMode(const PropertyValue<std::vector<TextWritingModeType>>& value) {
+ if (value == getTextWritingMode())
+ return;
+ auto impl_ = mutableImpl();
+ impl_->layout.get<TextWritingMode>() = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
// Paint properties
@@ -1387,6 +1403,7 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
TextSize,
TextTransform,
TextVariableAnchor,
+ TextWritingMode,
};
MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>({
{ "icon-allow-overlap", static_cast<uint8_t>(Property::IconAllowOverlap) },
@@ -1428,7 +1445,8 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
{ "text-rotation-alignment", static_cast<uint8_t>(Property::TextRotationAlignment) },
{ "text-size", static_cast<uint8_t>(Property::TextSize) },
{ "text-transform", static_cast<uint8_t>(Property::TextTransform) },
- { "text-variable-anchor", static_cast<uint8_t>(Property::TextVariableAnchor) }
+ { "text-variable-anchor", static_cast<uint8_t>(Property::TextVariableAnchor) },
+ { "text-writing-mode", static_cast<uint8_t>(Property::TextWritingMode) }
});
const auto it = properties.find(name.c_str());
@@ -1763,6 +1781,18 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
}
+ if (property == Property::TextWritingMode) {
+ Error error;
+ optional<PropertyValue<std::vector<TextWritingModeType>>> typedValue = convert<PropertyValue<std::vector<TextWritingModeType>>>(value, error, false, false);
+ if (!typedValue) {
+ return error;
+ }
+
+ setTextWritingMode(*typedValue);
+ return nullopt;
+
+ }
+
return Error { "layer doesn't support this property" };
}
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index 0c2bcd2661..59d65b3c86 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -214,6 +214,11 @@ struct TextVariableAnchor : LayoutProperty<std::vector<TextVariableAnchorType>>
static std::vector<TextVariableAnchorType> defaultValue() { return { }; }
};
+struct TextWritingMode : LayoutProperty<std::vector<TextWritingModeType>> {
+ static constexpr const char *name() { return "text-writing-mode"; }
+ static std::vector<TextWritingModeType> defaultValue() { return { }; }
+};
+
struct IconColor : DataDrivenPaintProperty<Color, attributes::fill_color, uniforms::fill_color> {
static Color defaultValue() { return Color::black(); }
};
@@ -313,7 +318,8 @@ class SymbolLayoutProperties : public Properties<
TextRotationAlignment,
TextSize,
TextTransform,
- TextVariableAnchor
+ TextVariableAnchor,
+ TextWritingMode
> {};
class SymbolPaintProperties : public Properties<
diff --git a/src/mbgl/style/types.cpp b/src/mbgl/style/types.cpp
index f388a9385f..c4a7b76b66 100644
--- a/src/mbgl/style/types.cpp
+++ b/src/mbgl/style/types.cpp
@@ -96,6 +96,11 @@ MBGL_DEFINE_ENUM(TextTransformType, {
{ TextTransformType::Lowercase, "lowercase" },
});
+MBGL_DEFINE_ENUM(TextWritingModeType, {
+ { TextWritingModeType::Horizontal, "horizontal" },
+ { TextWritingModeType::Vertical, "vertical" }
+});
+
MBGL_DEFINE_ENUM(AlignmentType, {
{ AlignmentType::Map, "map" },
{ AlignmentType::Viewport, "viewport" },