Skip to content

Commit

Permalink
ShaderClipboard is using UndoSystem's signals now
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 1, 2017
1 parent 89d9f49 commit e8a172e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
25 changes: 11 additions & 14 deletions radiant/selection/shaderclipboard/ShaderClipboard.cpp
Expand Up @@ -12,7 +12,8 @@
#include "brush/BrushNode.h"
#include <boost/format.hpp>

namespace selection {
namespace selection
{

ShaderClipboard::ShaderClipboard() :
_updatesDisabled(false)
Expand All @@ -24,13 +25,17 @@ ShaderClipboard::ShaderClipboard() :
_("The name of the shader in the clipboard")
);

GlobalUndoSystem().addObserver(this);
GlobalUndoSystem().signal_postUndo().connect(
sigc::mem_fun(this, &ShaderClipboard::onUndoRedoOperation));
GlobalUndoSystem().signal_postRedo().connect(
sigc::mem_fun(this, &ShaderClipboard::onUndoRedoOperation));

GlobalMapModule().signal_mapEvent().connect(
sigc::mem_fun(*this, &ShaderClipboard::onMapEvent));
}

void ShaderClipboard::clear() {
void ShaderClipboard::clear()
{
_source.clear();

_updatesDisabled = true;
Expand All @@ -41,16 +46,7 @@ void ShaderClipboard::clear() {
_updatesDisabled = false;
}

void ShaderClipboard::postUndo()
{
// Check if the source is still valid
if (!_source.checkValid())
{
clear();
}
}

void ShaderClipboard::postRedo()
void ShaderClipboard::onUndoRedoOperation()
{
// Check if the source is still valid
if (!_source.checkValid())
Expand Down Expand Up @@ -179,7 +175,8 @@ void ShaderClipboard::onMapEvent(IMap::MapEvent ev)
} // namespace selection

// global accessor function
selection::ShaderClipboard& GlobalShaderClipboard() {
selection::ShaderClipboard& GlobalShaderClipboard()
{
static selection::ShaderClipboard _instance;

return _instance;
Expand Down
12 changes: 6 additions & 6 deletions radiant/selection/shaderclipboard/ShaderClipboard.h
@@ -1,16 +1,17 @@
#pragma once

#include "iundo.h"
#include "imap.h"
#include "Texturable.h"
#include <sigc++/signal.h>
#include <sigc++/trackable.h>

namespace selection
{

class ShaderClipboard :
public UndoSystem::Observer
public sigc::trackable
{
private:
// The source and target Texturables
Texturable _source;

Expand Down Expand Up @@ -53,11 +54,10 @@ class ShaderClipboard :
*/
void clear();

// UndoSystem::Observer implementation
void postUndo();
void postRedo();

private:
// UndoSystem callbacks
void onUndoRedoOperation();

void onMapEvent(IMap::MapEvent ev);

/** greebo: Updates the shader information in the status bar.
Expand Down

0 comments on commit e8a172e

Please sign in to comment.