[core][android][macos][ios] Implement property functions for line-join, text-justify, text-anchor (#9583)
This commit is contained in:
@@ -26,7 +26,7 @@ auto makeLayoutPropertySetters() {
|
||||
|
||||
|
||||
result["line-cap"] = &setProperty<V, LineLayer, PropertyValue<LineCapType>, &LineLayer::setLineCap>;
|
||||
result["line-join"] = &setProperty<V, LineLayer, PropertyValue<LineJoinType>, &LineLayer::setLineJoin>;
|
||||
result["line-join"] = &setProperty<V, LineLayer, DataDrivenPropertyValue<LineJoinType>, &LineLayer::setLineJoin>;
|
||||
result["line-miter-limit"] = &setProperty<V, LineLayer, PropertyValue<float>, &LineLayer::setLineMiterLimit>;
|
||||
result["line-round-limit"] = &setProperty<V, LineLayer, PropertyValue<float>, &LineLayer::setLineRoundLimit>;
|
||||
|
||||
@@ -54,8 +54,8 @@ auto makeLayoutPropertySetters() {
|
||||
result["text-max-width"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setTextMaxWidth>;
|
||||
result["text-line-height"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setTextLineHeight>;
|
||||
result["text-letter-spacing"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setTextLetterSpacing>;
|
||||
result["text-justify"] = &setProperty<V, SymbolLayer, PropertyValue<TextJustifyType>, &SymbolLayer::setTextJustify>;
|
||||
result["text-anchor"] = &setProperty<V, SymbolLayer, PropertyValue<TextAnchorType>, &SymbolLayer::setTextAnchor>;
|
||||
result["text-justify"] = &setProperty<V, SymbolLayer, DataDrivenPropertyValue<TextJustifyType>, &SymbolLayer::setTextJustify>;
|
||||
result["text-anchor"] = &setProperty<V, SymbolLayer, DataDrivenPropertyValue<TextAnchorType>, &SymbolLayer::setTextAnchor>;
|
||||
result["text-max-angle"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setTextMaxAngle>;
|
||||
result["text-rotate"] = &setProperty<V, SymbolLayer, DataDrivenPropertyValue<float>, &SymbolLayer::setTextRotate>;
|
||||
result["text-padding"] = &setProperty<V, SymbolLayer, PropertyValue<float>, &SymbolLayer::setTextPadding>;
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
PropertyValue<LineCapType> getLineCap() const;
|
||||
void setLineCap(PropertyValue<LineCapType>);
|
||||
|
||||
static PropertyValue<LineJoinType> getDefaultLineJoin();
|
||||
PropertyValue<LineJoinType> getLineJoin() const;
|
||||
void setLineJoin(PropertyValue<LineJoinType>);
|
||||
static DataDrivenPropertyValue<LineJoinType> getDefaultLineJoin();
|
||||
DataDrivenPropertyValue<LineJoinType> getLineJoin() const;
|
||||
void setLineJoin(DataDrivenPropertyValue<LineJoinType>);
|
||||
|
||||
static PropertyValue<float> getDefaultLineMiterLimit();
|
||||
PropertyValue<float> getLineMiterLimit() const;
|
||||
|
||||
@@ -134,13 +134,13 @@ public:
|
||||
PropertyValue<float> getTextLetterSpacing() const;
|
||||
void setTextLetterSpacing(PropertyValue<float>);
|
||||
|
||||
static PropertyValue<TextJustifyType> getDefaultTextJustify();
|
||||
PropertyValue<TextJustifyType> getTextJustify() const;
|
||||
void setTextJustify(PropertyValue<TextJustifyType>);
|
||||
static DataDrivenPropertyValue<TextJustifyType> getDefaultTextJustify();
|
||||
DataDrivenPropertyValue<TextJustifyType> getTextJustify() const;
|
||||
void setTextJustify(DataDrivenPropertyValue<TextJustifyType>);
|
||||
|
||||
static PropertyValue<TextAnchorType> getDefaultTextAnchor();
|
||||
PropertyValue<TextAnchorType> getTextAnchor() const;
|
||||
void setTextAnchor(PropertyValue<TextAnchorType>);
|
||||
static DataDrivenPropertyValue<TextAnchorType> getDefaultTextAnchor();
|
||||
DataDrivenPropertyValue<TextAnchorType> getTextAnchor() const;
|
||||
void setTextAnchor(DataDrivenPropertyValue<TextAnchorType>);
|
||||
|
||||
static PropertyValue<float> getDefaultTextMaxAngle();
|
||||
PropertyValue<float> getTextMaxAngle() const;
|
||||
|
||||
@@ -1482,11 +1482,11 @@ public class PropertyFactory {
|
||||
/**
|
||||
* The display of lines when joining.
|
||||
*
|
||||
* @param <Z> the zoom parameter type
|
||||
* @param function a wrapper {@link CameraFunction} for String
|
||||
* @param <T> the function input type
|
||||
* @param function a wrapper function for String
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> lineJoin(CameraFunction<Z, String> function) {
|
||||
public static <T> PropertyValue<Function<T, String>> lineJoin(Function<T, String> function) {
|
||||
return new LayoutPropertyValue<>("line-join", function);
|
||||
}
|
||||
|
||||
@@ -2103,11 +2103,11 @@ public class PropertyFactory {
|
||||
/**
|
||||
* Text justification options.
|
||||
*
|
||||
* @param <Z> the zoom parameter type
|
||||
* @param function a wrapper {@link CameraFunction} for String
|
||||
* @param <T> the function input type
|
||||
* @param function a wrapper function for String
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textJustify(CameraFunction<Z, String> function) {
|
||||
public static <T> PropertyValue<Function<T, String>> textJustify(Function<T, String> function) {
|
||||
return new LayoutPropertyValue<>("text-justify", function);
|
||||
}
|
||||
|
||||
@@ -2126,11 +2126,11 @@ public class PropertyFactory {
|
||||
/**
|
||||
* Part of the text placed closest to the anchor.
|
||||
*
|
||||
* @param <Z> the zoom parameter type
|
||||
* @param function a wrapper {@link CameraFunction} for String
|
||||
* @param <T> the function input type
|
||||
* @param function a wrapper function for String
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textAnchor(CameraFunction<Z, String> function) {
|
||||
public static <T> PropertyValue<Function<T, String>> textAnchor(Function<T, String> function) {
|
||||
return new LayoutPropertyValue<>("text-anchor", function);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,63 @@ public class LineLayerTest extends BaseActivityTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineJoinAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("line-join");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
lineJoin(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getLineJoin());
|
||||
assertNotNull(layer.getLineJoin().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getLineJoin().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineJoin().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getLineJoin().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineJoinAsIntervalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("line-join");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
lineJoin(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
stop(1, lineJoin(LINE_JOIN_BEVEL))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getLineJoin());
|
||||
assertNotNull(layer.getLineJoin().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getLineJoin().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineJoin().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.getLineJoin().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimitAsConstant() {
|
||||
validateTestSetup();
|
||||
|
||||
@@ -1887,6 +1887,63 @@ public class SymbolLayerTest extends BaseActivityTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextJustifyAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("text-justify");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
textJustify(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getTextJustify());
|
||||
assertNotNull(layer.getTextJustify().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getTextJustify().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextJustify().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getTextJustify().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextJustifyAsIntervalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("text-justify");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
textJustify(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
stop(1, textJustify(TEXT_JUSTIFY_LEFT))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getTextJustify());
|
||||
assertNotNull(layer.getTextJustify().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getTextJustify().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextJustify().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.getTextJustify().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextAnchorAsConstant() {
|
||||
validateTestSetup();
|
||||
@@ -1935,6 +1992,63 @@ public class SymbolLayerTest extends BaseActivityTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextAnchorAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("text-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
textAnchor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getTextAnchor());
|
||||
assertNotNull(layer.getTextAnchor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getTextAnchor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextAnchor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getTextAnchor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextAnchorAsIntervalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("text-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
textAnchor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
stop(1, textAnchor(TEXT_ANCHOR_CENTER))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getTextAnchor());
|
||||
assertNotNull(layer.getTextAnchor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getTextAnchor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextAnchor().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.getTextAnchor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTextMaxAngleAsConstant() {
|
||||
validateTestSetup();
|
||||
|
||||
@@ -149,8 +149,18 @@ MGL_EXPORT
|
||||
You can set this property to an instance of:
|
||||
|
||||
* `MGLConstantStyleValue`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of
|
||||
`MGLInterpolationModeInterval`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLSourceStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
* `MGLInterpolationModeIdentity`
|
||||
* `MGLCompositeStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
*/
|
||||
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *lineJoin;
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace mbgl {
|
||||
- (void)setLineJoin:(MGLStyleValue<NSValue *> *)lineJoin {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumPropertyValue(lineJoin);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toDataDrivenPropertyValue(lineJoin);
|
||||
self.rawLayer->setLineJoin(mbglValue);
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ namespace mbgl {
|
||||
|
||||
auto propertyValue = self.rawLayer->getLineJoin();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumStyleValue(self.rawLayer->getDefaultLineJoin());
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toDataDrivenStyleValue(self.rawLayer->getDefaultLineJoin());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toEnumStyleValue(propertyValue);
|
||||
return MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setLineMiterLimit:(MGLStyleValue<NSNumber *> *)lineMiterLimit {
|
||||
|
||||
@@ -924,8 +924,18 @@ MGL_EXPORT
|
||||
You can set this property to an instance of:
|
||||
|
||||
* `MGLConstantStyleValue`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of
|
||||
`MGLInterpolationModeInterval`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLSourceStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
* `MGLInterpolationModeIdentity`
|
||||
* `MGLCompositeStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
*/
|
||||
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textAnchor;
|
||||
|
||||
@@ -1043,8 +1053,18 @@ MGL_EXPORT
|
||||
You can set this property to an instance of:
|
||||
|
||||
* `MGLConstantStyleValue`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of
|
||||
`MGLInterpolationModeInterval`
|
||||
* `MGLCameraStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLSourceStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
* `MGLInterpolationModeIdentity`
|
||||
* `MGLCompositeStyleFunction` with an interpolation mode of:
|
||||
* `MGLInterpolationModeExponential`
|
||||
* `MGLInterpolationModeInterval`
|
||||
* `MGLInterpolationModeCategorical`
|
||||
*/
|
||||
@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textJustification;
|
||||
|
||||
|
||||
@@ -586,7 +586,7 @@ namespace mbgl {
|
||||
- (void)setTextAnchor:(MGLStyleValue<NSValue *> *)textAnchor {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumPropertyValue(textAnchor);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toDataDrivenPropertyValue(textAnchor);
|
||||
self.rawLayer->setTextAnchor(mbglValue);
|
||||
}
|
||||
|
||||
@@ -595,9 +595,9 @@ namespace mbgl {
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextAnchor();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(self.rawLayer->getDefaultTextAnchor());
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toDataDrivenStyleValue(self.rawLayer->getDefaultTextAnchor());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toEnumStyleValue(propertyValue);
|
||||
return MGLStyleValueTransformer<mbgl::style::TextAnchorType, NSValue *, mbgl::style::TextAnchorType, MGLTextAnchor>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextFontNames:(MGLStyleValue<NSArray<NSString *> *> *)textFontNames {
|
||||
@@ -675,7 +675,7 @@ namespace mbgl {
|
||||
- (void)setTextJustification:(MGLStyleValue<NSValue *> *)textJustification {
|
||||
MGLAssertStyleLayerIsValid();
|
||||
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumPropertyValue(textJustification);
|
||||
auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toDataDrivenPropertyValue(textJustification);
|
||||
self.rawLayer->setTextJustify(mbglValue);
|
||||
}
|
||||
|
||||
@@ -684,9 +684,9 @@ namespace mbgl {
|
||||
|
||||
auto propertyValue = self.rawLayer->getTextJustify();
|
||||
if (propertyValue.isUndefined()) {
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumStyleValue(self.rawLayer->getDefaultTextJustify());
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toDataDrivenStyleValue(self.rawLayer->getDefaultTextJustify());
|
||||
}
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumStyleValue(propertyValue);
|
||||
return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toDataDrivenStyleValue(propertyValue);
|
||||
}
|
||||
|
||||
- (void)setTextJustify:(MGLStyleValue<NSValue *> *)textJustify {
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLLineJoin:MGLLineJoinMiter]];
|
||||
layer.lineJoin = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::LineJoinType> propertyValue = { mbgl::style::LineJoinType::Miter };
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::style::LineJoinType> propertyValue = { mbgl::style::LineJoinType::Miter };
|
||||
XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
|
||||
@"Setting lineJoin to a constant value should update line-join.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, constantStyleValue,
|
||||
@@ -119,11 +119,6 @@
|
||||
@"Unsetting lineJoin should return line-join to the default value.");
|
||||
XCTAssertEqualObjects(layer.lineJoin, defaultStyleValue,
|
||||
@"lineJoin should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineJoin = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.lineJoin = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// line-miter-limit
|
||||
|
||||
@@ -931,7 +931,7 @@
|
||||
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextAnchor:MGLTextAnchorBottomRight]];
|
||||
layer.textAnchor = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::TextAnchorType> propertyValue = { mbgl::style::TextAnchorType::BottomRight };
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::style::TextAnchorType> propertyValue = { mbgl::style::TextAnchorType::BottomRight };
|
||||
XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue,
|
||||
@"Setting textAnchor to a constant value should update text-anchor.");
|
||||
XCTAssertEqualObjects(layer.textAnchor, constantStyleValue,
|
||||
@@ -955,11 +955,6 @@
|
||||
@"Unsetting textAnchor should return text-anchor to the default value.");
|
||||
XCTAssertEqualObjects(layer.textAnchor, defaultStyleValue,
|
||||
@"textAnchor should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.textAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.textAnchor = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// text-font
|
||||
@@ -1105,7 +1100,7 @@
|
||||
|
||||
MGLStyleValue<NSValue *> *constantStyleValue = [MGLStyleValue<NSValue *> valueWithRawValue:[NSValue valueWithMGLTextJustification:MGLTextJustificationRight]];
|
||||
layer.textJustification = constantStyleValue;
|
||||
mbgl::style::PropertyValue<mbgl::style::TextJustifyType> propertyValue = { mbgl::style::TextJustifyType::Right };
|
||||
mbgl::style::DataDrivenPropertyValue<mbgl::style::TextJustifyType> propertyValue = { mbgl::style::TextJustifyType::Right };
|
||||
XCTAssertEqual(rawLayer->getTextJustify(), propertyValue,
|
||||
@"Setting textJustification to a constant value should update text-justify.");
|
||||
XCTAssertEqualObjects(layer.textJustification, constantStyleValue,
|
||||
@@ -1129,11 +1124,6 @@
|
||||
@"Unsetting textJustification should return text-justify to the default value.");
|
||||
XCTAssertEqualObjects(layer.textJustification, defaultStyleValue,
|
||||
@"textJustification should return the default value after being unset.");
|
||||
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.textJustification = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
functionStyleValue = [MGLStyleValue<NSValue *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil];
|
||||
XCTAssertThrowsSpecificNamed(layer.textJustification = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it");
|
||||
}
|
||||
|
||||
// text-letter-spacing
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
"render-tests/icon-text-fit/height": "https://github.com/mapbox/mapbox-gl-native/issues/5602",
|
||||
"render-tests/icon-text-fit/width-padding": "https://github.com/mapbox/mapbox-gl-native/issues/5602",
|
||||
"render-tests/icon-text-fit/width": "https://github.com/mapbox/mapbox-gl-native/issues/5602",
|
||||
"render-tests/line-join/property-function": "https://github.com/mapbox/mapbox-gl-native/pull/9583",
|
||||
"render-tests/line-join/property-function-dasharray": "https://github.com/mapbox/mapbox-gl-native/pull/9583",
|
||||
"render-tests/line-width/property-function": "https://github.com/mapbox/mapbox-gl-js/issues/3682#issuecomment-264348200",
|
||||
"render-tests/regressions/mapbox-gl-js#2305": "https://github.com/mapbox/mapbox-gl-native/issues/6927",
|
||||
"render-tests/regressions/mapbox-gl-js#3010": "skip - needs issue",
|
||||
"render-tests/regressions/mapbox-gl-js#3548": "skip - needs issue",
|
||||
@@ -57,8 +54,6 @@
|
||||
"render-tests/runtime-styling/set-style-paint-property-fill-flat-to-extrude": "skip - needs issue",
|
||||
"render-tests/runtime-styling/source-add-geojson-inline": "skip - needs issue",
|
||||
"render-tests/symbol-placement/line": "needs issue",
|
||||
"render-tests/text-anchor/property-function": "https://github.com/mapbox/mapbox-gl-native/issues/9555",
|
||||
"render-tests/text-justify/property-function": "https://github.com/mapbox/mapbox-gl-native/issues/9559",
|
||||
"render-tests/text-keep-upright/line-placement-true-offset": "https://github.com/mapbox/mapbox-gl-native/issues/9271",
|
||||
"render-tests/text-size/composite-function-high-base": "https://github.com/mapbox/mapbox-gl-native/issues/8654",
|
||||
"render-tests/video/default": "skip - needs issue"
|
||||
|
||||
@@ -180,47 +180,6 @@ bool SymbolLayout::hasSymbolInstances() const {
|
||||
|
||||
void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions,
|
||||
const ImageMap& imageMap, const ImagePositions& imagePositions) {
|
||||
float horizontalAlign = 0.5;
|
||||
float verticalAlign = 0.5;
|
||||
|
||||
switch (layout.get<TextAnchor>()) {
|
||||
case TextAnchorType::Top:
|
||||
case TextAnchorType::Bottom:
|
||||
case TextAnchorType::Center:
|
||||
break;
|
||||
case TextAnchorType::Right:
|
||||
case TextAnchorType::TopRight:
|
||||
case TextAnchorType::BottomRight:
|
||||
horizontalAlign = 1;
|
||||
break;
|
||||
case TextAnchorType::Left:
|
||||
case TextAnchorType::TopLeft:
|
||||
case TextAnchorType::BottomLeft:
|
||||
horizontalAlign = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (layout.get<TextAnchor>()) {
|
||||
case TextAnchorType::Left:
|
||||
case TextAnchorType::Right:
|
||||
case TextAnchorType::Center:
|
||||
break;
|
||||
case TextAnchorType::Bottom:
|
||||
case TextAnchorType::BottomLeft:
|
||||
case TextAnchorType::BottomRight:
|
||||
verticalAlign = 1;
|
||||
break;
|
||||
case TextAnchorType::Top:
|
||||
case TextAnchorType::TopLeft:
|
||||
case TextAnchorType::TopRight:
|
||||
verticalAlign = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
const float justify = layout.get<TextJustify>() == TextJustifyType::Right ? 1 :
|
||||
layout.get<TextJustify>() == TextJustifyType::Left ? 0 :
|
||||
0.5;
|
||||
|
||||
const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map &&
|
||||
layout.get<SymbolPlacement>() == SymbolPlacementType::Line;
|
||||
|
||||
@@ -248,9 +207,8 @@ void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyph
|
||||
/* maxWidth: ems */ layout.get<SymbolPlacement>() != SymbolPlacementType::Line ?
|
||||
layout.get<TextMaxWidth>() * oneEm : 0,
|
||||
/* lineHeight: ems */ layout.get<TextLineHeight>() * oneEm,
|
||||
/* horizontalAlign */ horizontalAlign,
|
||||
/* verticalAlign */ verticalAlign,
|
||||
/* justify */ justify,
|
||||
/* anchor */ layout.evaluate<TextAnchor>(zoom, feature),
|
||||
/* justify */ layout.evaluate<TextJustify>(zoom, feature),
|
||||
/* spacing: ems */ util::i18n::allowsLetterSpacing(*feature.text) ? layout.get<TextLetterSpacing>() * oneEm : 0.0f,
|
||||
/* translate */ Point<float>(layout.evaluate<TextOffset>(zoom, feature)[0] * oneEm, layout.evaluate<TextOffset>(zoom, feature)[1] * oneEm),
|
||||
/* verticalHeight */ oneEm,
|
||||
|
||||
@@ -15,7 +15,8 @@ LineBucket::LineBucket(const BucketParameters& parameters,
|
||||
const std::vector<const RenderLayer*>& layers,
|
||||
const style::LineLayoutProperties::Unevaluated& layout_)
|
||||
: layout(layout_.evaluate(PropertyEvaluationParameters(parameters.tileID.overscaledZ))),
|
||||
overscaling(parameters.tileID.overscaleFactor()) {
|
||||
overscaling(parameters.tileID.overscaleFactor()),
|
||||
zoom(parameters.tileID.overscaledZ) {
|
||||
for (const auto& layer : layers) {
|
||||
paintPropertyBinders.emplace(
|
||||
std::piecewise_construct,
|
||||
@@ -29,7 +30,7 @@ LineBucket::LineBucket(const BucketParameters& parameters,
|
||||
void LineBucket::addFeature(const GeometryTileFeature& feature,
|
||||
const GeometryCollection& geometryCollection) {
|
||||
for (auto& line : geometryCollection) {
|
||||
addGeometry(line, feature.getType());
|
||||
addGeometry(line, feature);
|
||||
}
|
||||
|
||||
for (auto& pair : paintPropertyBinders) {
|
||||
@@ -62,7 +63,8 @@ const float LINE_DISTANCE_SCALE = 1.0 / 2.0;
|
||||
// The maximum line distance, in tile units, that fits in the buffer.
|
||||
const float MAX_LINE_DISTANCE = std::pow(2, LINE_DISTANCE_BUFFER_BITS) / LINE_DISTANCE_SCALE;
|
||||
|
||||
void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType type) {
|
||||
void LineBucket::addGeometry(const GeometryCoordinates& coordinates, const GeometryTileFeature& feature) {
|
||||
const FeatureType type = feature.getType();
|
||||
const std::size_t len = [&coordinates] {
|
||||
std::size_t l = coordinates.size();
|
||||
// If the line has duplicate vertices at the end, adjust length to remove them.
|
||||
@@ -86,7 +88,9 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType
|
||||
return;
|
||||
}
|
||||
|
||||
const float miterLimit = layout.get<LineJoin>() == LineJoinType::Bevel ? 1.05f : float(layout.get<LineMiterLimit>());
|
||||
const LineJoinType joinType = layout.evaluate<LineJoin>(zoom, feature);
|
||||
|
||||
const float miterLimit = joinType == LineJoinType::Bevel ? 1.05f : float(layout.get<LineMiterLimit>());
|
||||
|
||||
const double sharpCornerOffset = SHARP_CORNER_OFFSET * (float(util::EXTENT) / (util::tileSize * overscaling));
|
||||
|
||||
@@ -193,7 +197,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType
|
||||
|
||||
// The join if a middle vertex, otherwise the cap
|
||||
const bool middleVertex = prevCoordinate && nextCoordinate;
|
||||
LineJoinType currentJoin = layout.get<LineJoin>();
|
||||
LineJoinType currentJoin = joinType;
|
||||
const LineCapType currentCap = nextCoordinate ? beginCap : endCap;
|
||||
|
||||
if (middleVertex) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
std::map<std::string, LineProgram::PaintPropertyBinders> paintPropertyBinders;
|
||||
|
||||
private:
|
||||
void addGeometry(const GeometryCoordinates&, FeatureType);
|
||||
void addGeometry(const GeometryCoordinates&, const GeometryTileFeature&);
|
||||
|
||||
struct TriangleElement {
|
||||
TriangleElement(uint16_t a_, uint16_t b_, uint16_t c_) : a(a_), b(b_), c(c_) {}
|
||||
@@ -59,6 +59,7 @@ private:
|
||||
std::ptrdiff_t e3;
|
||||
|
||||
const uint32_t overscaling;
|
||||
const float zoom;
|
||||
|
||||
float getLineWidth(const RenderLineLayer& layer) const;
|
||||
};
|
||||
|
||||
@@ -24,25 +24,6 @@ precision highp float;
|
||||
|
||||
#endif
|
||||
|
||||
float evaluate_zoom_function_1(const vec4 values, const float t) {
|
||||
if (t < 1.0) {
|
||||
return mix(values[0], values[1], t);
|
||||
} else if (t < 2.0) {
|
||||
return mix(values[1], values[2], t - 1.0);
|
||||
} else {
|
||||
return mix(values[2], values[3], t - 2.0);
|
||||
}
|
||||
}
|
||||
vec4 evaluate_zoom_function_4(const vec4 value0, const vec4 value1, const vec4 value2, const vec4 value3, const float t) {
|
||||
if (t < 1.0) {
|
||||
return mix(value0, value1, t);
|
||||
} else if (t < 2.0) {
|
||||
return mix(value1, value2, t - 1.0);
|
||||
} else {
|
||||
return mix(value2, value3, t - 2.0);
|
||||
}
|
||||
}
|
||||
|
||||
// Unpack a pair of values that have been packed into a single float.
|
||||
// The packed values are assumed to be 8-bit unsigned integers, and are
|
||||
// packed like so:
|
||||
@@ -54,8 +35,8 @@ vec2 unpack_float(const float packedValue) {
|
||||
}
|
||||
|
||||
|
||||
// To minimize the number of attributes needed in the mapbox-gl-native shaders,
|
||||
// we encode a 4-component color into a pair of floats (i.e. a vec2) as follows:
|
||||
// To minimize the number of attributes needed, we encode a 4-component
|
||||
// color into a pair of floats (i.e. a vec2) as follows:
|
||||
// [ floor(color.r * 255) * 256 + color.g * 255,
|
||||
// floor(color.b * 255) * 256 + color.g * 255 ]
|
||||
vec4 decode_color(const vec2 encodedColor) {
|
||||
|
||||
@@ -33,6 +33,9 @@ template class CategoricalStops<Color>;
|
||||
template class CategoricalStops<std::array<float, 2>>;
|
||||
template class CategoricalStops<std::string>;
|
||||
template class CategoricalStops<TextTransformType>;
|
||||
template class CategoricalStops<TextJustifyType>;
|
||||
template class CategoricalStops<TextAnchorType>;
|
||||
template class CategoricalStops<LineJoinType>;
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -36,10 +36,37 @@ optional<TextTransformType> IdentityStops<TextTransformType>::evaluate(const Val
|
||||
if (!value.is<std::string>()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
return Enum<TextTransformType>::toEnum(value.get<std::string>());
|
||||
}
|
||||
|
||||
template <>
|
||||
optional<TextJustifyType> IdentityStops<TextJustifyType>::evaluate(const Value& value) const {
|
||||
if (!value.is<std::string>()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Enum<TextJustifyType>::toEnum(value.get<std::string>());
|
||||
}
|
||||
|
||||
template <>
|
||||
optional<TextAnchorType> IdentityStops<TextAnchorType>::evaluate(const Value& value) const {
|
||||
if (!value.is<std::string>()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Enum<TextAnchorType>::toEnum(value.get<std::string>());
|
||||
}
|
||||
|
||||
template <>
|
||||
optional<LineJoinType> IdentityStops<LineJoinType>::evaluate(const Value& value) const {
|
||||
if (!value.is<std::string>()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Enum<LineJoinType>::toEnum(value.get<std::string>());
|
||||
}
|
||||
|
||||
template <>
|
||||
optional<std::array<float, 2>> IdentityStops<std::array<float, 2>>::evaluate(const Value& value) const {
|
||||
if (!value.is<std::vector<Value>>()) {
|
||||
|
||||
@@ -108,15 +108,15 @@ void LineLayer::setLineCap(PropertyValue<LineCapType> value) {
|
||||
baseImpl = std::move(impl_);
|
||||
observer->onLayerChanged(*this);
|
||||
}
|
||||
PropertyValue<LineJoinType> LineLayer::getDefaultLineJoin() {
|
||||
DataDrivenPropertyValue<LineJoinType> LineLayer::getDefaultLineJoin() {
|
||||
return LineJoin::defaultValue();
|
||||
}
|
||||
|
||||
PropertyValue<LineJoinType> LineLayer::getLineJoin() const {
|
||||
DataDrivenPropertyValue<LineJoinType> LineLayer::getLineJoin() const {
|
||||
return impl().layout.get<LineJoin>();
|
||||
}
|
||||
|
||||
void LineLayer::setLineJoin(PropertyValue<LineJoinType> value) {
|
||||
void LineLayer::setLineJoin(DataDrivenPropertyValue<LineJoinType> value) {
|
||||
if (value == getLineJoin())
|
||||
return;
|
||||
auto impl_ = mutableImpl();
|
||||
|
||||
@@ -17,7 +17,7 @@ struct LineCap : LayoutProperty<LineCapType> {
|
||||
static LineCapType defaultValue() { return LineCapType::Butt; }
|
||||
};
|
||||
|
||||
struct LineJoin : LayoutProperty<LineJoinType> {
|
||||
struct LineJoin : DataDrivenLayoutProperty<LineJoinType> {
|
||||
static constexpr const char * key = "line-join";
|
||||
static LineJoinType defaultValue() { return LineJoinType::Miter; }
|
||||
};
|
||||
|
||||
@@ -476,15 +476,15 @@ void SymbolLayer::setTextLetterSpacing(PropertyValue<float> value) {
|
||||
baseImpl = std::move(impl_);
|
||||
observer->onLayerChanged(*this);
|
||||
}
|
||||
PropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() {
|
||||
DataDrivenPropertyValue<TextJustifyType> SymbolLayer::getDefaultTextJustify() {
|
||||
return TextJustify::defaultValue();
|
||||
}
|
||||
|
||||
PropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const {
|
||||
DataDrivenPropertyValue<TextJustifyType> SymbolLayer::getTextJustify() const {
|
||||
return impl().layout.get<TextJustify>();
|
||||
}
|
||||
|
||||
void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) {
|
||||
void SymbolLayer::setTextJustify(DataDrivenPropertyValue<TextJustifyType> value) {
|
||||
if (value == getTextJustify())
|
||||
return;
|
||||
auto impl_ = mutableImpl();
|
||||
@@ -492,15 +492,15 @@ void SymbolLayer::setTextJustify(PropertyValue<TextJustifyType> value) {
|
||||
baseImpl = std::move(impl_);
|
||||
observer->onLayerChanged(*this);
|
||||
}
|
||||
PropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() {
|
||||
DataDrivenPropertyValue<TextAnchorType> SymbolLayer::getDefaultTextAnchor() {
|
||||
return TextAnchor::defaultValue();
|
||||
}
|
||||
|
||||
PropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const {
|
||||
DataDrivenPropertyValue<TextAnchorType> SymbolLayer::getTextAnchor() const {
|
||||
return impl().layout.get<TextAnchor>();
|
||||
}
|
||||
|
||||
void SymbolLayer::setTextAnchor(PropertyValue<TextAnchorType> value) {
|
||||
void SymbolLayer::setTextAnchor(DataDrivenPropertyValue<TextAnchorType> value) {
|
||||
if (value == getTextAnchor())
|
||||
return;
|
||||
auto impl_ = mutableImpl();
|
||||
|
||||
@@ -132,12 +132,12 @@ struct TextLetterSpacing : LayoutProperty<float> {
|
||||
static float defaultValue() { return 0; }
|
||||
};
|
||||
|
||||
struct TextJustify : LayoutProperty<TextJustifyType> {
|
||||
struct TextJustify : DataDrivenLayoutProperty<TextJustifyType> {
|
||||
static constexpr const char * key = "text-justify";
|
||||
static TextJustifyType defaultValue() { return TextJustifyType::Center; }
|
||||
};
|
||||
|
||||
struct TextAnchor : LayoutProperty<TextAnchorType> {
|
||||
struct TextAnchor : DataDrivenLayoutProperty<TextAnchorType> {
|
||||
static constexpr const char * key = "text-anchor";
|
||||
static TextAnchorType defaultValue() { return TextAnchorType::Center; }
|
||||
};
|
||||
|
||||
@@ -200,9 +200,8 @@ void shapeLines(Shaping& shaping,
|
||||
const std::vector<std::u16string>& lines,
|
||||
const float spacing,
|
||||
const float lineHeight,
|
||||
const float horizontalAlign,
|
||||
const float verticalAlign,
|
||||
const float justify,
|
||||
const style::TextAnchorType textAnchor,
|
||||
const style::TextJustifyType textJustify,
|
||||
const float verticalHeight,
|
||||
const WritingModeType writingMode,
|
||||
const Glyphs& glyphs) {
|
||||
@@ -214,6 +213,10 @@ void shapeLines(Shaping& shaping,
|
||||
float y = yOffset;
|
||||
|
||||
float maxLineLength = 0;
|
||||
|
||||
const float justify = textJustify == style::TextJustifyType::Right ? 1 :
|
||||
textJustify == style::TextJustifyType::Left ? 0 :
|
||||
0.5;
|
||||
|
||||
for (std::u16string line : lines) {
|
||||
// Collapse whitespace so it doesn't throw off justification
|
||||
@@ -254,11 +257,48 @@ void shapeLines(Shaping& shaping,
|
||||
x = 0;
|
||||
y += lineHeight;
|
||||
}
|
||||
|
||||
align(shaping, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight,
|
||||
lines.size());
|
||||
|
||||
float horizontalAlign = 0.5;
|
||||
float verticalAlign = 0.5;
|
||||
|
||||
switch (textAnchor) {
|
||||
case style::TextAnchorType::Top:
|
||||
case style::TextAnchorType::Bottom:
|
||||
case style::TextAnchorType::Center:
|
||||
break;
|
||||
case style::TextAnchorType::Right:
|
||||
case style::TextAnchorType::TopRight:
|
||||
case style::TextAnchorType::BottomRight:
|
||||
horizontalAlign = 1;
|
||||
break;
|
||||
case style::TextAnchorType::Left:
|
||||
case style::TextAnchorType::TopLeft:
|
||||
case style::TextAnchorType::BottomLeft:
|
||||
horizontalAlign = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (textAnchor) {
|
||||
case style::TextAnchorType::Left:
|
||||
case style::TextAnchorType::Right:
|
||||
case style::TextAnchorType::Center:
|
||||
break;
|
||||
case style::TextAnchorType::Bottom:
|
||||
case style::TextAnchorType::BottomLeft:
|
||||
case style::TextAnchorType::BottomRight:
|
||||
verticalAlign = 1;
|
||||
break;
|
||||
case style::TextAnchorType::Top:
|
||||
case style::TextAnchorType::TopLeft:
|
||||
case style::TextAnchorType::TopRight:
|
||||
verticalAlign = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
align(shaping, justify, horizontalAlign, verticalAlign,
|
||||
maxLineLength, lineHeight, lines.size());
|
||||
const uint32_t height = lines.size() * lineHeight;
|
||||
|
||||
|
||||
// Calculate the bounding box
|
||||
shaping.top += -verticalAlign * height;
|
||||
shaping.bottom = shaping.top + height;
|
||||
@@ -269,9 +309,8 @@ void shapeLines(Shaping& shaping,
|
||||
const Shaping getShaping(const std::u16string& logicalInput,
|
||||
const float maxWidth,
|
||||
const float lineHeight,
|
||||
const float horizontalAlign,
|
||||
const float verticalAlign,
|
||||
const float justify,
|
||||
const style::TextAnchorType textAnchor,
|
||||
const style::TextJustifyType textJustify,
|
||||
const float spacing,
|
||||
const Point<float>& translate,
|
||||
const float verticalHeight,
|
||||
@@ -284,8 +323,8 @@ const Shaping getShaping(const std::u16string& logicalInput,
|
||||
bidi.processText(logicalInput,
|
||||
determineLineBreaks(logicalInput, spacing, maxWidth, writingMode, glyphs));
|
||||
|
||||
shapeLines(shaping, reorderedLines, spacing, lineHeight, horizontalAlign, verticalAlign,
|
||||
justify, verticalHeight, writingMode, glyphs);
|
||||
shapeLines(shaping, reorderedLines, spacing, lineHeight, textAnchor,
|
||||
textJustify, verticalHeight, writingMode, glyphs);
|
||||
|
||||
return shaping;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/text/glyph.hpp>
|
||||
#include <mbgl/renderer/image_atlas.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -44,9 +45,8 @@ public:
|
||||
const Shaping getShaping(const std::u16string& string,
|
||||
float maxWidth,
|
||||
float lineHeight,
|
||||
float horizontalAlign,
|
||||
float verticalAlign,
|
||||
float justify,
|
||||
style::TextAnchorType textAnchor,
|
||||
style::TextJustifyType textJustify,
|
||||
float spacing,
|
||||
const Point<float>& translate,
|
||||
float verticalHeight,
|
||||
|
||||
Reference in New Issue
Block a user