diff --git a/src/Menus.cpp b/src/Menus.cpp index 7f94118dd..9e7b1c13d 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -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), diff --git a/src/Project.cpp b/src/Project.cpp index 1ad398bbd..1c8e8163d 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -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(TargetFactory::ProgressDefault(), - std::make_shared(*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; diff --git a/src/Project.h b/src/Project.h index ae30fe791..f04fa5bdb 100644 --- a/src/Project.h +++ b/src/Project.h @@ -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: diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index e773633b8..2075c7dbd 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -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 #include @@ -251,8 +250,6 @@ std::unique_ptr ScreenFrame::CreateCommand() std::make_unique(std::make_unique(), std::make_shared(*mStatus), std::make_shared()); - //OldStyleCommandType *type = CommandDirectory::Get()->LookUp(wxT("Screenshot")); - //wxASSERT_MSG(type != NULL, wxT("Screenshot command doesn't exist!")); return std::make_unique();//*type, std::move(output), this); } diff --git a/src/commands/CommandDirectory.cpp b/src/commands/CommandDirectory.cpp index db94c3841..05c5f10db 100644 --- a/src/commands/CommandDirectory.cpp +++ b/src/commands/CommandDirectory.cpp @@ -28,7 +28,7 @@ CommandDirectory::CommandDirectory() { // Create the command map. // First we have commands which return information - AddCommand(make_movable()); + //AddCommand(make_movable()); AddCommand(make_movable()); diff --git a/src/commands/HelpCommand.cpp b/src/commands/HelpCommand.cpp index e31443886..ecbf5a5e7 100644 --- a/src/commands/HelpCommand.cpp +++ b/src/commands/HelpCommand.cpp @@ -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" diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index 81eb9f241..5f32f7be9 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -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, () ) \ diff --git a/src/commands/MessageCommand.cpp b/src/commands/MessageCommand.cpp index 8ebd20ba1..1acc6f21c 100644 --- a/src/commands/MessageCommand.cpp +++ b/src/commands/MessageCommand.cpp @@ -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(); - signature.AddParameter(wxT("MessageString"), wxT("Connected"), std::move(stringValidator)); -} - -OldStyleCommandPointer MessageCommandType::Create(std::unique_ptr &&target) -{ - return std::make_shared(*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; } diff --git a/src/commands/MessageCommand.h b/src/commands/MessageCommand.h index d0f53cde9..28dafb320 100644 --- a/src/commands/MessageCommand.h +++ b/src/commands/MessageCommand.h @@ -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 &&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__ */ diff --git a/src/commands/ScriptCommandRelay.cpp b/src/commands/ScriptCommandRelay.cpp index 686d3e116..d9c87a66d 100644 --- a/src/commands/ScriptCommandRelay.cpp +++ b/src/commands/ScriptCommandRelay.cpp @@ -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);