1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +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 8b4b16524a
commit 7c819595bf
10 changed files with 41 additions and 64 deletions

View File

@ -1594,6 +1594,8 @@ void AudacityProject::CreateMenusAndCommands()
// you would have to use "Compareaudio" here.)
// c->AddItem(wxT("Demo"), _("Just a Demo..."), FN(OnAudacityCommand),
// AudioIONotBusyFlag, AudioIONotBusyFlag);
c->AddItem(wxT("Message"), _("Message..."), FN(OnAudacityCommand),
AudioIONotBusyFlag, AudioIONotBusyFlag);
c->AddItem(wxT("Screenshot"), _("Screenshot (Vanilla)..."), FN(OnAudacityCommand),
AudioIONotBusyFlag, AudioIONotBusyFlag);
c->AddItem(wxT("Select"), _("Select..."), FN(OnAudacityCommand),

View File

@ -161,7 +161,6 @@ scroll information. It also has some status flags.
#include "tracks/ui/Scrubbing.h"
#include "commands/ScriptCommandRelay.h"
#include "commands/CommandDirectory.h"
#include "commands/CommandTargets.h"
#include "commands/Command.h"
#include "commands/CommandType.h"
@ -5167,25 +5166,6 @@ void AudacityProject::TP_DisplayStatusMessage(const wxString &msg)
mLastStatusUpdateTime = ::wxGetUTCTime();
}
// Set the status indirectly, using the command system
// (more overhead, but can be used from a non-GUI thread)
void AudacityProject::SafeDisplayStatusMessage(const wxChar *msg)
{
auto target
= std::make_unique<CommandOutputTargets>(TargetFactory::ProgressDefault(),
std::make_shared<StatusBarTarget>(*mStatusBar),
TargetFactory::MessageDefault());
OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("Message"));
wxASSERT_MSG(type != NULL, wxT("Message command not found!"));
OldStyleCommandPointer statusCmd = type->Create(std::move(target));
statusCmd->SetParameter(wxT("MessageString"), msg);
ScriptCommandRelay::PostCommand(this, statusCmd);
// Although the status hasn't actually been set yet, updating the time now
// is probably accurate enough
mLastStatusUpdateTime = ::wxGetUTCTime();
}
void AudacityProject::TP_DisplaySelection()
{
double audioTime;

View File

@ -459,8 +459,6 @@ public:
void FinishAutoScroll();
void FixScrollbars();
void SafeDisplayStatusMessage(const wxChar *msg);
bool MayScrollBeyondZero() const;
double ScrollingLowerBoundTime() const;
// How many pixels are covered by the period from lowermost scrollable time, to the given time:

View File

@ -20,7 +20,6 @@ It forwards the actual work of doing the commands to the ScreenshotCommand.
#include "MemoryX.h"
#include "commands/ScreenshotCommand.h"
#include "commands/CommandTargets.h"
#include "commands/CommandDirectory.h"
#include "commands/CommandContext.h"
#include <wx/defs.h>
#include <wx/event.h>
@ -251,8 +250,6 @@ std::unique_ptr<ScreenshotCommand> ScreenFrame::CreateCommand()
std::make_unique<CommandOutputTargets>(std::make_unique<NullProgressTarget>(),
std::make_shared<StatusBarTarget>(*mStatus),
std::make_shared<MessageBoxTarget>());
//OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot"));
//wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!"));
return std::make_unique<ScreenshotCommand>();//*type, std::move(output), this);
}

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;
};
class MessageCommand final : public CommandImplementation
{
public:
MessageCommand(OldStyleCommandType &type)
: CommandImplementation(type) {}
// 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;
};
#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);
@ -109,7 +108,6 @@ int ExecCommand2(wxString *pIn, wxString *pOut)
if (builder.WasValid())
{
AudacityProject *project = GetActiveProject();
//project->SafeDisplayStatusMessage(wxT("Received script command"));
OldStyleCommandPointer cmd = builder.GetCommand();
AppCommandEvent ev;
ev.SetCommand(cmd);