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.h"
18#include "ComponentInterface.h" // for ComponentInterfaceSymbol
19#include "PluginProvider.h" // for PluginID
20
21class wxArrayString;
22class wxWindow;
23class Effect;
24class CommandContext;
25class CommandManager;
26class AudacityProject;
27class wxArrayStringEx;
28
30public:
31 // A triple of user-visible name, internal string identifier and type/help string.
32 struct Entry {
35 };
36 using Entries = std::vector<Entry>;
37
39
40 // binary search
41 Entries::const_iterator ByFriendlyName( const TranslatableString &friendlyName ) const;
42 // linear search
43 Entries::const_iterator ByCommandId( const CommandID &commandId ) const;
44 // linear search
45 Entries::const_iterator ByTranslation(const wxString &translation) const;
46
47
48 // Lookup by position as sorted by friendly name
49 const Entry &operator[] ( size_t index ) const { return mCommands[index]; }
50
51 Entries::const_iterator begin() const { return mCommands.begin(); }
52 Entries::const_iterator end() const { return mCommands.end(); }
53
54private:
55 // Sorted by friendly name
57};
58
59// Stores information for one macro
60class MacroCommands final {
61 public:
62 // constructors and destructors
65 public:
66 bool ApplyMacro( const MacroCommandsCatalog &catalog,
67 const wxString & filename = {});
71 bool ApplyCommand( const TranslatableString &friendlyCommand,
72 const CommandID & command, const wxString & params,
73 CommandContext const * pContext = nullptr);
77 bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
78 const CommandID & command, const wxString &params,
79 CommandContext const * pContext = nullptr);
81 const PluginID & ID, const TranslatableString &friendlyCommand,
82 const CommandID & command,
83 const wxString & params, const CommandContext & Context);
84 bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
85 void AbortBatch();
86
87 // These commands do not depend on the command list.
88 static void MigrateLegacyChains();
89 static wxArrayString GetNames();
91
92 static wxString GetCurrentParamsFor(const CommandID & command);
93 static wxString PromptForParamsFor(
94 const CommandID& command, const wxString& params,
96 static wxString PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent);
97
98 // These commands do depend on the command list.
99 void ResetMacro();
100
101 void RestoreMacro(const wxString & name);
102 wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr);
103 wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr);
104 bool AddMacro(const wxString & macro);
105 bool DeleteMacro(const wxString & name);
106 bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
107
108 void AddToMacro(const CommandID & command, int before = -1);
109 void AddToMacro(const CommandID & command, const wxString & params, int before = -1);
110
111 void DeleteFromMacro(int index);
112 CommandID GetCommand(int index);
113 wxString GetParams(int index);
114 int GetCount();
115 wxString GetMessage(){ return mMessage;};
116 void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
117
118 bool IsFixed(const wxString & name);
119
120 void Split(const wxString & str, wxString & command, wxString & param);
121 wxString Join(const wxString & command, const wxString & param);
122
123private:
125
127 wxArrayString mParamsMacro;
128 bool mAbort;
129 wxString mMessage;
130
131 wxString mFileName;
132};
133
134#endif
wxString PluginID
#define str(a)
EffectDistortionSettings params
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
Generalized interface for discovery of plug-ins for one protocol.
wxString name
Definition: TagsEditor.cpp:166
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
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:26
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:52
Entries::const_iterator ByTranslation(const wxString &translation) const
std::vector< Entry > Entries
Definition: BatchCommands.h:36
const Entry & operator[](size_t index) const
Definition: BatchCommands.h:49
Entries::const_iterator begin() const
Definition: BatchCommands.h:51
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:60
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, AudacityProject &project)
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=nullptr)
wxString GetParams(int index)
void DeleteFromMacro(int index)
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)
bool ApplyCommandInBatchMode(const TranslatableString &friendlyCommand, const CommandID &command, const wxString &params, CommandContext const *pContext=nullptr)
wxString mMessage
AudacityProject & GetProject()
Definition: BatchCommands.h:64
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
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)
AudacityProject & mProject
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:32
ComponentInterfaceSymbol name
Definition: BatchCommands.h:33
TranslatableString category
Definition: BatchCommands.h:34