diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-13 17:09:58 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@gmail.com> | 2017-11-13 17:15:23 -0800 |
commit | d6d469aff8a00e86c45c963b44ef1a20051fd67a (patch) | |
tree | 13086cf9586ecdfb5d8b462eee4b998a4a097c63 | |
parent | 09159d8c67a1e006d9f29c5d6dcce97004b55ea0 (diff) | |
download | qtlocation-mapboxgl-d6d469aff8a00e86c45c963b44ef1a20051fd67a.tar.gz |
Less fading for line labels.
-rw-r--r-- | src/mbgl/text/placement.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/text/placement.hpp | 5 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 85f6385ce6..112d641be0 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -8,8 +8,8 @@ namespace mbgl { -OpacityState::OpacityState(bool placed_, bool offscreen) - : opacity((offscreen && placed_) ? 1 : 0) +OpacityState::OpacityState(bool placed_, bool skipFadeIn) + : opacity((skipFadeIn && placed_) ? 1 : 0) , placed(placed_) { } @@ -22,9 +22,9 @@ bool OpacityState::isHidden() const { return opacity == 0 && !placed; } -JointOpacityState::JointOpacityState(bool placedIcon, bool placedText, bool offscreen) : - icon(OpacityState(placedIcon, offscreen)), - text(OpacityState(placedText, offscreen)) {} +JointOpacityState::JointOpacityState(bool placedIcon, bool placedText, bool skipFadeIn) : + icon(OpacityState(placedIcon, skipFadeIn)), + text(OpacityState(placedText, skipFadeIn)) {} JointOpacityState::JointOpacityState(const JointOpacityState& prevOpacityState, float increment, bool placedIcon, bool placedText) : icon(OpacityState(prevOpacityState.icon, increment, placedIcon)), @@ -104,6 +104,7 @@ void Placement::placeLayerBucket( bool placeText = false; bool placeIcon = false; bool offscreen = true; + bool lineLabel = false; if (symbolInstance.placedTextIndex) { PlacedSymbol& placedSymbol = bucket.text.placedSymbols.at(*symbolInstance.placedTextIndex); @@ -117,6 +118,7 @@ void Placement::placeLayerBucket( showCollisionBoxes); placeText = placed.first; offscreen &= placed.second; + lineLabel = symbolInstance.textCollisionFeature.alongLine; } if (symbolInstance.placedIconIndex) { @@ -152,7 +154,7 @@ void Placement::placeLayerBucket( assert(symbolInstance.crossTileID != 0); - placements.emplace(symbolInstance.crossTileID, JointPlacement(placeText, placeIcon, offscreen)); + placements.emplace(symbolInstance.crossTileID, JointPlacement(placeText, placeIcon, offscreen, lineLabel)); seenCrossTileIDs.insert(symbolInstance.crossTileID); } } @@ -164,7 +166,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) { bool placementChanged = false; float increment = mapMode == MapMode::Continuous ? - std::chrono::duration<float>(commitTime - prevPlacement.commitTime) / Duration(std::chrono::milliseconds(300)) : + std::chrono::duration<float>(commitTime - prevPlacement.commitTime) / Duration(std::chrono::milliseconds(2000)) : 1.0; // add the opacities from the current placement, and copy their current values from the previous placement @@ -176,7 +178,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) { jointPlacement.second.icon != prevOpacity->second.icon.placed || jointPlacement.second.text != prevOpacity->second.text.placed; } else { - opacities.emplace(jointPlacement.first, JointOpacityState(jointPlacement.second.icon, jointPlacement.second.text, jointPlacement.second.offscreen)); + opacities.emplace(jointPlacement.first, JointOpacityState(jointPlacement.second.icon, jointPlacement.second.text, jointPlacement.second.offscreen || jointPlacement.second.lineLabel)); placementChanged = placementChanged || jointPlacement.second.icon || jointPlacement.second.text; } } @@ -287,7 +289,7 @@ JointOpacityState Placement::getOpacity(uint32_t crossTileSymbolID) const { float Placement::symbolFadeChange(TimePoint now) const { if (mapMode == MapMode::Continuous) { - return std::chrono::duration<float>(now - commitTime) / Duration(std::chrono::milliseconds(300)); + return std::chrono::duration<float>(now - commitTime) / Duration(std::chrono::milliseconds(2000)); } else { return 1.0; } diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index c6d1f259a5..68de16a358 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -32,8 +32,8 @@ public: class JointPlacement { public: - JointPlacement(bool text_, bool icon_, bool offscreen_) - : text(text_), icon(icon_), offscreen(offscreen_) + JointPlacement(bool text_, bool icon_, bool offscreen_, bool lineLabel_) + : text(text_), icon(icon_), offscreen(offscreen_), lineLabel(lineLabel_) {} const bool text; @@ -43,6 +43,7 @@ public: // and if a subsequent viewport change brings them into view, they'll be fully // visible right away. const bool offscreen; + const bool lineLabel; }; class Placement { |