Skip to content

Commit

Permalink
#6131: LightInspector panel activation/deactivation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 22, 2022
1 parent d783d05 commit d71fc5b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
25 changes: 20 additions & 5 deletions radiant/ui/lightinspector/LightInspector.cpp
Expand Up @@ -48,11 +48,22 @@ LightInspector::LightInspector(wxWindow* parent) :
makeLabelBold(this, "LightInspectorOptionsLabel");

SetMinSize(contents->GetEffectiveMinSize());
}

_selectionChanged.disconnect();
_undoHandler.disconnect();
_redoHandler.disconnect();
void LightInspector::onPanelActivated()
{
connectListeners();
// Update the widgets right now
update();
}

void LightInspector::onPanelDeactivated()
{
disconnectListeners();
}

void LightInspector::connectListeners()
{
// Register self as observer to receive events
_undoHandler = GlobalMapModule().signal_postUndo().connect(
sigc::mem_fun(this, &LightInspector::update));
Expand All @@ -62,9 +73,13 @@ LightInspector::LightInspector(wxWindow* parent) :
// Register self to the SelSystem to get notified upon selection changes.
_selectionChanged = GlobalSelectionSystem().signal_selectionChanged().connect(
[this](const ISelectable&) { update(); });
}

// Update the widgets right now
update();
void LightInspector::disconnectListeners()
{
_selectionChanged.disconnect();
_undoHandler.disconnect();
_redoHandler.disconnect();
}

void LightInspector::shaderSelectionChanged()
Expand Down
7 changes: 7 additions & 0 deletions radiant/ui/lightinspector/LightInspector.h
Expand Up @@ -60,7 +60,14 @@ class LightInspector :
LightInspector(wxWindow* parent);
~LightInspector() override;

protected:
void onPanelActivated() override;
void onPanelDeactivated() override;

private:
void connectListeners();
void disconnectListeners();

// Widget construction functions
void setupLightShapeOptions();
void bindSpawnargToCheckbox(std::string spawnarg, std::string checkbox);
Expand Down

0 comments on commit d71fc5b

Please sign in to comment.