1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Make Message command into an AudacityCommand.

This commit is contained in:
James Crook
2018-02-14 19:32:39 +00:00
committed by Paul Licameli
parent edf90d6e2c
commit f7fe295651
10 changed files with 41 additions and 63 deletions

View File

@@ -28,7 +28,7 @@ CommandDirectory::CommandDirectory()
{
// Create the command map.
// First we have commands which return information
AddCommand(make_movable<MessageCommandType>());
//AddCommand(make_movable<MessageCommandType>());
AddCommand(make_movable<BatchEvalCommandType>());

View File

@@ -15,8 +15,6 @@
#include "../Audacity.h"
#include "HelpCommand.h"
//#include "../Project.h"
//#include "../Track.h"
#include "../ShuttleGui.h"
#include "CommandContext.h"
#include "../effects/EffectManager.h"

View File

@@ -22,6 +22,7 @@ modelled on BuiltinEffectsModule
#include "../effects/EffectManager.h"
#include "Demo.h"
#include "../Experimental.h"
#include "../commands/MessageCommand.h"
#include "../commands/ScreenshotCommand.h"
#include "../commands/CompareAudioCommand.h"
#include "../commands/SetTrackInfoCommand.h"
@@ -43,6 +44,7 @@ modelled on BuiltinEffectsModule
//
#define COMMAND_LIST \
COMMAND( DEMO, DemoCommand, () ) \
COMMAND( MESSAGE, MessageCommand, () ) \
COMMAND( SCREENSHOT, ScreenshotCommand, () ) \
COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \
COMMAND( SET_TRACK, SetTrackCommand, () ) \

View File

@@ -17,26 +17,25 @@
#include "MessageCommand.h"
#include "CommandType.h"
#include "CommandContext.h"
#include "../ShuttleGui.h"
wxString MessageCommandType::BuildName()
{
return wxT("Message");
}
void MessageCommandType::BuildSignature(CommandSignature &signature)
{
auto stringValidator = make_movable<DefaultValidator>();
signature.AddParameter(wxT("MessageString"), wxT("Connected"), std::move(stringValidator));
}
OldStyleCommandPointer MessageCommandType::Create(std::unique_ptr<CommandOutputTargets> &&target)
{
return std::make_shared<MessageCommand>(*this);
}
bool MessageCommand::Apply(const CommandContext & context)
{
wxString message = GetString(wxT("MessageString"));
context.Status(message);
bool MessageCommand::DefineParams( ShuttleParams & S ){
S.Define( mMessage, wxT("Text"), "Some message" );
return true;
}
void MessageCommand::PopulateOrExchange(ShuttleGui & S)
{
S.AddSpace(0, 5);
S.StartMultiColumn(2, wxALIGN_CENTER);
{
S.TieTextBox(_("Text:"),mMessage,60);
}
S.EndMultiColumn();
}
bool MessageCommand::Apply(const CommandContext & context){
context.Status( mMessage );
return true;
}

View File

@@ -18,26 +18,29 @@
*//*******************************************************************/
#ifndef __MESSAGECOMMAND__
#define __MESSAGECOMMAND__
#ifndef __MESSAGE_COMMAND__
#define __MESSAGE_COMMAND__
#include "Command.h"
#include "CommandType.h"
#include "Command.h"
class MessageCommandType final : public OldStyleCommandType
#define MESSAGE_PLUGIN_SYMBOL XO("Message")
class MessageCommand : public AudacityCommand
{
public:
wxString BuildName() override;
void BuildSignature(CommandSignature &signature) override;
OldStyleCommandPointer Create(std::unique_ptr<CommandOutputTargets> &&target) override;
// CommandDefinitionInterface overrides
wxString GetSymbol() override {return MESSAGE_PLUGIN_SYMBOL;};
wxString GetDescription() override {return _("Echos a message.");};
bool DefineParams( ShuttleParams & S ) override;
void PopulateOrExchange(ShuttleGui & S) override;
bool Apply(const CommandContext & context) override;
// AudacityCommand overrides
wxString ManualPage() override {return wxT("Message");};
public:
wxString mMessage;
};
class MessageCommand final : public CommandImplementation
{
public:
MessageCommand(OldStyleCommandType &type)
: CommandImplementation(type) {}
bool Apply(const CommandContext &context ) override;
};
#endif /* End of include guard: __MESSAGECOMMAND__ */

View File

@@ -72,7 +72,6 @@ int ExecCommand(wxString *pIn, wxString *pOut)
if (builder.WasValid())
{
AudacityProject *project = GetActiveProject();
//project->SafeDisplayStatusMessage(wxT("Received script command"));
OldStyleCommandPointer cmd = builder.GetCommand();
ScriptCommandRelay::PostCommand(project, cmd);