[core] Observe visibility changes
This commit is contained in:
@@ -19,7 +19,10 @@ VisibilityType Layer::getVisibility() const {
|
||||
}
|
||||
|
||||
void Layer::setVisibility(VisibilityType value) {
|
||||
if (value == getVisibility())
|
||||
return;
|
||||
baseImpl->visibility = value;
|
||||
baseImpl->observer->onLayerVisibilityChanged(*this);
|
||||
}
|
||||
|
||||
float Layer::getMinZoom() const {
|
||||
|
||||
@@ -10,6 +10,7 @@ public:
|
||||
virtual ~LayerObserver() = default;
|
||||
|
||||
virtual void onLayerFilterChanged(Layer&) {}
|
||||
virtual void onLayerVisibilityChanged(Layer&) {}
|
||||
virtual void onLayerPaintPropertyChanged(Layer&) {}
|
||||
virtual void onLayerLayoutPropertyChanged(Layer&) {}
|
||||
};
|
||||
|
||||
@@ -506,9 +506,11 @@ void Style::onSpriteError(std::exception_ptr error) {
|
||||
struct QueueSourceReloadVisitor {
|
||||
UpdateBatch& updateBatch;
|
||||
|
||||
void operator()(CustomLayer&) { assert(false); }
|
||||
void operator()(RasterLayer&) { assert(false); }
|
||||
void operator()(BackgroundLayer&) { assert(false); }
|
||||
// No need to reload sources for these types; their visibility can change but
|
||||
// they don't participate in layout.
|
||||
void operator()(CustomLayer&) {}
|
||||
void operator()(RasterLayer&) {}
|
||||
void operator()(BackgroundLayer&) {}
|
||||
|
||||
template <class VectorLayer>
|
||||
void operator()(VectorLayer& layer) {
|
||||
@@ -521,6 +523,11 @@ void Style::onLayerFilterChanged(Layer& layer) {
|
||||
observer->onUpdate(Update::Layout);
|
||||
}
|
||||
|
||||
void Style::onLayerVisibilityChanged(Layer& layer) {
|
||||
layer.accept(QueueSourceReloadVisitor { updateBatch });
|
||||
observer->onUpdate(Update::Layout);
|
||||
}
|
||||
|
||||
void Style::onLayerPaintPropertyChanged(Layer&) {
|
||||
observer->onUpdate(Update::RecalculateStyle | Update::Classes);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ private:
|
||||
|
||||
// LayerObserver implementation.
|
||||
void onLayerFilterChanged(Layer&) override;
|
||||
void onLayerVisibilityChanged(Layer&) override;
|
||||
void onLayerPaintPropertyChanged(Layer&) override;
|
||||
void onLayerLayoutPropertyChanged(Layer&) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user