Audacity 3.2.0
EffectAndCommandPluginManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EffectAndCommandManager.h
6
7 Split from EffectManager.h
8
9 Yet another "manager".
10 This one extends the functionality of `EffectManager` from plugins of type
11 `PluginTypeEffect` to also include plugins of type
12 `PluginTypeAudacityCommand`.
13
14 Motivation for this split was remove references to audacity commands from
15 `EffectManager` and be able to make `DoEffect` UI-framework-agnostic.
16
17**********************************************************************/
18#pragma once
19
20#include "Identifier.h"
21#include "TranslatableString.h"
22#include <functional>
23#include <memory>
24#include <wx/string.h>
25
26class Effect;
27class EffectSettings;
28class EffectInstance;
29class AudacityProject;
30class CommandContext;
31class AudacityCommand;
32
33using PluginID = wxString;
34
36{
37public:
39
40 using DialogInvoker = std::function<bool(
41 Effect&, EffectSettings&, std::shared_ptr<EffectInstance>&)>;
42
44 // Returns true on success.
46 const PluginID& ID, const CommandContext&, bool shouldPrompt = true);
47
48 // flags control which commands are included.
50 const PluginID& ID, const CommandContext& context, int flags);
51
53 wxString GetEffectParameters(const PluginID& ID);
54 bool SetEffectParameters(const PluginID& ID, const wxString& params);
55 bool PromptUser(
57 DialogInvoker dialogInvoker);
58
59private:
60 void BatchProcessingOn(const PluginID& ID);
61 void BatchProcessingOff(const PluginID& ID);
64 {
67 {
68 if (p)
70 }
71 };
73 std::unique_ptr<EffectAndCommandPluginManager, UnsetBatchProcessing>;
74
75public:
77
83 {
85 return BatchProcessingScope { this, { ID } };
86 }
87
88private:
89 using AudacityCommandMap = std::unordered_map<wxString, AudacityCommand*>;
90
91 // Used by GetCommandDefinition
94
97};
wxString PluginID
EffectDistortionSettings params
const auto project
Base class for command in Audacity.
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,...
bool PromptUser(const PluginID &ID, AudacityProject &project, DialogInvoker dialogInvoker)
Shows an effect or command dialog so the user can specify settings for later.
std::function< bool(Effect &, EffectSettings &, std::shared_ptr< EffectInstance > &)> DialogInvoker
wxString GetEffectParameters(const PluginID &ID)
void GetCommandDefinition(const PluginID &ID, const CommandContext &context, int flags)
static EffectAndCommandPluginManager & Get()
bool SetEffectParameters(const PluginID &ID, const wxString &params)
bool DoAudacityCommand(const PluginID &ID, const CommandContext &, bool shouldPrompt=true)
std::unique_ptr< EffectAndCommandPluginManager, UnsetBatchProcessing > BatchProcessingScope
BatchProcessingScope SetBatchProcessing(const PluginID &ID)
Begin a scope that ends when the returned object is destroyed.
std::unordered_map< wxString, AudacityCommand * > AudacityCommandMap
AudacityCommand * GetAudacityCommand(const PluginID &ID)
ManualPageID GetCommandUrl(const PluginID &ID)
TranslatableString GetCommandTip(const PluginID &ID)
Base class for many of the effects in Audacity.
Definition: Effect.h:26
Performs effect computation.
Holds a msgid for the translation catalog; may also bind format arguments.
void operator()(EffectAndCommandPluginManager *p) const
Externalized state of a plug-in.