Audacity 3.2.0
ClickRemoval.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ClickRemoval.cpp
6
7 Craig DeForest
8
9***********************************************************************/
10#include "ClickRemoval.h"
11#include "EffectEditor.h"
12#include "LoadEffects.h"
13
14#include <wx/slider.h>
15#include <wx/valgen.h>
16
17#include "ShuttleGui.h"
18#include "AudacityMessageBox.h"
19#include "../widgets/valnum.h"
20
21enum
22{
23 ID_Thresh = 10000,
25};
26
28
29BEGIN_EVENT_TABLE(EffectClickRemoval, wxEvtHandler)
35
36std::unique_ptr<EffectEditor> EffectClickRemoval::PopulateOrExchange(
38 const EffectOutputs *)
39{
40 mUIParent = S.GetParent();
41 S.AddSpace(0, 5);
42 S.SetBorder(10);
43
44 S.StartMultiColumn(3, wxEXPAND);
45 S.SetStretchyCol(2);
46 {
47 // Threshold
48 mThreshT = S.Id(ID_Thresh)
49 .Validator<IntegerValidator<int>>(
50 &mThresholdLevel, NumValidatorStyle::DEFAULT,
51 Threshold.min, Threshold.max )
52 .AddTextBox(XXO("&Threshold (lower is more sensitive):"),
53 wxT(""),
54 10);
55
56 mThreshS = S.Id(ID_Thresh)
57 .Name(XO("Threshold"))
58 .Style(wxSL_HORIZONTAL)
59 .Validator<wxGenericValidator>(&mThresholdLevel)
60 .MinSize( { 150, -1 } )
61 .AddSlider( {}, mThresholdLevel, Threshold.max, Threshold.min);
62
63 // Click width
64 mWidthT = S.Id(ID_Width)
65 .Validator<IntegerValidator<int>>(
66 &mClickWidth, NumValidatorStyle::DEFAULT, Width.min, Width.max)
67 .AddTextBox(XXO("Max &Spike Width (higher is more sensitive):"),
68 wxT(""),
69 10);
70
71 mWidthS = S.Id(ID_Width)
72 .Name(XO("Max Spike Width"))
73 .Style(wxSL_HORIZONTAL)
74 .Validator<wxGenericValidator>(&mClickWidth)
75 .MinSize( { 150, -1 } )
76 .AddSlider( {}, mClickWidth, Width.max, Width.min);
77 }
78 S.EndMultiColumn();
79
80 return nullptr;
81}
82
84{
85 if (!mUIParent->TransferDataToWindow())
86 {
87 return false;
88 }
89
90 return true;
91}
92
94{
95 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
96 {
97 return false;
98 }
99
100 return true;
101}
102
103void EffectClickRemoval::OnWidthText(wxCommandEvent & WXUNUSED(evt))
104{
105 mWidthT->GetValidator()->TransferFromWindow();
106 mWidthS->GetValidator()->TransferToWindow();
107}
108
109void EffectClickRemoval::OnThreshText(wxCommandEvent & WXUNUSED(evt))
110{
111 mThreshT->GetValidator()->TransferFromWindow();
112 mThreshS->GetValidator()->TransferToWindow();
113}
114
115void EffectClickRemoval::OnWidthSlider(wxCommandEvent & WXUNUSED(evt))
116{
117 mWidthS->GetValidator()->TransferFromWindow();
118 mWidthT->GetValidator()->TransferToWindow();
119}
120
121void EffectClickRemoval::OnThreshSlider(wxCommandEvent & WXUNUSED(evt))
122{
123 mThreshS->GetValidator()->TransferFromWindow();
124 mThreshT->GetValidator()->TransferToWindow();
125}
wxT("CloseDown"))
END_EVENT_TABLE()
@ ID_Width
@ ID_Thresh
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
wxTextCtrl * mThreshT
Definition: ClickRemoval.h:47
void OnWidthSlider(wxCommandEvent &evt)
wxWeakRef< wxWindow > mUIParent
Definition: ClickRemoval.h:42
void OnThreshSlider(wxCommandEvent &evt)
wxTextCtrl * mWidthT
Definition: ClickRemoval.h:46
bool TransferDataToWindow(const EffectSettings &settings) override
wxSlider * mThreshS
Definition: ClickRemoval.h:45
void OnWidthText(wxCommandEvent &evt)
wxSlider * mWidthS
Definition: ClickRemoval.h:44
void OnThreshText(wxCommandEvent &evt)
bool TransferDataFromWindow(EffectSettings &settings) override
Performs effect computation.
Hold values to send to effect output meters.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
BuiltinEffectsModule::Registration< EffectClickRemoval > reg
STL namespace.
Externalized state of a plug-in.