Add support for text-variable-anchor-offset property (#2921)
Co-authored-by: Yingfang Wang <junew@microsoft.com> Co-authored-by: Alexey Kon <48697757+random3940@users.noreply.github.com>
This commit is contained in:
@@ -44,6 +44,25 @@ Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, Padding>:
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, VariableAnchorOffsetCollection>::operator()(
|
||||
jni::JNIEnv& env, const VariableAnchorOffsetCollection& value) const {
|
||||
auto variableAnchorOffsets = jni::Array<jni::Object<>>::New(env, value.size() * 2);
|
||||
for (std::size_t i = 0; i < value.size(); i++) {
|
||||
auto anchorOffsetPair = value[i];
|
||||
auto anchorType = jni::Make<jni::String>(env,
|
||||
Enum<style::SymbolAnchorType>::toString(anchorOffsetPair.anchorType));
|
||||
auto offset = jni::Array<jni::Float>::New(env, anchorOffsetPair.offset.size());
|
||||
for (size_t j = 0; j < anchorOffsetPair.offset.size(); j++) {
|
||||
offset.Set(env, j, jni::Box(env, anchorOffsetPair.offset[j]));
|
||||
}
|
||||
|
||||
variableAnchorOffsets.Set(env, i, anchorType);
|
||||
variableAnchorOffsets.Set(env, i + 1, offset);
|
||||
}
|
||||
|
||||
return variableAnchorOffsets;
|
||||
}
|
||||
|
||||
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, style::expression::Formatted>::operator()(
|
||||
jni::JNIEnv& env, const style::expression::Formatted& value) const {
|
||||
return Formatted::New(env, value);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/expression/formatted.hpp>
|
||||
#include <mbgl/style/expression/image.hpp>
|
||||
#include <mbgl/style/variable_anchor_offset_collection.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
@@ -63,6 +64,11 @@ struct Converter<jni::Local<jni::Object<>>, Padding> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const Padding& value) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<jni::Local<jni::Object<>>, VariableAnchorOffsetCollection> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const VariableAnchorOffsetCollection& value) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<jni::Local<jni::Object<>>, style::expression::Formatted> {
|
||||
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const style::expression::Formatted& value) const;
|
||||
|
||||
@@ -189,6 +189,11 @@ jni::Local<jni::Object<>> SymbolLayer::getTextVariableAnchor(jni::JNIEnv& env) {
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextVariableAnchor()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getTextVariableAnchorOffset(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextVariableAnchorOffset()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getTextAnchor(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextAnchor()));
|
||||
@@ -540,6 +545,7 @@ void SymbolJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&SymbolLayer::getTextJustify, "nativeGetTextJustify"),
|
||||
METHOD(&SymbolLayer::getTextRadialOffset, "nativeGetTextRadialOffset"),
|
||||
METHOD(&SymbolLayer::getTextVariableAnchor, "nativeGetTextVariableAnchor"),
|
||||
METHOD(&SymbolLayer::getTextVariableAnchorOffset, "nativeGetTextVariableAnchorOffset"),
|
||||
METHOD(&SymbolLayer::getTextAnchor, "nativeGetTextAnchor"),
|
||||
METHOD(&SymbolLayer::getTextMaxAngle, "nativeGetTextMaxAngle"),
|
||||
METHOD(&SymbolLayer::getTextWritingMode, "nativeGetTextWritingMode"),
|
||||
|
||||
@@ -86,6 +86,8 @@ public:
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextVariableAnchor(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextVariableAnchorOffset(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextAnchor(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextMaxAngle(jni::JNIEnv&);
|
||||
|
||||
Reference in New Issue
Block a user