Update map immediately if map logo or attribution is toggled

This commit is contained in:
Dan Paulat 2024-03-08 00:55:55 -06:00
parent 931b5d8481
commit 35bd2433a7
2 changed files with 29 additions and 3 deletions

View file

@ -42,14 +42,38 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class OverlayLayerImpl class OverlayLayerImpl
{ {
public: public:
explicit OverlayLayerImpl(std::shared_ptr<MapContext> context) : explicit OverlayLayerImpl(OverlayLayer* self,
std::shared_ptr<MapContext> context) :
self_ {self},
activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)}, activeBoxOuter_ {std::make_shared<gl::draw::Rectangle>(context)},
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)}, activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)},
geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)}, geoIcons_ {std::make_shared<gl::draw::GeoIcons>(context)},
icons_ {std::make_shared<gl::draw::Icons>(context)} icons_ {std::make_shared<gl::draw::Icons>(context)}
{ {
auto& generalSettings = settings::GeneralSettings::Instance();
showMapAttributionCallbackUuid_ =
generalSettings.show_map_attribution().RegisterValueChangedCallback(
[this](const bool&) { Q_EMIT self_->NeedsRendering(); });
showMapLogoCallbackUuid_ =
generalSettings.show_map_logo().RegisterValueChangedCallback(
[this](const bool&) { Q_EMIT self_->NeedsRendering(); });
} }
~OverlayLayerImpl() = default;
~OverlayLayerImpl()
{
auto& generalSettings = settings::GeneralSettings::Instance();
generalSettings.show_map_attribution().UnregisterValueChangedCallback(
showMapAttributionCallbackUuid_);
generalSettings.show_map_logo().UnregisterValueChangedCallback(
showMapLogoCallbackUuid_);
}
OverlayLayer* self_;
boost::uuids::uuid showMapAttributionCallbackUuid_;
boost::uuids::uuid showMapLogoCallbackUuid_;
std::shared_ptr<manager::PositionManager> positionManager_ { std::shared_ptr<manager::PositionManager> positionManager_ {
manager::PositionManager::Instance()}; manager::PositionManager::Instance()};
@ -91,7 +115,7 @@ public:
}; };
OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) : OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) :
DrawLayer(context), p(std::make_unique<OverlayLayerImpl>(context)) DrawLayer(context), p(std::make_unique<OverlayLayerImpl>(this, context))
{ {
AddDrawItem(p->activeBoxOuter_); AddDrawItem(p->activeBoxOuter_);
AddDrawItem(p->activeBoxInner_); AddDrawItem(p->activeBoxInner_);

View file

@ -13,6 +13,8 @@ class OverlayLayerImpl;
class OverlayLayer : public DrawLayer class OverlayLayer : public DrawLayer
{ {
Q_DISABLE_COPY_MOVE(OverlayLayer)
public: public:
explicit OverlayLayer(std::shared_ptr<MapContext> context); explicit OverlayLayer(std::shared_ptr<MapContext> context);
~OverlayLayer(); ~OverlayLayer();