mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-08 16:11:14 +02:00
Make Message command into an AudacityCommand.
This commit is contained in:
parent
edf90d6e2c
commit
f7fe295651
@ -1596,6 +1596,8 @@ void AudacityProject::CreateMenusAndCommands()
|
|||||||
// you would have to use "Compareaudio" here.)
|
// you would have to use "Compareaudio" here.)
|
||||||
// c->AddItem(wxT("Demo"), _("Just a Demo..."), FN(OnAudacityCommand),
|
// c->AddItem(wxT("Demo"), _("Just a Demo..."), FN(OnAudacityCommand),
|
||||||
// AudioIONotBusyFlag, AudioIONotBusyFlag);
|
// AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||||
|
c->AddItem(wxT("Message"), _("Message..."), FN(OnAudacityCommand),
|
||||||
|
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||||
c->AddItem(wxT("Screenshot"), _("Screenshot (Vanilla)..."), FN(OnAudacityCommand),
|
c->AddItem(wxT("Screenshot"), _("Screenshot (Vanilla)..."), FN(OnAudacityCommand),
|
||||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||||
c->AddItem(wxT("Select"), _("Select..."), FN(OnAudacityCommand),
|
c->AddItem(wxT("Select"), _("Select..."), FN(OnAudacityCommand),
|
||||||
|
@ -161,7 +161,6 @@ scroll information. It also has some status flags.
|
|||||||
#include "tracks/ui/Scrubbing.h"
|
#include "tracks/ui/Scrubbing.h"
|
||||||
|
|
||||||
#include "commands/ScriptCommandRelay.h"
|
#include "commands/ScriptCommandRelay.h"
|
||||||
#include "commands/CommandDirectory.h"
|
|
||||||
#include "commands/CommandTargets.h"
|
#include "commands/CommandTargets.h"
|
||||||
#include "commands/Command.h"
|
#include "commands/Command.h"
|
||||||
#include "commands/CommandType.h"
|
#include "commands/CommandType.h"
|
||||||
@ -5170,25 +5169,6 @@ void AudacityProject::TP_DisplayStatusMessage(const wxString &msg)
|
|||||||
mLastStatusUpdateTime = ::wxGetUTCTime();
|
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()
|
void AudacityProject::TP_DisplaySelection()
|
||||||
{
|
{
|
||||||
double audioTime;
|
double audioTime;
|
||||||
|
@ -459,8 +459,6 @@ public:
|
|||||||
void FinishAutoScroll();
|
void FinishAutoScroll();
|
||||||
void FixScrollbars();
|
void FixScrollbars();
|
||||||
|
|
||||||
void SafeDisplayStatusMessage(const wxChar *msg);
|
|
||||||
|
|
||||||
bool MayScrollBeyondZero() const;
|
bool MayScrollBeyondZero() const;
|
||||||
double ScrollingLowerBoundTime() const;
|
double ScrollingLowerBoundTime() const;
|
||||||
// How many pixels are covered by the period from lowermost scrollable time, to the given time:
|
// How many pixels are covered by the period from lowermost scrollable time, to the given time:
|
||||||
|
@ -20,7 +20,6 @@ It forwards the actual work of doing the commands to the ScreenshotCommand.
|
|||||||
#include "MemoryX.h"
|
#include "MemoryX.h"
|
||||||
#include "commands/ScreenshotCommand.h"
|
#include "commands/ScreenshotCommand.h"
|
||||||
#include "commands/CommandTargets.h"
|
#include "commands/CommandTargets.h"
|
||||||
#include "commands/CommandDirectory.h"
|
|
||||||
#include "commands/CommandContext.h"
|
#include "commands/CommandContext.h"
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/event.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_unique<CommandOutputTargets>(std::make_unique<NullProgressTarget>(),
|
||||||
std::make_shared<StatusBarTarget>(*mStatus),
|
std::make_shared<StatusBarTarget>(*mStatus),
|
||||||
std::make_shared<MessageBoxTarget>());
|
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);
|
return std::make_unique<ScreenshotCommand>();//*type, std::move(output), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ CommandDirectory::CommandDirectory()
|
|||||||
{
|
{
|
||||||
// Create the command map.
|
// Create the command map.
|
||||||
// First we have commands which return information
|
// First we have commands which return information
|
||||||
AddCommand(make_movable<MessageCommandType>());
|
//AddCommand(make_movable<MessageCommandType>());
|
||||||
AddCommand(make_movable<BatchEvalCommandType>());
|
AddCommand(make_movable<BatchEvalCommandType>());
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "../Audacity.h"
|
#include "../Audacity.h"
|
||||||
#include "HelpCommand.h"
|
#include "HelpCommand.h"
|
||||||
//#include "../Project.h"
|
|
||||||
//#include "../Track.h"
|
|
||||||
#include "../ShuttleGui.h"
|
#include "../ShuttleGui.h"
|
||||||
#include "CommandContext.h"
|
#include "CommandContext.h"
|
||||||
#include "../effects/EffectManager.h"
|
#include "../effects/EffectManager.h"
|
||||||
|
@ -22,6 +22,7 @@ modelled on BuiltinEffectsModule
|
|||||||
#include "../effects/EffectManager.h"
|
#include "../effects/EffectManager.h"
|
||||||
#include "Demo.h"
|
#include "Demo.h"
|
||||||
#include "../Experimental.h"
|
#include "../Experimental.h"
|
||||||
|
#include "../commands/MessageCommand.h"
|
||||||
#include "../commands/ScreenshotCommand.h"
|
#include "../commands/ScreenshotCommand.h"
|
||||||
#include "../commands/CompareAudioCommand.h"
|
#include "../commands/CompareAudioCommand.h"
|
||||||
#include "../commands/SetTrackInfoCommand.h"
|
#include "../commands/SetTrackInfoCommand.h"
|
||||||
@ -43,6 +44,7 @@ modelled on BuiltinEffectsModule
|
|||||||
//
|
//
|
||||||
#define COMMAND_LIST \
|
#define COMMAND_LIST \
|
||||||
COMMAND( DEMO, DemoCommand, () ) \
|
COMMAND( DEMO, DemoCommand, () ) \
|
||||||
|
COMMAND( MESSAGE, MessageCommand, () ) \
|
||||||
COMMAND( SCREENSHOT, ScreenshotCommand, () ) \
|
COMMAND( SCREENSHOT, ScreenshotCommand, () ) \
|
||||||
COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \
|
COMMAND( COMPARE_AUDIO, CompareAudioCommand, () ) \
|
||||||
COMMAND( SET_TRACK, SetTrackCommand, () ) \
|
COMMAND( SET_TRACK, SetTrackCommand, () ) \
|
||||||
|
@ -17,26 +17,25 @@
|
|||||||
#include "MessageCommand.h"
|
#include "MessageCommand.h"
|
||||||
#include "CommandType.h"
|
#include "CommandType.h"
|
||||||
#include "CommandContext.h"
|
#include "CommandContext.h"
|
||||||
|
#include "../ShuttleGui.h"
|
||||||
|
|
||||||
wxString MessageCommandType::BuildName()
|
bool MessageCommand::DefineParams( ShuttleParams & S ){
|
||||||
{
|
S.Define( mMessage, wxT("Text"), "Some message" );
|
||||||
return wxT("Message");
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageCommandType::BuildSignature(CommandSignature &signature)
|
void MessageCommand::PopulateOrExchange(ShuttleGui & S)
|
||||||
{
|
{
|
||||||
auto stringValidator = make_movable<DefaultValidator>();
|
S.AddSpace(0, 5);
|
||||||
signature.AddParameter(wxT("MessageString"), wxT("Connected"), std::move(stringValidator));
|
|
||||||
}
|
S.StartMultiColumn(2, wxALIGN_CENTER);
|
||||||
|
{
|
||||||
OldStyleCommandPointer MessageCommandType::Create(std::unique_ptr<CommandOutputTargets> &&target)
|
S.TieTextBox(_("Text:"),mMessage,60);
|
||||||
{
|
}
|
||||||
return std::make_shared<MessageCommand>(*this);
|
S.EndMultiColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessageCommand::Apply(const CommandContext & context)
|
bool MessageCommand::Apply(const CommandContext & context){
|
||||||
{
|
context.Status( mMessage );
|
||||||
wxString message = GetString(wxT("MessageString"));
|
|
||||||
context.Status(message);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,26 +18,29 @@
|
|||||||
|
|
||||||
*//*******************************************************************/
|
*//*******************************************************************/
|
||||||
|
|
||||||
#ifndef __MESSAGECOMMAND__
|
#ifndef __MESSAGE_COMMAND__
|
||||||
#define __MESSAGECOMMAND__
|
#define __MESSAGE_COMMAND__
|
||||||
|
|
||||||
#include "Command.h"
|
|
||||||
#include "CommandType.h"
|
#include "CommandType.h"
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
class MessageCommandType final : public OldStyleCommandType
|
#define MESSAGE_PLUGIN_SYMBOL XO("Message")
|
||||||
|
|
||||||
|
class MessageCommand : public AudacityCommand
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxString BuildName() override;
|
// CommandDefinitionInterface overrides
|
||||||
void BuildSignature(CommandSignature &signature) override;
|
wxString GetSymbol() override {return MESSAGE_PLUGIN_SYMBOL;};
|
||||||
OldStyleCommandPointer Create(std::unique_ptr<CommandOutputTargets> &&target) override;
|
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__ */
|
#endif /* End of include guard: __MESSAGECOMMAND__ */
|
||||||
|
@ -72,7 +72,6 @@ int ExecCommand(wxString *pIn, wxString *pOut)
|
|||||||
if (builder.WasValid())
|
if (builder.WasValid())
|
||||||
{
|
{
|
||||||
AudacityProject *project = GetActiveProject();
|
AudacityProject *project = GetActiveProject();
|
||||||
//project->SafeDisplayStatusMessage(wxT("Received script command"));
|
|
||||||
OldStyleCommandPointer cmd = builder.GetCommand();
|
OldStyleCommandPointer cmd = builder.GetCommand();
|
||||||
ScriptCommandRelay::PostCommand(project, cmd);
|
ScriptCommandRelay::PostCommand(project, cmd);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user