Skip to content

Commit

Permalink
#6131: TransformPanel activation/deactivation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 22, 2022
1 parent 6540671 commit 966c5df
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
32 changes: 24 additions & 8 deletions radiant/ui/transform/TransformPanel.cpp
Expand Up @@ -48,15 +48,36 @@ TransformPanel::TransformPanel(wxWindow* parent) :
{
// Create all the widgets and pack them into the window
populateWindow();
}

_selectionChanged.disconnect();
TransformPanel::~TransformPanel()
{
disconnectListeners();
}

void TransformPanel::onPanelActivated()
{
connectListeners();

// Update the widget sensitivity
update();
}

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

void TransformPanel::connectListeners()
{
// Register self to the SelSystem to get notified upon selection changes.
_selectionChanged = GlobalSelectionSystem().signal_selectionChanged().connect(
[this](const ISelectable&) { update(); });
}

// Update the widget sensitivity
update();
void TransformPanel::disconnectListeners()
{
_selectionChanged.disconnect();
}

void TransformPanel::populateWindow()
Expand Down Expand Up @@ -173,11 +194,6 @@ TransformPanel::EntryRow TransformPanel::createEntryRow(
return entryRow;
}

TransformPanel::~TransformPanel()
{
_selectionChanged.disconnect();
}

void TransformPanel::update()
{
// Check if there is anything selected
Expand Down
7 changes: 7 additions & 0 deletions radiant/ui/transform/TransformPanel.h
Expand Up @@ -50,7 +50,14 @@ class TransformPanel :
TransformPanel(wxWindow* parent);
~TransformPanel() override;

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

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

/** greebo: Updates the sensitivity of the widgets according to
* the current selection.
*/
Expand Down

0 comments on commit 966c5df

Please sign in to comment.