1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-22 06:22:58 +02:00

Automation: AudacityCommand

This is a squash of 50 commits.

This merges the capabilities of BatchCommands and Effects using a new
AudacityCommand class.  AudacityCommand provides one function to specify the
parameters, and then we leverage that one function in automation, whether by chains,
mod-script-pipe or (future) Nyquist.

- Now have AudacityCommand which is using the same mechanism as Effect
- Has configurable parameters
- Has data-entry GUI (built using shuttle GUI)
- Registers with PluginManager.
- Menu commands now provided in chains, and to python batch.
   - Tested with Zoom Toggle.

- ShuttleParams now can set, get, set defaults, validate and specify
the parameters.
- Bugfix: Don't overwrite values with defaults first time out.
- Add DefineParams function for all built-in effects.
- Extend CommandContext to carry output channels for results.

We abuse EffectsManager.  It handles both Effects and
AudacityCommands now.  In time an Effect should become a special case of
AudacityCommand and we'll split and rename the EffectManager class.

- Don't use 'default' as a parameter name.
- Massive renaming for CommandDefinitionInterface
- EffectIdentInterface becomes EffectDefinitionInterface
- EffectAutomationParameters becomes CommandAutomationParameters
- PluginType is now a bit field.

This way we can search for related types at the same time.

- Most old batch commands made into AudacityCommands.
The ones that weren't are for a reason.  They are used by mod-script-pipe
to carry commands and responses across from a non-GUI thread to the GUI
thread.

- Major tidy up of ScreenshotCommand
- Reworking of SelectCommand
- GetPreferenceCommand and SetPreferenceCommand
- GetTrackInfo and SetTrackInfo
- GetInfoCommand
- Help, Open, Save, Import and Export commands.
- Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo
  which are now better handled by other commands.

- JSONify "GetInfo: Commands" output, i.e. commas in the right places.

- General work on better Doxygen.
    - Lyrics -> LyricsPanel
    - Meter -> MeterPanel
- Updated Linux makefile.
- Scripting commands added into Extra menu.
- Distinct names for previously duplicated find-clipping parameters.
- Fixed longstanding error with erroneous status field number which
  previously caused an ASSERT in debug.
- Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
This commit is contained in:
James Crook
2018-01-14 18:51:41 +00:00
committed by Paul Licameli
parent b7b01d48e0
commit 1c988b4e3a
191 changed files with 4659 additions and 2768 deletions

View File

@@ -11,26 +11,6 @@
\file Command.h
\brief Contains declaration of Command base class.
\class CommandExecutionContext
\brief Represents a context to which a command may be applied.
\class Command
\brief Abstract base class for command interface. It implements
Command::SetParameter() and defers all other operations to derived classes.
That process may depend on certain parameters (determined by the command's
signature) and may produce output on various channels. Any process which is to
be controlled by a script should be separated out into its own Command class.
(And that class should be registered with the CommandDirectory).
\class ApplyAndSendResponse
\brief Decorator command that performs the given command and then
outputs a status message according to the result.
\class CommandImplementation,
\brief is derived from Command. It validates and
applies the command. CommandImplementation::Apply() is overloaded in
classes derived from it.
*//*******************************************************************/
@@ -38,61 +18,40 @@ classes derived from it.
#define __COMMAND__
#include <wx/app.h>
#include "../Project.h"
#include "../MemoryX.h"
#include "CommandMisc.h"
#include "CommandSignature.h"
#include "CommandTargets.h"
#include "../commands/AudacityCommand.h"
class AudacityApp;
class CommandContext;
class CommandOutputTarget;
class CommandExecutionContext
{
public:
CommandExecutionContext(AudacityApp *WXUNUSED(app), AudacityProject *WXUNUSED(proj))
{
};
AudacityApp *GetApp() const
{
return (AudacityApp *) wxTheApp;
};
AudacityProject *GetProject() const
{
// TODO: Presumably, this would be different if running in a command context.
// So, if this command system is ever actually enabled, then this will need to
// be reviewed.
return GetActiveProject();
};
};
// Abstract base class for command interface.
class Command /* not final */
class OldStyleCommand /* not final */
{
public:
virtual void Progress(double completed) = 0;
virtual void Status(const wxString &message) = 0;
virtual void Error(const wxString &message) = 0;
virtual ~Command() { }
OldStyleCommand() {};
virtual ~OldStyleCommand() { }
virtual wxString GetName() = 0;
virtual CommandSignature &GetSignature() = 0;
virtual bool SetParameter(const wxString &paramName, const wxVariant &paramValue);
virtual bool Apply(CommandExecutionContext context) = 0;
virtual bool Apply()=0;
virtual bool Apply(const CommandContext &context) = 0;
};
using CommandHolder = std::shared_ptr<Command>;
using OldStyleCommandPointer = std::shared_ptr<OldStyleCommand>;
/// Command which wraps another command
class DecoratedCommand /* not final */ : public Command
/// It ISA command and HAS a command.
class DecoratedCommand /* not final */ : public OldStyleCommand
{
protected:
CommandHolder mCommand;
OldStyleCommandPointer mCommand;
public:
void Progress(double completed) override;
void Status(const wxString &message) override;
void Error(const wxString &message) override;
DecoratedCommand(const CommandHolder &cmd)
DecoratedCommand(const OldStyleCommandPointer &cmd)
: mCommand(cmd)
{
wxASSERT(cmd != NULL);
@@ -108,14 +67,14 @@ public:
class ApplyAndSendResponse final : public DecoratedCommand
{
public:
ApplyAndSendResponse(const CommandHolder &cmd)
: DecoratedCommand(cmd)
{ }
ApplyAndSendResponse(const OldStyleCommandPointer &cmd, std::unique_ptr<CommandOutputTarget> &target);
bool Apply() override;
bool Apply(const CommandContext &context) override;// Error to use this.
std::unique_ptr<CommandContext> mCtx;
bool Apply(CommandExecutionContext context) override;
};
class CommandImplementation /* not final */ : public Command
class CommandImplementation /* not final */ : public OldStyleCommand
{
private:
CommandType &mType;
@@ -127,8 +86,6 @@ private:
bool Valid(const wxString &paramName, const wxVariant &paramValue);
protected:
std::unique_ptr<CommandOutputTarget> mOutput;
// Convenience methods for allowing subclasses to access parameters
void TypeCheck(const wxString &typeName,
const wxString &paramName,
@@ -141,15 +98,9 @@ protected:
wxString GetString(const wxString &paramName);
public:
// Convenience methods for passing messages to the output target
void Progress(double completed);
void Status(const wxString &status) override;
void Error(const wxString &message) override;
/// Constructor should not be called directly; only by a factory which
/// ensures name and params are set appropriately for the command.
CommandImplementation(CommandType &type,
std::unique_ptr<CommandOutputTarget> &&output);
CommandImplementation(CommandType &type);
virtual ~CommandImplementation();
@@ -168,7 +119,8 @@ public:
/// Actually carry out the command. Return true if successful and false
/// otherwise.
bool Apply(CommandExecutionContext context) override;
bool Apply() { return false;};// No longer supported.
bool Apply(const CommandContext &context) override;
};
#endif /* End of include guard: __COMMAND__ */