Audacity 3.2.0
EffectEditor.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EffectEditor.cpp
6
7 Dominic Mazzoni
8 Vaughan Johnson
9 Martyn Shaw
10
11 Paul Licameli split from EffectPlugin.cpp
12
13**********************************************************************/
14#include "EffectEditor.h"
15#include "EffectPlugin.h"
16#include "EffectUIServices.h"
17#include <wx/window.h>
18
20 const EffectUIServices &services, EffectSettingsAccess &access)
21 : mUIServices{ services }
22 , mAccess{ access }
23{}
24
26
28{
29 return true;
30}
31
33{
34 return false;
35}
36
38{
39}
40
42{
43 if (!mUIClosed)
44 {
46 mUIClosed = true;
47 }
48}
49
50bool EffectEditor::EnableApply(wxWindow *parent, bool enable)
51{
52 // May be called during initialization, so try to find the dialog
53 if (auto dlg = wxGetTopLevelParent(parent)) {
54 wxWindow *apply = dlg->FindWindow(wxID_APPLY);
55
56 // Don't allow focus to get trapped
57 if (!enable)
58 {
59 wxWindow *focus = dlg->FindFocus();
60 if (focus == apply)
61 {
62 dlg->FindWindow(wxID_CLOSE)->SetFocus();
63 }
64 }
65
66 if (apply)
67 apply->Enable(enable);
68 }
69
70 EnablePreview(parent, enable);
71
72 return enable;
73}
74
75bool EffectEditor::EnablePreview(wxWindow *parent, bool enable)
76{
77 // May be called during initialization, so try to find the dialog
78 if (auto dlg = wxGetTopLevelParent(parent)) {
79 wxWindow *play = dlg->FindWindow(kPlayID);
80 if (play)
81 {
82 // Don't allow focus to get trapped
83 if (!enable)
84 {
85 wxWindow *focus = dlg->FindFocus();
86 if (focus == play)
87 {
88 dlg->FindWindow(wxID_CLOSE)->SetFocus();
89 }
90 }
91
92 play->Enable(enable);
93 }
94 }
95
96 return enable;
97}
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
EffectEditor(const EffectUIServices &services, EffectSettingsAccess &access)
static constexpr int kPlayID
Definition: EffectEditor.h:76
virtual bool IsGraphicalUI()
const EffectUIServices & mUIServices
Definition: EffectEditor.h:91
virtual bool UpdateUI()
Update appearance of the panel for changes in settings.
virtual ~EffectEditor()
virtual void OnClose()
virtual void Disconnect()
On the first call only, may disconnect from further event handling.
static bool EnablePreview(wxWindow *parent, bool enable=true)
virtual bool CloseUI() const =0