diff --git a/core/src/scene/styleParam.cpp b/core/src/scene/styleParam.cpp index 180489ff85..516cdf8a91 100644 --- a/core/src/scene/styleParam.cpp +++ b/core/src/scene/styleParam.cpp @@ -50,8 +50,8 @@ const std::map s_StyleParamMap = { {"placement_spacing", StyleParamKey::placement_spacing}, {"placement_min_length_ratio", StyleParamKey::placement_min_length_ratio}, {"priority", StyleParamKey::priority}, - {"repeat_distance", StyleParamKey::text_repeat_distance}, - {"repeat_group", StyleParamKey::text_repeat_group}, + {"repeat_distance", StyleParamKey::repeat_distance}, + {"repeat_group", StyleParamKey::repeat_group}, {"size", StyleParamKey::size}, {"sprite", StyleParamKey::sprite}, {"sprite_default", StyleParamKey::sprite_default}, @@ -234,6 +234,7 @@ StyleParam::Value StyleParam::parseString(StyleParamKey key, const std::string& case StyleParamKey::sprite_default: case StyleParamKey::style: case StyleParamKey::outline_style: + case StyleParamKey::repeat_group: case StyleParamKey::text_repeat_group: return _value; case StyleParamKey::text_font_size: { @@ -290,6 +291,7 @@ StyleParam::Value StyleParam::parseString(StyleParamKey key, const std::string& return Width(placementSpacing); } + case StyleParamKey::repeat_distance: case StyleParamKey::text_repeat_distance: { ValueUnitPair repeatDistance; repeatDistance.unit = Unit::pixel; @@ -385,6 +387,7 @@ std::string StyleParam::toString() const { auto p = value.get(); return k + "(" + std::to_string(p.x) + "px, " + std::to_string(p.y) + "px)"; } + case StyleParamKey::repeat_group: case StyleParamKey::transition_hide_time: case StyleParamKey::text_transition_hide_time: case StyleParamKey::transition_show_time: @@ -433,6 +436,7 @@ std::string StyleParam::toString() const { case StyleParamKey::color: case StyleParamKey::outline_color: case StyleParamKey::outline_style: + case StyleParamKey::repeat_distance: case StyleParamKey::text_font_fill: case StyleParamKey::text_font_stroke_color: case StyleParamKey::text_repeat_distance: diff --git a/core/src/scene/styleParam.h b/core/src/scene/styleParam.h index 940b9543e6..69f772470f 100644 --- a/core/src/scene/styleParam.h +++ b/core/src/scene/styleParam.h @@ -48,6 +48,8 @@ enum class StyleParamKey : uint8_t { placement_spacing, placement_min_length_ratio, priority, + repeat_distance, + repeat_group, text_order, text_priority, text_repeat_distance, diff --git a/core/src/style/pointStyleBuilder.cpp b/core/src/style/pointStyleBuilder.cpp index a30b59a446..25fb2747c3 100644 --- a/core/src/style/pointStyleBuilder.cpp +++ b/core/src/style/pointStyleBuilder.cpp @@ -121,6 +121,10 @@ auto PointStyleBuilder::applyRule(const DrawRule& _rule, const Properties& _prop _rule.get(StyleParamKey::offset, p.labelOptions.offset); uint32_t priority; + size_t repeatGroupHash = 0; + std::string repeatGroup; + StyleParam::Width repeatDistance; + if (_rule.get(StyleParamKey::priority, priority)) { p.labelOptions.priority = (float)priority; } @@ -149,6 +153,21 @@ auto PointStyleBuilder::applyRule(const DrawRule& _rule, const Properties& _prop _rule.get(StyleParamKey::flat, p.labelOptions.flat); _rule.get(StyleParamKey::anchor, p.labelOptions.anchors); + if (_rule.get(StyleParamKey::repeat_distance, repeatDistance)) { + p.labelOptions.repeatDistance = repeatDistance.value; + } + + if (p.labelOptions.repeatDistance > 0.f) { + if (_rule.get(StyleParamKey::repeat_group, repeatGroup)) { + hash_combine(repeatGroupHash, repeatGroup); + } else { + repeatGroupHash = _rule.getParamSetHash(); + } + + p.labelOptions.repeatGroup = repeatGroupHash; + p.labelOptions.repeatDistance *= m_style.pixelScale(); + } + if (p.labelOptions.anchors.count == 0) { p.labelOptions.anchors.anchor = { {LabelProperty::Anchor::center} }; p.labelOptions.anchors.count = 1; diff --git a/core/src/style/textStyleBuilder.cpp b/core/src/style/textStyleBuilder.cpp index 0045ec0cff..c232ac5686 100644 --- a/core/src/style/textStyleBuilder.cpp +++ b/core/src/style/textStyleBuilder.cpp @@ -311,6 +311,10 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, _rule.get(StyleParamKey::transition_show_time, p.labelOptions.showTransition.time); uint32_t priority; + size_t repeatGroupHash = 0; + std::string repeatGroup; + StyleParam::Width repeatDistance; + if (_iconText) { if (_rule.get(StyleParamKey::text_priority, priority)) { @@ -330,6 +334,24 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, p.labelOptions.anchors.count = 4; } + // child text's repeat group params + if (_rule.get(StyleParamKey::text_repeat_distance, repeatDistance)) { + p.labelOptions.repeatDistance = repeatDistance.value; + } else { + p.labelOptions.repeatDistance = View::s_pixelsPerTile; + } + + if (p.labelOptions.repeatDistance > 0.f) { + if (_rule.get(StyleParamKey::text_repeat_group, repeatGroup)) { + hash_combine(repeatGroupHash, repeatGroup); + } else if (_rule.get(StyleParamKey::repeat_group, repeatGroup)) { //inherit from parent point + hash_combine(repeatGroupHash, repeatGroup); + } else { + repeatGroupHash = _rule.getParamSetHash(); + } + } + + _rule.get(StyleParamKey::text_transition_hide_time, p.labelOptions.hideTransition.time); _rule.get(StyleParamKey::text_transition_selected_time, p.labelOptions.selectTransition.time); _rule.get(StyleParamKey::text_transition_show_time, p.labelOptions.showTransition.time); @@ -348,28 +370,30 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule, p.labelOptions.anchors.anchor = { {LabelProperty::Anchor::center} }; p.labelOptions.anchors.count = 1; } - } - _rule.get(StyleParamKey::text_wrap, p.maxLineWidth); + if (_rule.get(StyleParamKey::repeat_distance, repeatDistance)) { + p.labelOptions.repeatDistance = repeatDistance.value; + } else { + p.labelOptions.repeatDistance = View::s_pixelsPerTile; + } + + if (p.labelOptions.repeatDistance > 0.f) { + if (_rule.get(StyleParamKey::repeat_group, repeatGroup)) { + hash_combine(repeatGroupHash, repeatGroup); + } else { + repeatGroupHash = _rule.getParamSetHash(); + } + } - size_t repeatGroupHash = 0; - std::string repeatGroup; - if (_rule.get(StyleParamKey::text_repeat_group, repeatGroup)) { - hash_combine(repeatGroupHash, repeatGroup); - } else { - repeatGroupHash = _rule.getParamSetHash(); } - StyleParam::Width repeatDistance; - if (_rule.get(StyleParamKey::text_repeat_distance, repeatDistance)) { - p.labelOptions.repeatDistance = repeatDistance.value; - } else { - p.labelOptions.repeatDistance = View::s_pixelsPerTile; + if (p.labelOptions.repeatDistance > 0.f) { + hash_combine(repeatGroupHash, p.text); + p.labelOptions.repeatGroup = repeatGroupHash; + p.labelOptions.repeatDistance *= m_style.pixelScale(); } - hash_combine(repeatGroupHash, p.text); - p.labelOptions.repeatGroup = repeatGroupHash; - p.labelOptions.repeatDistance *= m_style.pixelScale(); + _rule.get(StyleParamKey::text_wrap, p.maxLineWidth); if (auto* transform = _rule.get(StyleParamKey::text_transform)) { TextLabelProperty::transform(*transform, p.transform);