Audacity 3.2.0
EffectUI.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EffectUI.h
6
7 Leland Lucius
8
9 Audacity(R) is copyright (c) 1999-2008 Audacity Team.
10 License: GPL v2 or later. See License.txt.
11
12**********************************************************************/
13
14#ifndef __AUDACITY_EFFECTUI_H__
15#define __AUDACITY_EFFECTUI_H__
16
17#include <optional>
18
19#include "Identifier.h"
20#include "EffectUIServices.h" // for DialogFactoryResults
21#include "EffectPlugin.h" // for its nested types
22#include "Observer.h"
23#include "PluginInterface.h"
26
27struct AudioIOEvent;
28
29#include "EffectInterface.h"
30#include "wxPanelWrapper.h" // to inherit
31
32#include "SelectedRegion.h"
33
34class AudacityCommand;
35class AudacityProject;
36class EffectBase;
38
39class wxCheckBox;
40class AButton;
41
42//
43class EffectUIHost final
44 : public wxDialogWrapper
46{
47public:
48 // constructors and destructors
49 /*
50 @param[out] pInstance may construct
51 (and then must call Init() with success), or leave null for failure
52 */
53 EffectUIHost(wxWindow *parent, AudacityProject &project,
54 EffectBase &effect, EffectUIServices &client,
55 std::shared_ptr<EffectInstance> &pInstance,
57 const std::shared_ptr<RealtimeEffectState> &pPriorState = {});
58 virtual ~EffectUIHost();
59
60 bool TransferDataToWindow() override;
61 bool TransferDataFromWindow() override;
62
63 int ShowModal() override;
64
65 bool Initialize();
66 EffectEditor *GetEditor() const { return mpEditor.get(); }
67
68 bool HandleCommandKeystrokes() override;
69
70 void SetClosed() {
71#if wxDEBUG_LEVEL
72 mClosed = true;
73#endif
74 }
75
76private:
77 std::shared_ptr<EffectInstance> InitializeInstance();
78
80
81 void OnInitDialog(wxInitDialogEvent & evt);
82 void OnErase(wxEraseEvent & evt);
83 void OnPaint(wxPaintEvent & evt);
84 void OnClose(wxCloseEvent & evt);
85 void OnApply(wxCommandEvent & evt);
86 void DoCancel();
87 void OnCancel(wxCommandEvent & evt);
88 void OnDebug(wxCommandEvent & evt);
89 void OnMenu(wxCommandEvent & evt);
90 void OnEnable(wxCommandEvent & evt);
91 void OnPlay(wxCommandEvent & evt);
94 void OnUserPreset(wxCommandEvent & evt);
95 void OnFactoryPreset(wxCommandEvent & evt);
96 void OnDeletePreset(wxCommandEvent & evt);
97 void OnSaveAs(wxCommandEvent & evt);
98 void OnImport(wxCommandEvent & evt);
99 void OnExport(wxCommandEvent & evt);
100 void OnOptions(wxCommandEvent & evt);
101 void OnDefaults(wxCommandEvent & evt);
102 void OnIdle(wxIdleEvent &evt);
103 void OnCharHook(wxKeyEvent& evt);
104
105 bool IsOpenedFromEffectPanel() const;
106
107 void UpdateControls();
108 wxBitmap CreateBitmap(const char * const xpm[], bool up, bool pusher);
109 void LoadUserPresets();
110
111 void CleanupRealtime();
112
113private:
115
117 wxWindow *const mParent;
124 std::weak_ptr<RealtimeEffectState> mwState{};
125 // Temporary state used for destructive processing
126 std::shared_ptr<RealtimeEffectState> mpTempProjectState {};
127
129 bool mInitialized{ false };
131 bool mIsGUI{};
132 bool mIsBatch{};
133
134 wxButton *mApplyBtn{};
135 wxButton *mMenuBtn{};
137 wxButton *mDebugBtn{};
138
139 bool mEnabled{ true };
140
142
144 double mPlayPos{ 0.0 };
145
147 const bool mHadPriorState;
148
149#if wxDEBUG_LEVEL
150 // Used only in an assertion
151 bool mClosed{ false };
152#endif
153
154 const std::shared_ptr<EffectInstance> mpInstance;
156
157 std::unique_ptr<EffectEditor> mpEditor;
158
159 DECLARE_EVENT_TABLE()
160};
161
162class CommandContext;
163
164namespace EffectUI {
165
166 AUDACITY_DLL_API
167 DialogFactoryResults DialogFactory(wxWindow &parent, EffectBase &host,
168 EffectUIServices &client, EffectSettingsAccess &access);
169
171 // Returns true on success. Will only operate on tracks that
172 // have the "selected" flag set to true, which is consistent with
173 // Audacity's standard UI.
174 AUDACITY_DLL_API bool DoEffect(
175 const PluginID & ID, const CommandContext &context, unsigned flags );
176
177}
178
179class ShuttleGui;
180
181// Obsolescent dialog still used only in Noise Reduction/Removal
182class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper
183{
184public:
185 // constructors and destructors
186 EffectDialog(wxWindow * parent,
188 int type = 0,
189 int flags = wxDEFAULT_DIALOG_STYLE,
190 int additionalButtons = 0);
191
192 void Init();
193
194 bool TransferDataToWindow() override;
195 bool TransferDataFromWindow() override;
196 bool Validate() override;
197
198 // NEW virtuals:
199 virtual void PopulateOrExchange(ShuttleGui & S);
200 virtual void OnPreview(wxCommandEvent & evt);
201 virtual void OnOk(wxCommandEvent & evt);
202
203private:
204 int mType;
206
207 DECLARE_EVENT_TABLE()
208 wxDECLARE_NO_COPY_CLASS(EffectDialog);
209};
210
211#if defined(__WXMAC__)
212void MacMakeWindowFloating(NSView *handle);
213#endif
214
215#endif // __AUDACITY_EFFECTUI_H__
wxString PluginID
void MacMakeWindowFloating(NSView *handle)
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
static const auto title
const auto project
#define S(N)
Definition: ToChars.cpp:64
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
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,...
Base class for many of the effects in Audacity.
Definition: EffectBase.h:28
int mAdditionalButtons
Definition: EffectUI.h:205
Hold values to send to effect output meters.
std::shared_ptr< EffectSettingsAccess > EffectSettingsAccessPtr
Definition: EffectPlugin.h:38
void OnEnable(wxCommandEvent &evt)
Definition: EffectUI.cpp:744
void OnFactoryPreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:796
RegistryPaths mUserPresets
Definition: EffectUI.h:128
void OnDefaults(wxCommandEvent &evt)
Definition: EffectUI.cpp:935
Observer::Subscription mAudioIOSubscription
Definition: EffectUI.h:114
bool HandleCommandKeystrokes() override
Definition: EffectUI.cpp:487
void UpdateControls()
Definition: EffectUI.cpp:1009
const EffectPlugin::EffectSettingsAccessPtr mpGivenAccess
Definition: EffectUI.h:121
bool mIsBatch
Definition: EffectUI.h:132
bool mCapturing
Definition: EffectUI.h:141
wxButton * mMenuBtn
Definition: EffectUI.h:135
virtual ~EffectUIHost()
Definition: EffectUI.cpp:263
void OnErase(wxEraseEvent &evt)
Definition: EffectUI.cpp:516
void OnPlayback(AudioIOEvent)
void CleanupRealtime()
Definition: EffectUI.cpp:1090
AudacityProject & mProject
Definition: EffectUI.h:116
std::shared_ptr< RealtimeEffectState > mpTempProjectState
Definition: EffectUI.h:126
bool mIsGUI
Definition: EffectUI.h:131
EffectBase & mEffectUIHost
Definition: EffectUI.h:118
bool TransferDataToWindow() override
Definition: EffectUI.cpp:275
EffectPlugin::EffectSettingsAccessPtr mpAccess
Definition: EffectUI.h:122
const EffectOutputs *const mpOutputs
Definition: EffectUI.h:155
void OnUserPreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:783
void OnDeletePreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:807
void OnIdle(wxIdleEvent &evt)
Definition: EffectUI.cpp:946
int ShowModal() override
Definition: EffectUI.cpp:328
Observer::Subscription mEffectStateSubscription
Definition: EffectUI.h:114
SelectedRegion mRegion
Definition: EffectUI.h:143
void DoCancel()
Definition: EffectUI.cpp:606
void OnCapture(AudioIOEvent)
Definition: EffectUI.cpp:771
EffectUIHost(wxWindow *parent, AudacityProject &project, EffectBase &effect, EffectUIServices &client, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, const std::shared_ptr< RealtimeEffectState > &pPriorState={})
Definition: EffectUI.cpp:228
EffectUIServices & mClient
Definition: EffectUI.h:119
double mPlayPos
Definition: EffectUI.h:144
void OnClose(wxCloseEvent &evt)
Definition: EffectUI.cpp:528
EffectEditor * GetEditor() const
Definition: EffectUI.h:66
void OnExport(wxCommandEvent &evt)
Definition: EffectUI.cpp:918
AButton * mEnableBtn
Definition: EffectUI.h:136
void BuildTopBar(ShuttleGui &S)
Definition: EffectUI.cpp:356
void OnSaveAs(wxCommandEvent &evt)
Definition: EffectUI.cpp:826
void SetClosed()
Definition: EffectUI.h:70
wxButton * mApplyBtn
Definition: EffectUI.h:134
const bool mHadPriorState
Definition: EffectUI.h:147
void OnOptions(wxCommandEvent &evt)
Definition: EffectUI.cpp:928
void LoadUserPresets()
Definition: EffectUI.cpp:1025
void OnInitDialog(wxInitDialogEvent &evt)
Definition: EffectUI.cpp:493
void OnMenu(wxCommandEvent &evt)
Definition: EffectUI.cpp:649
void OnDebug(wxCommandEvent &evt)
Definition: EffectUI.cpp:633
void OnCharHook(wxKeyEvent &evt)
Definition: EffectUI.cpp:953
bool mEnabled
Definition: EffectUI.h:139
EffectPlugin::EffectSettingsAccessPtr mpAccess2
Definition: EffectUI.h:123
void OnImport(wxCommandEvent &evt)
Definition: EffectUI.cpp:906
std::unique_ptr< EffectEditor > mpEditor
Definition: EffectUI.h:157
std::shared_ptr< EffectInstance > InitializeInstance()
Definition: EffectUI.cpp:1037
void OnApply(wxCommandEvent &evt)
Definition: EffectUI.cpp:544
const bool mSupportsRealtime
Definition: EffectUI.h:130
bool Initialize()
Definition: EffectUI.cpp:394
void OnPlay(wxCommandEvent &evt)
Definition: EffectUI.cpp:757
const std::shared_ptr< EffectInstance > mpInstance
Definition: EffectUI.h:154
void OnCancel(wxCommandEvent &evt)
Definition: EffectUI.cpp:627
bool mInitialized
Definition: EffectUI.h:129
std::weak_ptr< RealtimeEffectState > mwState
Definition: EffectUI.h:124
wxWindow *const mParent
Definition: EffectUI.h:117
wxButton * mDebugBtn
Definition: EffectUI.h:137
wxBitmap CreateBitmap(const char *const xpm[], bool up, bool pusher)
Definition: EffectUI.cpp:976
bool IsOpenedFromEffectPanel() const
Definition: EffectUI.cpp:971
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:287
void OnPaint(wxPaintEvent &evt)
Definition: EffectUI.cpp:521
bool mDismissed
Definition: EffectUI.h:146
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
Defines a selected portion of a project.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
Holds a msgid for the translation catalog; may also bind format arguments.
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1148
AUDACITY_DLL_API DialogFactoryResults DialogFactory(wxWindow &parent, EffectBase &host, EffectUIServices &client, EffectSettingsAccess &access)
Definition: EffectUI.cpp:1111