Audacity 3.2.0
Repeat.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Repeat.cpp
6
7 Dominic Mazzoni
8 Vaughan Johnson
9
10*******************************************************************//****************************************************************//*******************************************************************/
21#include "Repeat.h"
22#include "EffectEditor.h"
23
24#include <wx/stattext.h>
25
26#include "ShuttleGui.h"
27#include "../widgets/NumericTextCtrl.h"
28#include "../widgets/valnum.h"
29
30#include "LoadEffects.h"
31
32namespace
33{
35}
36
37BEGIN_EVENT_TABLE(EffectRepeat, wxEvtHandler)
38EVT_TEXT(wxID_ANY, EffectRepeat::OnRepeatTextChange)
40
41std::unique_ptr<EffectEditor> EffectRepeat::PopulateOrExchange(
43 const EffectOutputs *)
44{
45 mUIParent = S.GetParent();
46 S.StartHorizontalLay(wxCENTER, false);
47 {
48 mRepeatCount = S.Validator<IntegerValidator<int>>(
49 &repeatCount, NumValidatorStyle::DEFAULT,
50 Count.min, 2147483647 / mProjectRate )
51 .AddTextBox(XXO("&Number of repeats to add:"), L"", 12);
52 }
53 S.EndHorizontalLay();
54
55 S.StartMultiColumn(1, wxCENTER);
56 {
57 mCurrentTime = S.AddVariableText(
58 XO("Current selection length: dd:hh:mm:ss"));
59 mTotalTime = S.AddVariableText(XO("New selection length: dd:hh:mm:ss"));
60 }
61 S.EndMultiColumn();
62 return nullptr;
63}
64
66{
67 mRepeatCount->ChangeValue(wxString::Format(wxT("%d"), repeatCount));
68
70
71 return true;
72}
73
75{
76 if (!mUIParent->Validate())
77 {
78 return false;
79 }
80
81 long l;
82
83 mRepeatCount->GetValue().ToLong(&l);
84
85 repeatCount = (int) l;
86
87 return true;
88}
89
91{
92 long l;
93 wxString str;
94 mRepeatCount->GetValue().ToLong(&l);
95
99 mT1 - mT0);
100
101 str = wxString::Format( _("Current selection length: %s"), nc.GetString() );
102
103 mCurrentTime->SetLabel(str);
104 mCurrentTime->SetName(str); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
105
106 if (l > 0) {
108 repeatCount = l;
109
110 nc.SetValue((mT1 - mT0) * (repeatCount + 1));
111 str = wxString::Format( _("New selection length: %s"), nc.GetString() );
112 }
113 else {
114 str = _("Warning: No repeats.");
116 }
117 mTotalTime->SetLabel(str);
118 mTotalTime->SetName(str); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
119}
120
121void EffectRepeat::OnRepeatTextChange(wxCommandEvent & WXUNUSED(evt))
122{
124}
wxT("CloseDown"))
END_EVENT_TABLE()
#define str(a)
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
const NumericConverterType & NumericConverterType_TIME()
#define S(N)
Definition: ToChars.cpp:64
double mT1
Definition: EffectBase.h:123
double mProjectRate
Definition: EffectBase.h:119
double mT0
Definition: EffectBase.h:122
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
virtual NumericFormatID GetSelectionFormat()
Definition: Effect.cpp:187
Performs effect computation.
Hold values to send to effect output meters.
An Effect that repeats audio several times over.
Definition: Repeat.h:25
wxStaticText * mTotalTime
Definition: Repeat.h:41
wxWeakRef< wxWindow > mUIParent
Definition: Repeat.h:37
wxTextCtrl * mRepeatCount
Definition: Repeat.h:39
bool TransferDataToWindow(const EffectSettings &settings) override
Definition: Repeat.cpp:65
void DisplayNewTime()
Definition: Repeat.cpp:90
void OnRepeatTextChange(wxCommandEvent &evt)
Definition: Repeat.cpp:121
bool TransferDataFromWindow(EffectSettings &settings) override
Definition: Repeat.cpp:74
wxStaticText * mCurrentTime
Definition: Repeat.h:40
static FormatterContext SampleRateContext(double sampleRate)
NumericConverter provides the advanced formatting control used in the selection bar of Audacity.
void SetValue(double newValue)
int repeatCount
Definition: RepeatBase.h:34
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
size_t Count(const Ptr< Type, BaseDeleter > &p)
Find out how many elements were allocated with a Ptr.
Definition: PackedArray.h:143
BuiltinEffectsModule::Registration< EffectRepeat > reg
Definition: Repeat.cpp:34
STL namespace.
Externalized state of a plug-in.