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 // constructors and destructors
60 public:
61 bool ApplyMacro( const MacroCommandsCatalog &catalog,
62 const wxString & filename = {});
63 bool ApplyCommand( const TranslatableString &friendlyCommand,
64 const CommandID & command, const wxString & params,
65 CommandContext const * pContext=NULL );
66 bool ApplyCommandInBatchMode( const TranslatableString &friendlyCommand,
67 const CommandID & command, const wxString &params,
68 CommandContext const * pContext = NULL);
70 const PluginID & ID, const TranslatableString &friendlyCommand,
71 const CommandID & command,
72 const wxString & params, const CommandContext & Context);
73 bool ReportAndSkip( const TranslatableString & friendlyCommand, const wxString & params );
74 void AbortBatch();
75
76 // These commands do not depend on the command list.
77 static void MigrateLegacyChains();
78 static wxArrayString GetNames();
80
81 static wxString GetCurrentParamsFor(const CommandID & command);
82 static wxString PromptForParamsFor(
83 const CommandID & command, const wxString & params, wxWindow &parent);
84 static wxString PromptForPresetFor(const CommandID & command, const wxString & params, wxWindow *parent);
85
86 // These commands do depend on the command list.
87 void ResetMacro();
88
89 void RestoreMacro(const wxString & name);
90 wxString ReadMacro(const wxString & macro, wxWindow *parent = nullptr);
91 wxString WriteMacro(const wxString & macro, wxWindow *parent = nullptr);
92 bool AddMacro(const wxString & macro);
93 bool DeleteMacro(const wxString & name);
94 bool RenameMacro(const wxString & oldmacro, const wxString & newmacro);
95
96 void AddToMacro(const CommandID & command, int before = -1);
97 void AddToMacro(const CommandID & command, const wxString & params, int before = -1);
98
99 void DeleteFromMacro(int index);
100 CommandID GetCommand(int index);
101 wxString GetParams(int index);
102 int GetCount();
103 wxString GetMessage(){ return mMessage;};
104 void AddToMessage(const wxString & msgIn ){ mMessage += msgIn;};
105
106 bool IsFixed(const wxString & name);
107
108 void Split(const wxString & str, wxString & command, wxString & param);
109 wxString Join(const wxString & command, const wxString & param);
110
111private:
113
115 wxArrayString mParamsMacro;
116 bool mAbort;
117 wxString mMessage;
118
120 wxString mFileName;
121};
122
123#endif
#define str(a)
EffectDistortionSettings params
Definition: Distortion.cpp:77
const TranslatableString name
Definition: Distortion.cpp:76
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: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: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)
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