Audacity  3.0.3
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. See License.txt.
11 
12 **********************************************************************/
13 
14 #ifndef __AUDACITY_EFFECTUI_H__
15 #define __AUDACITY_EFFECTUI_H__
16 
17 #include <wx/bitmap.h> // member variables
18 
19 #include "Identifier.h"
20 #include "EffectHostInterface.h"
21 #include "PluginInterface.h"
22 
23 #if defined(EXPERIMENTAL_EFFECTS_RACK)
24 
25 #include <vector>
26 
27 #include <wx/defs.h>
28 #include <wx/frame.h> // to inherit
29 #include <wx/timer.h> // member variable
30 
31 class wxFlexGridSizer;
32 class wxPanel;
33 class wxStaticText;
34 
35 class AudacityProject;
36 
37 class Effect;
38 using EffectArray = std::vector<Effect*>;
39 
40 class EffectRack final : public wxFrame
41 {
42 public:
43  EffectRack( AudacityProject &project );
44  virtual ~EffectRack();
45 
46  void Add(Effect *effect, bool active = false, bool favorite = false);
47 
48  static EffectRack &Get( AudacityProject &project );
49 
50 private:
51 
52  wxBitmap CreateBitmap(const char *const xpm[], bool up, bool pusher);
53  int GetEffectIndex(wxWindow *win);
54  void MoveRowUp(int row);
55  void UpdateActive();
56 
57  void OnClose(wxCloseEvent & evt);
58  void OnTimer(wxTimerEvent & evt);
59  void OnApply(wxCommandEvent & evt);
60  void OnBypass(wxCommandEvent & evt);
61 
62  void OnPower(wxCommandEvent & evt);
63  void OnEditor(wxCommandEvent & evt);
64  void OnUp(wxCommandEvent & evt);
65  void OnDown(wxCommandEvent & evt);
66  void OnFav(wxCommandEvent & evt);
67  void OnRemove(wxCommandEvent & evt);
68 
69 private:
70  AudacityProject &mProject;
71 
72  wxStaticText *mLatency;
73  int mLastLatency;
74 
75  wxBitmap mPowerPushed;
76  wxBitmap mPowerRaised;
77  wxBitmap mSettingsPushed;
78  wxBitmap mSettingsRaised;
79  wxBitmap mUpPushed;
80  wxBitmap mUpRaised;
81  wxBitmap mUpDisabled;
82  wxBitmap mDownPushed;
83  wxBitmap mDownRaised;
84  wxBitmap mDownDisabled;
85  wxBitmap mFavPushed;
86  wxBitmap mFavRaised;
87  wxBitmap mRemovePushed;
88  wxBitmap mRemoveRaised;
89 
90  std::vector<int> mPowerState;
91  std::vector<int> mFavState;
92 
93  int mNumEffects;
94 
95  wxTimer mTimer;
96 
97  wxPanel *mPanel;
98  wxFlexGridSizer *mMainSizer;
99 
100  EffectArray mEffects;
101  EffectArray mActive;
102  bool mBypassing;
103 
104  DECLARE_EVENT_TABLE()
105 };
106 
107 #endif
108 
109 #include "EffectInterface.h"
110 #include "widgets/wxPanelWrapper.h" // to inherit
111 
112 #include "SelectedRegion.h"
113 
114 class AudacityCommand;
115 class AudacityProject;
116 class Effect;
117 
118 class wxCheckBox;
119 
120 //
121 class EffectUIHost final : public wxDialogWrapper
122 {
123 public:
124  // constructors and destructors
125  EffectUIHost(wxWindow *parent,
126  AudacityProject &project,
127  Effect &effect,
128  EffectUIClientInterface &client);
129  virtual ~EffectUIHost();
130 
131  bool TransferDataToWindow() override;
132  bool TransferDataFromWindow() override;
133 
134  int ShowModal() override;
135 
136  bool Initialize();
137 
138 private:
139  wxPanel *BuildButtonBar( wxWindow *parent );
140 
141  void OnInitDialog(wxInitDialogEvent & evt);
142  void OnErase(wxEraseEvent & evt);
143  void OnPaint(wxPaintEvent & evt);
144  void OnClose(wxCloseEvent & evt);
145  void OnApply(wxCommandEvent & evt);
146  void DoCancel();
147  void OnCancel(wxCommandEvent & evt);
148  void OnHelp(wxCommandEvent & evt);
149  void OnDebug(wxCommandEvent & evt);
150  void OnMenu(wxCommandEvent & evt);
151  void OnEnable(wxCommandEvent & evt);
152  void OnPlay(wxCommandEvent & evt);
153  void OnRewind(wxCommandEvent & evt);
154  void OnFFwd(wxCommandEvent & evt);
155  void OnPlayback(wxCommandEvent & evt);
156  void OnCapture(wxCommandEvent & evt);
157  void OnUserPreset(wxCommandEvent & evt);
158  void OnFactoryPreset(wxCommandEvent & evt);
159  void OnDeletePreset(wxCommandEvent & evt);
160  void OnSaveAs(wxCommandEvent & evt);
161  void OnImport(wxCommandEvent & evt);
162  void OnExport(wxCommandEvent & evt);
163  void OnOptions(wxCommandEvent & evt);
164  void OnDefaults(wxCommandEvent & evt);
165 
166  void UpdateControls();
167  wxBitmap CreateBitmap(const char * const xpm[], bool up, bool pusher);
168  void LoadUserPresets();
169 
170  void InitializeRealtime();
171  void CleanupRealtime();
172  void Resume();
173 
174 private:
176  wxWindow *mParent;
179 
183  bool mIsGUI;
184  bool mIsBatch;
185 
186  wxButton *mApplyBtn;
187  wxButton *mCloseBtn;
188  wxButton *mMenuBtn;
189  wxButton *mPlayBtn;
190  wxButton *mRewindBtn;
191  wxButton *mFFwdBtn;
192  wxCheckBox *mEnableCb;
193 
194  wxButton *mEnableToggleBtn;
195  wxButton *mPlayToggleBtn;
196 
197  wxBitmap mPlayBM;
198  wxBitmap mPlayDisabledBM;
199  wxBitmap mStopBM;
200  wxBitmap mStopDisabledBM;
201 
202  bool mEnabled;
203 
205  bool mPlaying;
207 
209  double mPlayPos;
210 
211  bool mDismissed{};
212  bool mNeedsResume{};
213 
214  DECLARE_EVENT_TABLE()
215 };
216 
217 class CommandContext;
218 
219 namespace EffectUI {
220 
221  AUDACITY_DLL_API
222  wxDialog *DialogFactory( wxWindow &parent, EffectHostInterface &host,
223  EffectUIClientInterface &client);
224 
226  // Returns true on success. Will only operate on tracks that
227  // have the "selected" flag set to true, which is consistent with
228  // Audacity's standard UI.
229  AUDACITY_DLL_API bool DoEffect(
230  const PluginID & ID, const CommandContext &context, unsigned flags );
231 
232 }
233 
234 class ShuttleGui;
235 
236 // Obsolescent dialog still used only in Noise Reduction/Removal
237 class AUDACITY_DLL_API EffectDialog /* not final */ : public wxDialogWrapper
238 {
239 public:
240  // constructors and destructors
241  EffectDialog(wxWindow * parent,
242  const TranslatableString & title,
243  int type = 0,
244  int flags = wxDEFAULT_DIALOG_STYLE,
245  int additionalButtons = 0);
246 
247  void Init();
248 
249  bool TransferDataToWindow() override;
250  bool TransferDataFromWindow() override;
251  bool Validate() override;
252 
253  // NEW virtuals:
254  virtual void PopulateOrExchange(ShuttleGui & S);
255  virtual void OnPreview(wxCommandEvent & evt);
256  virtual void OnOk(wxCommandEvent & evt);
257 
258 private:
259  int mType;
261 
262  DECLARE_EVENT_TABLE()
263  wxDECLARE_NO_COPY_CLASS(EffectDialog);
264 };
265 
266 #endif // __AUDACITY_EFFECTUI_H__
EffectUIClientInterface
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Definition: EffectInterface.h:224
Init
Definition: ModuleManager.h:152
EffectUIHost::ShowModal
int ShowModal() override
Definition: EffectUI.cpp:784
EffectDialog::mAdditionalButtons
int mAdditionalButtons
Definition: EffectUI.h:260
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectUIHost::mStopBM
wxBitmap mStopBM
Definition: EffectUI.h:199
EffectUIHost::mIsBatch
bool mIsBatch
Definition: EffectUI.h:184
EffectUIHost::mDisableTransport
bool mDisableTransport
Definition: EffectUI.h:204
EffectUIHost::mClient
EffectUIClientInterface & mClient
Definition: EffectUI.h:178
EffectUIHost::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: EffectUI.cpp:775
S
#define S(N)
Definition: ToChars.cpp:64
EffectHostInterface
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
Definition: EffectHostInterface.h:32
EffectUIHost::DoCancel
void DoCancel()
Definition: EffectUI.cpp:1152
EffectInterface.h
Effect
An Effect object is at once host and client: it is self-hosting.
Definition: Effect.h:76
RegistryPaths
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
EffectUIHost::OnClose
void OnClose(wxCloseEvent &evt)
Definition: EffectUI.cpp:1072
EffectUIHost::OnApply
void OnApply(wxCommandEvent &evt)
Definition: EffectUI.cpp:1087
EffectUIHost::OnSaveAs
void OnSaveAs(wxCommandEvent &evt)
Definition: EffectUI.cpp:1496
EffectUIHost::Initialize
bool Initialize()
Definition: EffectUI.cpp:951
EffectUI
Definition: EffectUI.h:219
SelectedRegion.h
EffectUIHost::OnDebug
void OnDebug(wxCommandEvent &evt)
Definition: EffectUI.cpp:1183
EffectUIHost::mMenuBtn
wxButton * mMenuBtn
Definition: EffectUI.h:188
wxPanelWrapper.h
EffectUIHost::OnEnable
void OnEnable(wxCommandEvent &evt)
Definition: EffectUI.cpp:1293
EffectUIHost::OnCancel
void OnCancel(wxCommandEvent &evt)
Definition: EffectUI.cpp:1164
EffectUIHost::OnFFwd
void OnFFwd(wxCommandEvent &evt)
Definition: EffectUI.cpp:1383
EffectUIHost::EffectUIHost
EffectUIHost(wxWindow *parent, AudacityProject &project, Effect &effect, EffectUIClientInterface &client)
Definition: EffectUI.cpp:725
EffectUIHost::mInitialized
bool mInitialized
Definition: EffectUI.h:181
EffectUIHost::OnOptions
void OnOptions(wxCommandEvent &evt)
Definition: EffectUI.cpp:1592
EffectUIHost::Resume
void Resume()
Definition: EffectUI.cpp:1278
EffectUIHost::OnPlayback
void OnPlayback(wxCommandEvent &evt)
Definition: EffectUI.cpp:1406
EffectUIHost::mCapturing
bool mCapturing
Definition: EffectUI.h:206
EffectUIHost::mPlayBtn
wxButton * mPlayBtn
Definition: EffectUI.h:189
EffectUIHost::OnImport
void OnImport(wxCommandEvent &evt)
Definition: EffectUI.cpp:1574
EffectUIHost::mEnableCb
wxCheckBox * mEnableCb
Definition: EffectUI.h:192
EffectUIHost::mFFwdBtn
wxButton * mFFwdBtn
Definition: EffectUI.h:191
EffectUIHost::mEnableToggleBtn
wxButton * mEnableToggleBtn
Definition: EffectUI.h:194
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
EffectUIHost::mStopDisabledBM
wxBitmap mStopDisabledBM
Definition: EffectUI.h:200
EffectUIHost::mDismissed
bool mDismissed
Definition: EffectUI.h:211
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
EffectUIHost::mParent
wxWindow * mParent
Definition: EffectUI.h:176
EffectUIHost::InitializeRealtime
void InitializeRealtime()
Definition: EffectUI.cpp:1730
EffectUIHost::mProject
AudacityProject * mProject
Definition: EffectUI.h:175
EffectUIHost::mEffect
Effect & mEffect
Definition: EffectUI.h:177
EffectUIHost::mRegion
SelectedRegion mRegion
Definition: EffectUI.h:208
EffectUIHost::OnPlay
void OnPlay(wxCommandEvent &evt)
Definition: EffectUI.cpp:1310
PluginID
wxString PluginID
Definition: EffectManager.h:31
AudacityCommand
Base class for command in Audacity.
Definition: AudacityCommand.h:40
Identifier.h
EffectUIHost::mPlaying
bool mPlaying
Definition: EffectUI.h:205
EffectDialog
Definition: EffectUI.h:238
EffectHostInterface.h
EffectUIHost::mEnabled
bool mEnabled
Definition: EffectUI.h:202
EffectUIHost::OnDeletePreset
void OnDeletePreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:1476
EffectUIHost::OnRewind
void OnRewind(wxCommandEvent &evt)
Definition: EffectUI.cpp:1361
anonymous_namespace{LogWindow.cpp}::OnClose
void OnClose(wxCommandEvent &e)
EffectUIHost::OnCapture
void OnCapture(wxCommandEvent &evt)
Definition: EffectUI.cpp:1436
EffectUIHost::OnInitDialog
void OnInitDialog(wxInitDialogEvent &evt)
Definition: EffectUI.cpp:1037
EffectUIHost::OnPaint
void OnPaint(wxPaintEvent &evt)
Definition: EffectUI.cpp:1065
EffectUIHost::mApplyBtn
wxButton * mApplyBtn
Definition: EffectUI.h:186
EffectUIHost::OnUserPreset
void OnUserPreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:1460
EffectUIHost::OnHelp
void OnHelp(wxCommandEvent &evt)
Definition: EffectUI.cpp:1170
EffectUIHost::mIsGUI
bool mIsGUI
Definition: EffectUI.h:183
EffectUIHost::mUserPresets
RegistryPaths mUserPresets
Definition: EffectUI.h:180
wxDialogWrapper
Definition: wxPanelWrapper.h:81
EffectUIHost::mPlayBM
wxBitmap mPlayBM
Definition: EffectUI.h:197
EffectUIHost::BuildButtonBar
wxPanel * BuildButtonBar(wxWindow *parent)
Definition: EffectUI.cpp:813
EffectUIHost::OnMenu
void OnMenu(wxCommandEvent &evt)
Definition: EffectUI.cpp:1188
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
EffectUIHost::OnDefaults
void OnDefaults(wxCommandEvent &evt)
Definition: EffectUI.cpp:1599
EffectUIHost::OnFactoryPreset
void OnFactoryPreset(wxCommandEvent &evt)
Definition: EffectUI.cpp:1469
EffectUIHost::mPlayDisabledBM
wxBitmap mPlayDisabledBM
Definition: EffectUI.h:198
EffectUIHost::CreateBitmap
wxBitmap CreateBitmap(const char *const xpm[], bool up, bool pusher)
Definition: EffectUI.cpp:1606
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
EffectUIHost::mRewindBtn
wxButton * mRewindBtn
Definition: EffectUI.h:190
EffectUIHost::OnExport
void OnExport(wxCommandEvent &evt)
Definition: EffectUI.cpp:1583
EffectUIHost::~EffectUIHost
virtual ~EffectUIHost()
Definition: EffectUI.cpp:758
EffectUIHost
Definition: EffectUI.h:122
EffectDialog::mType
int mType
Definition: EffectUI.h:259
EffectUI::DoEffect
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
Definition: EffectUI.cpp:1798
PluginInterface.h
EffectUI::DialogFactory
AUDACITY_DLL_API wxDialog * DialogFactory(wxWindow &parent, EffectHostInterface &host, EffectUIClientInterface &client)
Definition: EffectUI.cpp:1758
EffectUIHost::mPlayPos
double mPlayPos
Definition: EffectUI.h:209
EffectUIHost::mPlayToggleBtn
wxButton * mPlayToggleBtn
Definition: EffectUI.h:195
EffectUIHost::mCloseBtn
wxButton * mCloseBtn
Definition: EffectUI.h:187
ActiveProjects::Add
void Add(const FilePath &path)
EffectUIHost::UpdateControls
void UpdateControls()
Definition: EffectUI.cpp:1639
EffectUIHost::mNeedsResume
bool mNeedsResume
Definition: EffectUI.h:212
EffectUIHost::CleanupRealtime
void CleanupRealtime()
Definition: EffectUI.cpp:1748
EffectUIHost::OnErase
void OnErase(wxEraseEvent &evt)
Definition: EffectUI.cpp:1060
EffectUIHost::LoadUserPresets
void LoadUserPresets()
Definition: EffectUI.cpp:1718
EffectUIHost::TransferDataToWindow
bool TransferDataToWindow() override
Definition: EffectUI.cpp:770
EffectUIHost::mSupportsRealtime
bool mSupportsRealtime
Definition: EffectUI.h:182
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38