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