[core] Place already visible symbols first and hidden symbols last
This commit is contained in:
@@ -662,7 +662,25 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
|
||||
}
|
||||
|
||||
} else {
|
||||
for (const SymbolInstance& symbol : bucket.getSymbols(params.sortKeyRange)) {
|
||||
auto sortedSymbols = bucket.getSymbols(params.sortKeyRange);
|
||||
if (auto* previousPlacement = getPrevPlacement()) {
|
||||
std::stable_sort(
|
||||
sortedSymbols.begin(), sortedSymbols.end(), [&](const SymbolInstance& a, const SymbolInstance& b) {
|
||||
auto* aPlacement = previousPlacement->getSymbolPlacement(a);
|
||||
auto* bPlacement = previousPlacement->getSymbolPlacement(b);
|
||||
if (!aPlacement) {
|
||||
// a < b, if 'a' is new and if 'b' was previously hidden.
|
||||
return bPlacement && !bPlacement->placed();
|
||||
}
|
||||
if (!bPlacement) {
|
||||
// a < b, if 'b' is new and 'a' was previously shown.
|
||||
return aPlacement && aPlacement->placed();
|
||||
}
|
||||
// a < b, if 'a' was shown and 'b' was hidden.
|
||||
return aPlacement->placed() && !bPlacement->placed();
|
||||
});
|
||||
}
|
||||
for (const SymbolInstance& symbol : sortedSymbols) {
|
||||
placeSymbol(symbol);
|
||||
}
|
||||
}
|
||||
@@ -1203,6 +1221,13 @@ float Placement::zoomAdjustment(const float zoom) const {
|
||||
return std::max(0.0, (placementZoom - zoom) / 1.5);
|
||||
}
|
||||
|
||||
const JointPlacement* Placement::getSymbolPlacement(const SymbolInstance& symbol) const {
|
||||
assert(symbol.crossTileID != 0);
|
||||
auto found = placements.find(symbol.crossTileID);
|
||||
if (found == placements.end()) return nullptr;
|
||||
return &found->second;
|
||||
}
|
||||
|
||||
Duration Placement::getUpdatePeriod(const float zoom) const {
|
||||
// Even if transitionOptions.duration is set to a value < 300ms, we still wait for this default transition duration
|
||||
// before attempting another placement operation.
|
||||
|
||||
Reference in New Issue
Block a user