Audacity 3.2.0
BatchCommands.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 MacroCommands.h
6
7 Dominic Mazzoni
8 James Crook
9
10**********************************************************************/
11
12#ifndef __AUDACITY_BATCH_COMMANDS_DIALOG__
13#define __AUDACITY_BATCH_COMMANDS_DIALOG__
14
15#include <wx/defs.h>
16
17#include "export/Export.h"
18#include "ComponentInterface.h" // for ComponentInterfaceSymbol
19#include "PluginProvider.h" // for PluginID
20
21class wxArrayString;
22class Effect;
23class CommandContext;
24class CommandManager;
25class AudacityProject;
26class wxArrayStringEx;
27
29public:
30 // A triple of user-visible name, internal string identifier and type/help string.
31 struct Entry {
34 };
35 using Entries = std::vector<Entry>;
36
37 MacroCommandsCatalog( const AudacityProject *project );
38
39 // binary search
40 Entries::const_iterator ByFriendlyName( const TranslatableString &friendlyName ) const;
41 // linear search
42 Entries::const_iterator ByCommandId( const CommandID &commandId ) const;
43
44 // Lookup by position as sorted by friendly name
45 const Entry &operator[] ( size_t index ) const { return mCommands[index]; }
46
47 Entries::const_iterator begin() const { return mCommands.begin(); }
48 Entries::const_iterator end() const { return mCommands.end(); }
49
50private:
51 // Sorted by friendly name
53};
54
55// Stores information for one macro
56class MacroCommands final {
57 public:
58 static bool DoAudacityCommand(
59 const PluginID & ID, const CommandContext & context, unsigned flags );
60
61 // constructors and destructors
63 public:
64 bool ApplyMacro( const MacroCommandsCatalog &catalog,
65 const wxString & filename = {});
66 bool ApplyCommand( const TranslatableString &friendlyCommand,
67 const CommandID & command, const wxString & params,
68 CommandContext const * pContext=NULL );
69 bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
70 const CommandID & command, const wxString &params,
71 CommandContext const * pContext = NULL);
73 const PluginID & ID, const TranslatableString &friendlyCommand,
74 const CommandID & command,
75 const wxString & params, const CommandContext & Context);
76 bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
77 void AbortBatch();
78
79 // These commands do not depend on the command list.
80 static void MigrateLegacyChains();
81 static wxArrayString GetNames();
83
84 static wxString GetCurrentParamsFor(const CommandID & command);
85 static wxString PromptForParamsFor(
86 const CommandID & command, const wxString & params, wxWindow &parent);
87 static wxString PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent);
88
89 // These commands do depend on the command list.
90 void ResetMacro();
91
92 void RestoreMacro(const wxString & name);
93 wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr);
94 wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr);
95 bool AddMacro(const wxString & macro);
96 bool DeleteMacro(const wxString & name);
97 bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
98
99 void AddToMacro(const CommandID & command, int before = -1);
100 void AddToMacro(const CommandID & command, const wxString & params, int before = -1);
101
102 void DeleteFromMacro(int index);
103 CommandID GetCommand(int index);
104 wxString GetParams(int index);
105 int GetCount();
106 wxString GetMessage(){ return mMessage;};
107 void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
108
109 bool IsFixed(const wxString & name);
110
111 void Split(const wxString & str, wxString & command, wxString & param);
112 wxString Join(const wxString & command, const wxString & param);
113
114private:
116
118 wxArrayString mParamsMacro;
119 bool mAbort;
120 wxString mMessage;
121
123 wxString mFileName;
124};
125
126#endif
#define str(a)
EffectDistortion::Params params
Definition: Distortion.cpp:83
const TranslatableString name
Definition: Distortion.cpp:82
wxString PluginID
Definition: EffectManager.h:30
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
Generalized interface for discovery of plug-ins for one protocol.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandManager implements a system for organizing all user-callable commands.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for many of the effects in Audacity.
Definition: Effect.h:29
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:48
std::vector< Entry > Entries
Definition: BatchCommands.h:35
const Entry & operator[](size_t index) const
Definition: BatchCommands.h:45
Entries::const_iterator begin() const
Definition: BatchCommands.h:47
MacroCommandsCatalog(const AudacityProject *project)
Entries::const_iterator ByFriendlyName(const TranslatableString &friendlyName) const
Maintains the list of commands for batch/macro processing. See also MacrosWindow and ApplyMacroDialog...
Definition: BatchCommands.h:56
static wxArrayStringEx GetNamesOfDefaultMacros()
static wxString PromptForPresetFor(const CommandID &command, const wxString &params, wxWindow *parent)
bool IsFixed(const wxString &name)
CommandIDs mCommandMacro
wxString GetMessage()
void AddToMacro(const CommandID &command, int before=-1)
bool ApplyEffectCommand(const PluginID &ID, const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, const CommandContext &Context)
wxString mFileName
bool ApplyCommand(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=NULL)
wxString GetParams(int index)
void DeleteFromMacro(int index)
Exporter mExporter
wxArrayString mParamsMacro
wxString Join(const wxString &command, const wxString &param)
static wxString GetCurrentParamsFor(const CommandID &command)
static void MigrateLegacyChains()
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
CommandID GetCommand(int index)
static wxArrayString GetNames()
bool DeleteMacro(const wxString &name)
bool ReportAndSkip(const TranslatableString &friendlyCommand, const wxString &params)
void Split(const wxString &str, wxString &command, wxString &param)
wxString mMessage
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
bool AddMacro(const wxString &macro)
MacroCommands(AudacityProject &project)
wxString ReadMacro(const wxString &macro, wxWindow *parent=nullptr)
void RestoreMacro(const wxString &name)
void AddToMessage(const wxString &msgIn)
static bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
AudacityProject & mProject
bool ApplyCommandInBatchMode(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=NULL)
Holds a msgid for the translation catalog; may also bind format arguments.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: BatchCommands.h:31
ComponentInterfaceSymbol name
Definition: BatchCommands.h:32
TranslatableString category
Definition: BatchCommands.h:33