Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5408: Set up infrastructure to show the last named map operation in …
…the status bar
- Loading branch information
1 parent
c4f7a6f
commit 2263151
Showing
15 changed files
with
147 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include "iradiant.h" | ||
#include "imessagebus.h" | ||
|
||
namespace map | ||
{ | ||
|
||
/** | ||
* Message sent when an operation affecting the loaded map is finished. | ||
* This can be an ordinary edit operation, loading, saving, or an undo/redo step. | ||
*/ | ||
class OperationMessage : | ||
public radiant::IMessage | ||
{ | ||
private: | ||
std::string _message; | ||
|
||
public: | ||
OperationMessage(const std::string& message) : | ||
_message(message) | ||
{} | ||
|
||
std::size_t getId() const override | ||
{ | ||
return IMessage::Type::MapOperationFinished; | ||
} | ||
|
||
const std::string& getMessage() const | ||
{ | ||
return _message; | ||
} | ||
|
||
static void Send(const std::string& message) | ||
{ | ||
OperationMessage msg(message); | ||
GlobalRadiantCore().getMessageBus().sendMessage(msg); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "CommandStatus.h" | ||
|
||
#include "ui/istatusbarmanager.h" | ||
#include "iradiant.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
namespace statusbar | ||
{ | ||
|
||
namespace | ||
{ | ||
const char* const STATUS_BAR_ELEMENT = "Commands"; | ||
} | ||
|
||
CommandStatus::CommandStatus() | ||
{ | ||
_mapOperationListener = GlobalRadiantCore().getMessageBus().addListener( | ||
radiant::IMessage::MapOperationFinished, | ||
radiant::TypeListener<map::OperationMessage>( | ||
sigc::mem_fun(this, &CommandStatus::onOperationFinished))); | ||
|
||
// Add the status bar element | ||
GlobalStatusBarManager().addTextElement(STATUS_BAR_ELEMENT, "", StandardPosition::Commands, ""); | ||
} | ||
|
||
CommandStatus::~CommandStatus() | ||
{ | ||
GlobalRadiantCore().getMessageBus().removeListener(_mapOperationListener); | ||
} | ||
|
||
void CommandStatus::onOperationFinished(map::OperationMessage& message) | ||
{ | ||
GlobalStatusBarManager().setText(STATUS_BAR_ELEMENT, message.getMessage(), false); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "iundo.h" | ||
#include "imap.h" | ||
|
||
#include "messages/MapOperationMessage.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
namespace statusbar | ||
{ | ||
|
||
/** | ||
* Status bar widget displaying the most recently completed | ||
* operation or any undo / redo activitiy. | ||
*/ | ||
class CommandStatus final | ||
{ | ||
private: | ||
std::size_t _mapOperationListener; | ||
|
||
public: | ||
CommandStatus(); | ||
~CommandStatus(); | ||
|
||
void onOperationFinished(map::OperationMessage& message); | ||
}; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters