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}
170
171class ShuttleGui;
172
173// Obsolescent dialog still used only in Noise Reduction/Removal
174class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper
175{
176public:
177 // constructors and destructors
178 EffectDialog(wxWindow * parent,
180 int type = 0,
181 int flags = wxDEFAULT_DIALOG_STYLE,
182 int additionalButtons = 0);
183
184 void Init();
185
186 bool TransferDataToWindow() override;
187 bool TransferDataFromWindow() override;
188 bool Validate() override;
189
190 // NEW virtuals:
191 virtual void PopulateOrExchange(ShuttleGui & S);
192 virtual void OnPreview(wxCommandEvent & evt);
193 virtual void OnOk(wxCommandEvent & evt);
194
195private:
196 int mType;
198
199 DECLARE_EVENT_TABLE()
200 wxDECLARE_NO_COPY_CLASS(EffectDialog);
201};
202
203#if defined(__WXMAC__)
204void MacMakeWindowFloating(NSView *handle);
205#endif
206
207#endif // __AUDACITY_EFFECTUI_H__
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:33
int mAdditionalButtons
Definition: EffectUI.h:197
Hold values to send to effect output meters.
std::shared_ptr< EffectSettingsAccess > EffectSettingsAccessPtr
Definition: EffectPlugin.h:38
void OnEnable(wxCommandEvent &evt)
Definition: EffectUI.cpp:745
void OnFactoryPreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:797
RegistryPaths mUserPresets
Definition: EffectUI.h:128
void OnDefaults(wxCommandEvent &evt)
Definition: EffectUI.cpp:936
Observer::Subscription mAudioIOSubscription
Definition: EffectUI.h:114
bool HandleCommandKeystrokes() override
Definition: EffectUI.cpp:488
void UpdateControls()
Definition: EffectUI.cpp:1010
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:517
void OnPlayback(AudioIOEvent)
void CleanupRealtime()
Definition: EffectUI.cpp:1091
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:784
void OnDeletePreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:808
void OnIdle(wxIdleEvent &evt)
Definition: EffectUI.cpp:947
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:607
void OnCapture(AudioIOEvent)
Definition: EffectUI.cpp:772
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:529
EffectEditor * GetEditor() const
Definition: EffectUI.h:66
void OnExport(wxCommandEvent &evt)
Definition: EffectUI.cpp:919
AButton * mEnableBtn
Definition: EffectUI.h:136
void BuildTopBar(ShuttleGui &S)
Definition: EffectUI.cpp:356
void OnSaveAs(wxCommandEvent &evt)
Definition: EffectUI.cpp:827
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:929
void LoadUserPresets()
Definition: EffectUI.cpp:1026
void OnInitDialog(wxInitDialogEvent &evt)
Definition: EffectUI.cpp:494
void OnMenu(wxCommandEvent &evt)
Definition: EffectUI.cpp:650
void OnDebug(wxCommandEvent &evt)
Definition: EffectUI.cpp:634
void OnCharHook(wxKeyEvent &evt)
Definition: EffectUI.cpp:954
bool mEnabled
Definition: EffectUI.h:139
EffectPlugin::EffectSettingsAccessPtr mpAccess2
Definition: EffectUI.h:123
void OnImport(wxCommandEvent &evt)
Definition: EffectUI.cpp:907
std::unique_ptr< EffectEditor > mpEditor
Definition: EffectUI.h:157
std::shared_ptr< EffectInstance > InitializeInstance()
Definition: EffectUI.cpp:1038
void OnApply(wxCommandEvent &evt)
Definition: EffectUI.cpp:545
const bool mSupportsRealtime
Definition: EffectUI.h:130
bool Initialize()
Definition: EffectUI.cpp:395
void OnPlay(wxCommandEvent &evt)
Definition: EffectUI.cpp:758
const std::shared_ptr< EffectInstance > mpInstance
Definition: EffectUI.h:154
void OnCancel(wxCommandEvent &evt)
Definition: EffectUI.cpp:628
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:977
bool IsOpenedFromEffectPanel() const
Definition: EffectUI.cpp:972
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:287
void OnPaint(wxPaintEvent &evt)
Definition: EffectUI.cpp:522
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:640
Holds a msgid for the translation catalog; may also bind format arguments.
AUDACITY_DLL_API DialogFactoryResults DialogFactory(wxWindow &parent, EffectBase &host, EffectUIServices &client, EffectSettingsAccess &access)
Definition: EffectUI.cpp:1112