diff options
author | Young Hahn <young@mapbox.com> | 2016-09-21 19:07:33 -0400 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-21 16:07:33 -0700 |
commit | 6a2ce352d1eec6dc166e351e06c6b10c633eb07c (patch) | |
tree | 58e5682522a544cd9db5c1052d538148565be9da /src/mbgl/style | |
parent | 673d8f90f24a89871905e80ef1bfd7970e61dc6c (diff) | |
download | qtlocation-mapboxgl-6a2ce352d1eec6dc166e351e06c6b10c633eb07c.tar.gz |
Better handling for undefined icon|text-rotation-alignment (#6253)
* [core, ios, android] Use `auto` value for properties with calculated defaults
* Fix render tests
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_impl.cpp | 24 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer_properties.hpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/types.cpp | 2 |
4 files changed, 24 insertions, 14 deletions
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index c9fd2c0988..6b4d7400da 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -144,7 +144,7 @@ void SymbolLayer::setIconOptional(PropertyValue<bool> value) { impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultIconRotationAlignment() { - return { AlignmentType::Viewport }; + return { AlignmentType::Auto }; } PropertyValue<AlignmentType> SymbolLayer::getIconRotationAlignment() const { @@ -270,7 +270,7 @@ void SymbolLayer::setIconOffset(PropertyValue<std::array<float, 2>> value) { impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultTextPitchAlignment() { - return { AlignmentType::Undefined }; + return { AlignmentType::Auto }; } PropertyValue<AlignmentType> SymbolLayer::getTextPitchAlignment() const { @@ -284,7 +284,7 @@ void SymbolLayer::setTextPitchAlignment(PropertyValue<AlignmentType> value) { impl->observer->onLayerLayoutPropertyChanged(*this); } PropertyValue<AlignmentType> SymbolLayer::getDefaultTextRotationAlignment() { - return { AlignmentType::Viewport }; + return { AlignmentType::Auto }; } PropertyValue<AlignmentType> SymbolLayer::getTextRotationAlignment() const { diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 1039951f5e..e85f3a90f9 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -35,19 +35,29 @@ std::unique_ptr<SymbolLayout> SymbolLayer::Impl::createLayout(BucketParameters& SymbolLayoutProperties layoutProperties = layout; CalculationParameters p(parameters.tileID.overscaledZ); - layoutProperties.symbolPlacement.calculate(p); - if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) { - layoutProperties.iconRotationAlignment.value = AlignmentType::Map; - layoutProperties.textRotationAlignment.value = AlignmentType::Map; + layoutProperties.recalculate(p); + + if (layoutProperties.iconRotationAlignment.value == AlignmentType::Auto) { + if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) { + layoutProperties.iconRotationAlignment.value = AlignmentType::Map; + } else { + layoutProperties.iconRotationAlignment.value = AlignmentType::Viewport; + } + } + + if (layoutProperties.textRotationAlignment.value == AlignmentType::Auto) { + if (layoutProperties.symbolPlacement.value == SymbolPlacementType::Line) { + layoutProperties.textRotationAlignment.value = AlignmentType::Map; + } else { + layoutProperties.textRotationAlignment.value = AlignmentType::Viewport; + } } // If unspecified `text-pitch-alignment` inherits `text-rotation-alignment` - if (layoutProperties.textPitchAlignment.value == AlignmentType::Undefined) { + if (layoutProperties.textPitchAlignment.value == AlignmentType::Auto) { layoutProperties.textPitchAlignment.value = layoutProperties.textRotationAlignment.value; } - layoutProperties.recalculate(p); - layoutProperties.textSize.calculate(CalculationParameters(18)); float textMaxSize = layoutProperties.textSize; diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index e4560ab486..fefa0ae05e 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -22,7 +22,7 @@ public: LayoutProperty<bool> iconAllowOverlap { false }; LayoutProperty<bool> iconIgnorePlacement { false }; LayoutProperty<bool> iconOptional { false }; - LayoutProperty<AlignmentType> iconRotationAlignment { AlignmentType::Viewport }; + LayoutProperty<AlignmentType> iconRotationAlignment { AlignmentType::Auto }; LayoutProperty<float> iconSize { 1 }; LayoutProperty<IconTextFitType> iconTextFit { IconTextFitType::None }; LayoutProperty<std::array<float, 4>> iconTextFitPadding { {{ 0, 0, 0, 0 }} }; @@ -31,8 +31,8 @@ public: LayoutProperty<float> iconPadding { 2 }; LayoutProperty<bool> iconKeepUpright { false }; LayoutProperty<std::array<float, 2>> iconOffset { {{ 0, 0 }} }; - LayoutProperty<AlignmentType> textPitchAlignment { AlignmentType::Undefined }; - LayoutProperty<AlignmentType> textRotationAlignment { AlignmentType::Viewport }; + LayoutProperty<AlignmentType> textPitchAlignment { AlignmentType::Auto }; + LayoutProperty<AlignmentType> textRotationAlignment { AlignmentType::Auto }; LayoutProperty<std::string> textField { "" }; LayoutProperty<std::vector<std::string>> textFont { { "Open Sans Regular", "Arial Unicode MS Regular" } }; LayoutProperty<float> textSize { 16 }; diff --git a/src/mbgl/style/types.cpp b/src/mbgl/style/types.cpp index be0b217134..bf2ba8a793 100644 --- a/src/mbgl/style/types.cpp +++ b/src/mbgl/style/types.cpp @@ -79,7 +79,7 @@ MBGL_DEFINE_ENUM(TextTransformType, { MBGL_DEFINE_ENUM(AlignmentType, { { AlignmentType::Map, "map" }, { AlignmentType::Viewport, "viewport" }, - { AlignmentType::Undefined, "undefined" }, + { AlignmentType::Auto, "auto" }, }); MBGL_DEFINE_ENUM(IconTextFitType, { |