Audacity 3.2.0
EffectUIServices.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file EffectUIServices.cpp
6
7 Paul Licameli split from EffectPlugin.cpp
8
9**********************************************************************/
10#include "EffectUIServices.h"
11#include "EffectBase.h"
12#include "AudacityMessageBox.h"
13
15
17 wxWindow &parent,
19 std::shared_ptr<EffectInstance> &pInstance, EffectSettingsAccess &access,
20 bool forceModal)
21{
22 if (!plugin.IsInteractive())
23 // Effect without UI just proceeds quietly to apply it destructively.
24 return wxID_APPLY;
25
26 // Create the dialog
27 auto results = factory(parent, plugin, *this, access);
28 auto pDialog = results.pDialog;
29 pInstance = results.pInstance;
30 if (!pDialog)
31 return 0;
32
33 // Let the derived class show the dialog and decide whether to keep it open
34 auto result = ShowClientInterface(plugin, parent, *pDialog,
35 results.pEditor, forceModal);
36 if (pDialog && !pDialog->IsShown())
37 // Derived class didn't show it, or showed it modally and closed it
38 // So destroy it.
39 pDialog->Destroy();
40
41 return result;
42}
43
45 const TranslatableString& message,
46 long style, const TranslatableString &titleStr)
47{
48 auto title = titleStr.empty()
49 ? plugin.GetName()
50 : XO("%s: %s").Format(plugin.GetName(), titleStr);
51 return AudacityMessageBox(message, title, style);
52}
53
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static RegisteredToolbarFactory factory
std::function< DialogFactoryResults(wxWindow &parent, EffectBase &, EffectUIServices &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
XO("Cut/Copy/Paste")
static const auto title
TranslatableString GetName() const
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
virtual bool IsInteractive() const =0
Whether the effect needs a dialog for entry of settings.
Factory of instances of an effect.
Definition: EffectPlugin.h:36
virtual ~EffectUIServices()
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
virtual int ShowClientInterface(const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
virtual int ShowHostInterface(EffectBase &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
Holds a msgid for the translation catalog; may also bind format arguments.