Audacity 3.2.0
EffectPlugin.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file EffectPlugin.cpp
6
7 Paul Licameli split from EffectInterface.cpp
8
9**********************************************************************/
10#include "EffectPlugin.h"
11#include <wx/window.h>
12
14
15const wxString EffectPlugin::kUserPresetIdent = wxT("User Preset:");
16const wxString EffectPlugin::kFactoryPresetIdent = wxT("Factory Preset:");
17const wxString EffectPlugin::kCurrentSettingsIdent = wxT("<Current Settings>");
18const wxString EffectPlugin::kFactoryDefaultsIdent = wxT("<Factory Defaults>");
19
21
23{
24 return true;
25}
26
29 : mEffect{effect}
30 , mAccess{access}
31{}
32
34
36{
37 return true;
38}
39
41{
42 return false;
43}
44
46{
47}
48
50{
51 if (!mUIClosed)
52 {
54 mUIClosed = true;
55 }
56}
57
58bool EffectUIValidator::EnableApply(wxWindow *parent, bool enable)
59{
60 // May be called during initialization, so try to find the dialog
61 if (auto dlg = wxGetTopLevelParent(parent)) {
62 wxWindow *apply = dlg->FindWindow(wxID_APPLY);
63
64 // Don't allow focus to get trapped
65 if (!enable)
66 {
67 wxWindow *focus = dlg->FindFocus();
68 if (focus == apply)
69 {
70 dlg->FindWindow(wxID_CLOSE)->SetFocus();
71 }
72 }
73
74 if (apply)
75 apply->Enable(enable);
76 }
77
78 EnablePreview(parent, enable);
79
80 return enable;
81}
82
83bool EffectUIValidator::EnablePreview(wxWindow *parent, bool enable)
84{
85 // May be called during initialization, so try to find the dialog
86 if (auto dlg = wxGetTopLevelParent(parent)) {
87 wxWindow *play = dlg->FindWindow(kPlayID);
88 if (play)
89 {
90 // Don't allow focus to get trapped
91 if (!enable)
92 {
93 wxWindow *focus = dlg->FindFocus();
94 if (focus == play)
95 {
96 dlg->FindWindow(wxID_CLOSE)->SetFocus();
97 }
98 }
99
100 play->Enable(enable);
101 }
102 }
103
104 return enable;
105}
106
wxT("CloseDown"))
~EffectInstanceEx() override
virtual bool Init()
Call once to set up state for whole list of tracks to be processed.
static const wxString kUserPresetIdent
Definition: EffectPlugin.h:59
virtual ~EffectPlugin()
static const wxString kFactoryPresetIdent
Definition: EffectPlugin.h:60
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:61
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:62
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
Definition: EffectPlugin.h:170
virtual bool CloseUI()=0
virtual ~EffectUIClientInterface()
static constexpr int kPlayID
Definition: EffectPlugin.h:281
virtual bool IsGraphicalUI()
static bool EnablePreview(wxWindow *parent, bool enable=true)
virtual void OnClose()
EffectUIValidator(EffectUIClientInterface &effect, EffectSettingsAccess &access)
virtual bool UpdateUI()
Update appearance of the panel for changes in settings.
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
virtual ~EffectUIValidator()
virtual void Disconnect()
On the first call only, may disconnect from further event handling.
EffectUIClientInterface & mEffect
Definition: EffectPlugin.h:296