Skip to content

Commit

Permalink
floating point values for priority style param
Browse files Browse the repository at this point in the history
- floating point values for priority will be used soon once
tilezen/vector-datasource#988 lands in
tilzen tiles
  • Loading branch information
tallytalwar committed Jan 19, 2019
1 parent 44e094b commit b6529ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion core/src/scene/styleContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Val
break;
}
case StyleParamKey::angle:
case StyleParamKey::priority:
case StyleParamKey::text_priority:
case StyleParamKey::text_font_stroke_width:
case StyleParamKey::placement_min_length_ratio: {
_val = static_cast<float>(number);
Expand All @@ -326,7 +328,6 @@ bool StyleContext::evalStyle(FunctionID _id, StyleParamKey _key, StyleParam::Val
}
case StyleParamKey::order:
case StyleParamKey::outline_order:
case StyleParamKey::priority:
case StyleParamKey::color:
case StyleParamKey::outline_color:
case StyleParamKey::text_font_fill:
Expand Down
10 changes: 5 additions & 5 deletions core/src/scene/styleParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ StyleParam::Value StyleParam::parseNode(StyleParamKey key, const YAML::Node& nod
break;
case StyleParamKey::order:
case StyleParamKey::outline_order:
case StyleParamKey::priority:
case StyleParamKey::text_max_lines:
case StyleParamKey::text_priority: {
case StyleParamKey::text_max_lines: {
int result = -1;
if (YamlUtil::getInt(node, result)) {
return static_cast<uint32_t>(result);
Expand Down Expand Up @@ -350,6 +348,8 @@ StyleParam::Value StyleParam::parseNode(StyleParamKey key, const YAML::Node& nod
LOGW("Invalid angle value: %s", Dump(node).c_str());
break;
}
case StyleParamKey::priority:
case StyleParamKey::text_priority:
case StyleParamKey::miter_limit:
case StyleParamKey::outline_miter_limit:
case StyleParamKey::placement_min_length_ratio:
Expand Down Expand Up @@ -477,9 +477,7 @@ std::string StyleParam::toString() const {
case StyleParamKey::order:
case StyleParamKey::text_order:
case StyleParamKey::outline_order:
case StyleParamKey::priority:
case StyleParamKey::text_max_lines:
case StyleParamKey::text_priority:
case StyleParamKey::color:
case StyleParamKey::outline_color:
case StyleParamKey::outline_style:
Expand All @@ -493,6 +491,8 @@ std::string StyleParam::toString() const {
case StyleParamKey::outline_join:
if (!value.is<uint32_t>()) break;
return k + std::to_string(value.get<uint32_t>());
case StyleParamKey::priority:
case StyleParamKey::text_priority:
case StyleParamKey::miter_limit:
case StyleParamKey::angle:
case StyleParamKey::outline_miter_limit:
Expand Down
4 changes: 2 additions & 2 deletions core/src/style/pointStyleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ auto PointStyleBuilder::applyRule(const DrawRule& _rule) const -> Parameters {
_rule.get(StyleParamKey::offset, p.labelOptions.offset);
_rule.get(StyleParamKey::buffer, p.labelOptions.buffer);

uint32_t priority = 0;
float priority = 0;
std::string repeatGroup;
StyleParam::Width repeatDistance;

if (_rule.get(StyleParamKey::priority, priority)) {
p.labelOptions.priority = (float)priority;
p.labelOptions.priority = priority;
}

_rule.get(StyleParamKey::sprite_default, p.spriteDefault);
Expand Down
6 changes: 3 additions & 3 deletions core/src/style/textStyleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,15 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule,

_rule.get(StyleParamKey::text_max_lines, p.maxLines);

uint32_t priority = 0;
float priority = 0;
size_t repeatGroupHash = 0;
std::string repeatGroup;
StyleParam::Width repeatDistance;
glm::vec2 defaultBuffer = glm::vec2(p.fontSize * 0.25f);

if (_iconText) {
if (_rule.get(StyleParamKey::text_priority, priority)) {
p.labelOptions.priority = (float)priority;
p.labelOptions.priority = priority;
}
_rule.get(StyleParamKey::text_collide, p.labelOptions.collide);
if (!_rule.get(StyleParamKey::text_interactive, p.interactive)) {
Expand Down Expand Up @@ -668,7 +668,7 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule,
}
} else {
if (_rule.get(StyleParamKey::priority, priority)) {
p.labelOptions.priority = (float)priority;
p.labelOptions.priority = priority;
}
_rule.get(StyleParamKey::collide, p.labelOptions.collide);
_rule.get(StyleParamKey::interactive, p.interactive);
Expand Down

0 comments on commit b6529ba

Please sign in to comment.