Skip to content

Commit

Permalink
LightInspector and TransformDialog are using SelectionSystem's signal…
Browse files Browse the repository at this point in the history
… now
  • Loading branch information
codereader committed Jul 1, 2017
1 parent 696c7e2 commit 20b05aa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 32 deletions.
14 changes: 7 additions & 7 deletions radiant/ui/lightinspector/LightInspector.cpp
Expand Up @@ -243,7 +243,7 @@ void LightInspector::_preHide()
TransientWindow::_preHide();

// Remove as observer, an invisible inspector doesn't need to receive events
GlobalSelectionSystem().removeObserver(this);
_selectionChanged.disconnect();
GlobalUndoSystem().removeObserver(this);
}

Expand All @@ -252,16 +252,16 @@ void LightInspector::_preShow()
{
TransientWindow::_preShow();

_selectionChanged.disconnect();

// Register self as observer to receive events
GlobalUndoSystem().addObserver(this);
GlobalSelectionSystem().addObserver(this);

// Update the widgets before showing
update();
}
// Register self to the SelSystem to get notified upon selection changes.
_selectionChanged = GlobalSelectionSystem().signal_selectionChanged().connect(
[this](const ISelectable&) { update(); });

void LightInspector::selectionChanged(const scene::INodePtr& node, bool isComponent)
{
// Update the widgets before showing
update();
}

Expand Down
7 changes: 4 additions & 3 deletions radiant/ui/lightinspector/LightInspector.h
@@ -1,6 +1,5 @@
#pragma once

#include "iselection.h"
#include "icommandsystem.h"
#include "iundo.h"
#include "iradiant.h"
Expand All @@ -10,6 +9,7 @@

#include <map>
#include <string>
#include <sigc++/connection.h>

/* FORWARD DECLS */
class Entity;
Expand All @@ -26,7 +26,6 @@ typedef std::shared_ptr<LightInspector> LightInspectorPtr;

class LightInspector
: public wxutil::TransientWindow,
public SelectionSystem::Observer,
public ShaderSelector::Client,
public UndoSystem::Observer,
private wxutil::XmlResourceBasedWidget
Expand All @@ -46,9 +45,11 @@ class LightInspector
typedef std::map<std::string, std::string> StringMap;
StringMap _valueMap;

// Disables GTK callbacks if set to TRUE (during widget updates)
// Disables callbacks if set to TRUE (during widget updates)
bool _updateActive;

sigc::connection _selectionChanged;

private:
// This is where the static shared_ptr of the singleton instance is held.
static LightInspectorPtr& InstancePtr();
Expand Down
14 changes: 5 additions & 9 deletions radiant/ui/transform/TransformDialog.cpp
Expand Up @@ -70,8 +70,6 @@ void TransformDialog::onRadiantShutdown()
Hide();
}

GlobalSelectionSystem().removeObserver(this);

// Destroy the window
SendDestroyEvent();
InstancePtr().reset();
Expand Down Expand Up @@ -226,16 +224,19 @@ void TransformDialog::_preHide()
{
TransientWindow::_preHide();

GlobalSelectionSystem().removeObserver(this);
_selectionChanged.disconnect();
}

// Pre-show callback
void TransformDialog::_preShow()
{
TransientWindow::_preShow();

_selectionChanged.disconnect();

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

// Update the widget values
update();
Expand All @@ -255,11 +256,6 @@ void TransformDialog::update()
_scalePanel->Enable(scaleSensitive);
}

void TransformDialog::selectionChanged(const scene::INodePtr& node, bool isComponent)
{
update();
}

void TransformDialog::onClickLarger(wxCommandEvent& ev, EntryRow* row)
{
// Get the current step increment
Expand Down
18 changes: 5 additions & 13 deletions radiant/ui/transform/TransformDialog.h
Expand Up @@ -2,11 +2,11 @@

#include <string>
#include <map>
#include "iselection.h"
#include "icommandsystem.h"
#include "iradiant.h"
#include "wxutil/window/TransientWindow.h"
#include <wx/panel.h>
#include <sigc++/connection.h>

namespace wxutil { class ControlButton; }

Expand All @@ -25,9 +25,8 @@ namespace ui
class TransformDialog;
typedef std::shared_ptr<TransformDialog> TransformDialogPtr;

class TransformDialog
: public wxutil::TransientWindow,
public SelectionSystem::Observer
class TransformDialog :
public wxutil::TransientWindow
{
private:
// The entry fields
Expand All @@ -50,6 +49,8 @@ class TransformDialog
wxPanel* _rotatePanel;
wxPanel* _scalePanel;

sigc::connection _selectionChanged;

private:

// TransientWindow callbacks
Expand Down Expand Up @@ -77,9 +78,6 @@ class TransformDialog
void onClickSmaller(wxCommandEvent& ev, EntryRow* row);
void onClickLarger(wxCommandEvent& ev, EntryRow* row);

// The callback ensuring that the step changes are written to the registry
void onStepChanged();

public:
// Constructor
TransformDialog();
Expand All @@ -89,12 +87,6 @@ class TransformDialog
*/
static TransformDialog& Instance();

/** greebo: SelectionSystem::Observer implementation. Gets called by
* the SelectionSystem upon selection change to allow updating of the
* widget sensitivity.
*/
void selectionChanged(const scene::INodePtr& node, bool isComponent);

/** greebo: Safely disconnects this dialog from all systems
* (EventManager) also saves the window state to the registry.
*/
Expand Down

0 comments on commit 20b05aa

Please sign in to comment.