Skip to content

Commit

Permalink
Change points:text:required to points:text:optional
Browse files Browse the repository at this point in the history
inverts the behavior (previous required: true is now optional: false)
  • Loading branch information
tallytalwar committed Jan 6, 2017
1 parent 6f21ca5 commit 5c086c1
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/src/labels/label.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Label {
float buffer = 0.f;
size_t paramHash = 0; // the label hash based on its styling parameters
LabelProperty::Anchors anchors;
bool required = true;
bool optional = false;
bool flat = false;
float angle = 0.f;
uint32_t featureId = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/src/labels/labelCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void LabelCollider::process(TileID _tileID, float _tileInverseScale, float _tile
// First check if the child is required is occluded
if (label->parent()->isOccluded()) {
label->occlude();
} else if (label->options().required && label->isOccluded()) {
} else if (!label->options().optional && label->isOccluded()) {
label->parent()->occlude();
label->parent()->enterState(Label::State::dead, 0.0f);
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/labels/labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ void Labels::handleOcclusions(const ViewState& _viewState) {
} while (l->isOccluded() && l->nextAnchor());

// At this point, the label has a parent that is visible,
// if it is a required label, turn the parent to occluded
// if it is not an optional label, turn the parent to occluded
if (l->isOccluded()) {
if (l->parent() && l->options().required) {
if (l->parent() && !l->options().optional) {
l->parent()->occlude();
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/scene/styleParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const std::map<std::string, StyleParamKey> s_StyleParamMap = {
{"text:priority", StyleParamKey::text_priority},
{"text:repeat_distance", StyleParamKey::text_repeat_distance},
{"text:repeat_group", StyleParamKey::text_repeat_group},
{"text:required", StyleParamKey::text_required},
{"text:optional", StyleParamKey::text_optional},
{"text:text_source", StyleParamKey::text_source},
{"text:text_wrap", StyleParamKey::text_wrap},
{"text:transition:hide:time", StyleParamKey::text_transition_hide_time},
Expand Down Expand Up @@ -242,7 +242,7 @@ StyleParam::Value StyleParam::parseString(StyleParamKey key, const std::string&
case StyleParamKey::text_visible:
case StyleParamKey::outline_visible:
case StyleParamKey::collide:
case StyleParamKey::text_required:
case StyleParamKey::text_optional:
case StyleParamKey::text_collide:
if (_value == "true") { return true; }
if (_value == "false") { return false; }
Expand Down Expand Up @@ -381,7 +381,7 @@ std::string StyleParam::toString() const {
case StyleParamKey::outline_visible:
case StyleParamKey::centroid:
case StyleParamKey::collide:
case StyleParamKey::text_required:
case StyleParamKey::text_optional:
case StyleParamKey::text_collide:
if (!value.is<bool>()) break;
return k + std::to_string(value.get<bool>());
Expand Down
2 changes: 1 addition & 1 deletion core/src/scene/styleParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum class StyleParamKey : uint8_t {
transition_hide_time,
transition_selected_time,
transition_show_time,
text_required,
text_optional,
text_transition_hide_time,
text_transition_selected_time,
text_transition_show_time,
Expand Down
2 changes: 1 addition & 1 deletion core/src/style/textStyleBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ TextStyle::Parameters TextStyleBuilder::applyRule(const DrawRule& _rule,
}
}

_rule.get(StyleParamKey::text_required, p.labelOptions.required);
_rule.get(StyleParamKey::text_optional, p.labelOptions.optional);

// TODO style option?
p.labelOptions.buffer = p.fontSize * 0.25f;
Expand Down
3 changes: 0 additions & 3 deletions scenes/scene.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ layers:
collide: true
transition: { show: { time: 0s }, hide: { time: 1s } }
text:
required: true
interactive: true
font:
family: sans-serif
Expand Down Expand Up @@ -471,7 +470,6 @@ layers:
interactive: true
priority: 6
text:
required: false
visible: false

# add text label at higher zoom
Expand All @@ -482,7 +480,6 @@ layers:
draw:
icons:
text:
required: true
visible: true
font:
size: 12px
Expand Down

0 comments on commit 5c086c1

Please sign in to comment.