Skip to content

Commit

Permalink
Update map immediately if map logo or attribution is toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulat committed Mar 8, 2024
1 parent 931b5d8 commit 35bd243
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 27 additions & 3 deletions scwx-qt/source/scwx/qt/map/overlay_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,38 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class OverlayLayerImpl
{
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)},
activeBoxInner_ {std::make_shared<gl::draw::Rectangle>(context)},
geoIcons_ {std::make_shared<gl::draw::GeoIcons>(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_ {
manager::PositionManager::Instance()};
Expand Down Expand Up @@ -91,7 +115,7 @@ class OverlayLayerImpl
};

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->activeBoxInner_);
Expand Down
2 changes: 2 additions & 0 deletions scwx-qt/source/scwx/qt/map/overlay_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class OverlayLayerImpl;

class OverlayLayer : public DrawLayer
{
Q_DISABLE_COPY_MOVE(OverlayLayer)

public:
explicit OverlayLayer(std::shared_ptr<MapContext> context);
~OverlayLayer();
Expand Down

0 comments on commit 35bd243

Please sign in to comment.