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
45 // Lookup by position as sorted by friendly name
46 const Entry &operator[] ( size_t index ) const { return mCommands[index]; }
47
48 Entries::const_iterator begin() const { return mCommands.begin(); }
49 Entries::const_iterator end() const { return mCommands.end(); }
50
51private:
52 // Sorted by friendly name
54};
55
56// Stores information for one macro
57class MacroCommands final {
58 public:
59 // constructors and destructors
62 public:
63 bool ApplyMacro( const MacroCommandsCatalog &catalog,
64 const wxString & filename = {});
68 bool ApplyCommand( const TranslatableString &friendlyCommand,
69 const CommandID & command, const wxString & params,
70 CommandContext const * pContext = nullptr);
74 bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
75 const CommandID & command, const wxString &params,
76 CommandContext const * pContext = nullptr);
78 const PluginID & ID, const TranslatableString &friendlyCommand,
79 const CommandID & command,
80 const wxString & params, const CommandContext & Context);
81 bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
82 void AbortBatch();
83
84 // These commands do not depend on the command list.
85 static void MigrateLegacyChains();
86 static wxArrayString GetNames();
88
89 static wxString GetCurrentParamsFor(const CommandID & command);
90 static wxString PromptForParamsFor(
91 const CommandID & command, const wxString & params, wxWindow &parent);
92 static wxString PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent);
93
94 // These commands do depend on the command list.
95 void ResetMacro();
96
97 void RestoreMacro(const wxString & name);
98 wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr);
99 wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr);
100 bool AddMacro(const wxString & macro);
101 bool DeleteMacro(const wxString & name);
102 bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
103
104 void AddToMacro(const CommandID & command, int before = -1);
105 void AddToMacro(const CommandID & command, const wxString & params, int before = -1);
106
107 void DeleteFromMacro(int index);
108 CommandID GetCommand(int index);
109 wxString GetParams(int index);
110 int GetCount();
111 wxString GetMessage(){ return mMessage;};
112 void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
113
114 bool IsFixed(const wxString & name);
115
116 void Split(const wxString & str, wxString & command, wxString & param);
117 wxString Join(const wxString & command, const wxString & param);
118
119private:
121
123 wxArrayString mParamsMacro;
124 bool mAbort;
125 wxString mMessage;
126
127 wxString mFileName;
128};
129
130#endif
wxString PluginID
#define str(a)
EffectDistortionSettings params
Definition: Distortion.cpp:77
const TranslatableString name
Definition: Distortion.cpp:76
std::vector< CommandID > CommandIDs
Definition: Identifier.h:233
Generalized interface for discovery of plug-ins for one protocol.
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:49
std::vector< Entry > Entries
Definition: BatchCommands.h:36
const Entry & operator[](size_t index) const
Definition: BatchCommands.h:46
Entries::const_iterator begin() const
Definition: BatchCommands.h:48
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:57
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:61
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)
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