Define and use ShuttleGui::Validator

This commit is contained in:
Paul Licameli 2017-10-30 12:23:41 -04:00
parent 8ea137e041
commit 1d32824e02
35 changed files with 567 additions and 460 deletions

View File

@ -160,7 +160,6 @@ void BenchmarkDialog::OnClose(wxCommandEvent & WXUNUSED(event))
void BenchmarkDialog::MakeBenchmarkDialog() void BenchmarkDialog::MakeBenchmarkDialog()
{ {
ShuttleGui S(this, eIsCreating); ShuttleGui S(this, eIsCreating);
wxControl *item;
// Strings don't need to be translated because this class doesn't // Strings don't need to be translated because this class doesn't
// ever get used in a stable release. // ever get used in a stable release.
@ -171,47 +170,47 @@ void BenchmarkDialog::MakeBenchmarkDialog()
S.StartMultiColumn(4); S.StartMultiColumn(4);
{ {
// //
item = S.Id(BlockSizeID).AddTextBox(_("Disk Block Size (KB):"), S.Id(BlockSizeID)
.Validator<wxTextValidator>(wxFILTER_NUMERIC, &mBlockSizeStr)
.AddTextBox(_("Disk Block Size (KB):"),
wxT(""), wxT(""),
12); 12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mBlockSizeStr));
// //
item = S.Id(NumEditsID).AddTextBox(_("Number of Edits:"), S.Id(NumEditsID)
.Validator<wxTextValidator>(wxFILTER_NUMERIC, &mNumEditsStr)
.AddTextBox(_("Number of Edits:"),
wxT(""), wxT(""),
12); 12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mNumEditsStr));
// //
item = S.Id(DataSizeID).AddTextBox(_("Test Data Size (MB):"), S.Id(DataSizeID)
.Validator<wxTextValidator>(wxFILTER_NUMERIC, &mDataSizeStr)
.AddTextBox(_("Test Data Size (MB):"),
wxT(""), wxT(""),
12); 12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mDataSizeStr));
/// ///
S.Id(RandSeedID)
.Validator<wxTextValidator>(wxFILTER_NUMERIC, &mRandSeedStr)
/* i18n-hint: A "seed" is a number that initializes a /* i18n-hint: A "seed" is a number that initializes a
pseudorandom number generating algorithm */ pseudorandom number generating algorithm */
item = S.Id(RandSeedID).AddTextBox(_("Random Seed:"), .AddTextBox(_("Random Seed:"),
wxT(""), wxT(""),
12); 12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mRandSeedStr));
} }
S.EndMultiColumn(); S.EndMultiColumn();
// //
item = S.AddCheckBox(_("Show detailed info about each block file"), S.Validator<wxGenericValidator>(&mBlockDetail)
.AddCheckBox(_("Show detailed info about each block file"),
false); false);
item->SetValidator(wxGenericValidator(&mBlockDetail));
// //
item = S.AddCheckBox(_("Show detailed info about each editing operation"), S.Validator<wxGenericValidator>(&mEditDetail)
.AddCheckBox(_("Show detailed info about each editing operation"),
false); false);
item->SetValidator(wxGenericValidator(&mEditDetail));
// //
mText = S.Id(StaticTextID).AddTextWindow(wxT("")); mText = S.Id(StaticTextID).AddTextWindow(wxT(""));

View File

@ -2072,6 +2072,9 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
if (!prompt) { if (!prompt) {
// Apply certain optional window attributes here // Apply certain optional window attributes here
if ( mItem.mValidatorSetter )
mItem.mValidatorSetter( mpWind );
// Reset to defaults // Reset to defaults
mItem = {}; mItem = {};
} }

View File

@ -123,6 +123,24 @@ namespace DialogDefinition {
struct Item { struct Item {
Item() = default; Item() = default;
// Factory is a class that returns a value of some subclass of wxValidator
// We must wrap it in another lambda to allow the return type of f to
// vary, and avoid the "slicing" problem.
// (That is, std::function<wxValidator()> would not work.)
template<typename Factory>
Item&& Validator( const Factory &f ) &&
{
mValidatorSetter = [f](wxWindow *p){ p->SetValidator(f()); };
return std::move(*this);
}
// This allows further abbreviation of the previous:
template<typename V, typename... Args>
Item&& Validator( Args&&... args ) &&
{ return std::move(*this).Validator( [args...]{ return V( args... ); } ); }
std::function< void(wxWindow*) > mValidatorSetter;
}; };
} }
@ -478,6 +496,24 @@ public:
public: public:
ShuttleGui & Optional( bool & bVar ); ShuttleGui & Optional( bool & bVar );
ShuttleGui & Id(int id ); ShuttleGui & Id(int id );
template<typename Factory>
ShuttleGui& Validator( const Factory &f )
{
if ( GetMode() == eIsCreating )
std::move( mItem ).Validator( f );
return *this;
}
// This allows further abbreviation of the previous:
template<typename V, typename...Args>
ShuttleGui& Validator( Args&& ...args )
{
if ( GetMode() == eIsCreating )
std::move( mItem ).Validator<V>( std::forward<Args>(args)... );
return *this;
}
// Prop() sets the proportion value, defined as in wxSizer::Add(). // Prop() sets the proportion value, defined as in wxSizer::Add().
ShuttleGui & Prop( int iProp ){ ShuttleGuiBase::Prop(iProp); return *this;}; // Has to be here too, to return a ShuttleGui and not a ShuttleGuiBase. ShuttleGui & Prop( int iProp ){ ShuttleGuiBase::Prop(iProp); return *this;}; // Has to be here too, to return a ShuttleGui and not a ShuttleGuiBase.
GuiWaveTrack * AddGuiWaveTrack( const wxString & Name); GuiWaveTrack * AddGuiWaveTrack( const wxString & Name);

View File

@ -233,10 +233,11 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S)
// Amplitude // Amplitude
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
FloatingPointValidator<double> vldAmp(precision, &mAmp, NumValidatorStyle::ONE_TRAILING_ZERO); mAmpT = S.Id(ID_Amp)
vldAmp.SetRange(MIN_Amp, MAX_Amp); .Validator<FloatingPointValidator<double>>(
mAmpT = S.Id(ID_Amp).AddTextBox(_("Amplification (dB):"), wxT(""), 12); precision, &mAmp, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Amp, MAX_Amp
mAmpT->SetValidator(vldAmp); )
.AddTextBox(_("Amplification (dB):"), wxT(""), 12);
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -252,18 +253,17 @@ void EffectAmplify::PopulateOrExchange(ShuttleGui & S)
// Peak // Peak
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
// One extra decimal place so that rounding is visible to user (see: bug 958) mNewPeakT = S.Id(ID_Peak)
FloatingPointValidator<double> vldNewPeak(precision + 1, &mNewPeak, NumValidatorStyle::ONE_TRAILING_ZERO); .Validator<FloatingPointValidator<double>>(
double minAmp = MIN_Amp + LINEAR_TO_DB(mPeak); // One extra decimal place so that rounding is visible to user
double maxAmp = MAX_Amp + LINEAR_TO_DB(mPeak); // (see: bug 958)
precision + 1,
&mNewPeak, NumValidatorStyle::ONE_TRAILING_ZERO,
// min and max need same precision as what we're validating (bug 963) // min and max need same precision as what we're validating (bug 963)
minAmp = Internat::CompatibleToDouble(Internat::ToString(minAmp, precision +1)); RoundValue( precision + 1, MIN_Amp + LINEAR_TO_DB(mPeak) ),
maxAmp = Internat::CompatibleToDouble(Internat::ToString(maxAmp, precision +1)); RoundValue( precision + 1, MAX_Amp + LINEAR_TO_DB(mPeak) )
)
vldNewPeak.SetRange(minAmp, maxAmp); .AddTextBox(_("New Peak Amplitude (dB):"), wxT(""), 12);
mNewPeakT = S.Id(ID_Peak).AddTextBox(_("New Peak Amplitude (dB):"), wxT(""), 12);
mNewPeakT->SetValidator(vldNewPeak);
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -428,50 +428,57 @@ void EffectAutoDuck::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(6, wxCENTER); S.StartMultiColumn(6, wxCENTER);
{ {
FloatingPointValidator<double> vldDuckAmountDb(1, &mDuckAmountDb, NumValidatorStyle::NO_TRAILING_ZEROES); mDuckAmountDbBox = S.Validator<FloatingPointValidator<double>>(
vldDuckAmountDb.SetRange(MIN_DuckAmountDb, MAX_DuckAmountDb); 1, &mDuckAmountDb, NumValidatorStyle::NO_TRAILING_ZEROES,
mDuckAmountDbBox = S.AddTextBox(_("Duck amount:"), wxT(""), 10); MIN_DuckAmountDb, MAX_DuckAmountDb
mDuckAmountDbBox->SetValidator(vldDuckAmountDb); )
.AddTextBox(_("Duck amount:"), wxT(""), 10);
S.AddUnits(_("dB")); S.AddUnits(_("dB"));
FloatingPointValidator<double> vldMaximumPause(2, &mMaximumPause, NumValidatorStyle::NO_TRAILING_ZEROES); mMaximumPauseBox = S.Validator<FloatingPointValidator<double>>(
vldMaximumPause.SetRange(MIN_MaximumPause, MAX_MaximumPause); 2, &mMaximumPause, NumValidatorStyle::NO_TRAILING_ZEROES,
mMaximumPauseBox = S.AddTextBox(_("Maximum pause:"), wxT(""), 10); MIN_MaximumPause, MAX_MaximumPause
mMaximumPauseBox->SetValidator(vldMaximumPause); )
.AddTextBox(_("Maximum pause:"), wxT(""), 10);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
FloatingPointValidator<double> vldOuterFadeDownLen(2, &mOuterFadeDownLen, NumValidatorStyle::NO_TRAILING_ZEROES); mOuterFadeDownLenBox = S.Validator<FloatingPointValidator<double>>(
vldOuterFadeDownLen.SetRange(MIN_OuterFadeDownLen, MAX_OuterFadeDownLen); 2, &mOuterFadeDownLen, NumValidatorStyle::NO_TRAILING_ZEROES,
mOuterFadeDownLenBox = S.AddTextBox(_("Outer fade down length:"), wxT(""), 10); MIN_OuterFadeDownLen, MAX_OuterFadeDownLen
mOuterFadeDownLenBox->SetValidator(vldOuterFadeDownLen); )
.AddTextBox(_("Outer fade down length:"), wxT(""), 10);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
FloatingPointValidator<double> vldOuterFadeUpLen(2, &mOuterFadeUpLen, NumValidatorStyle::NO_TRAILING_ZEROES); mOuterFadeUpLenBox = S.Validator<FloatingPointValidator<double>>(
vldOuterFadeUpLen.SetRange(MIN_OuterFadeUpLen, MAX_OuterFadeUpLen); 2, &mOuterFadeUpLen, NumValidatorStyle::NO_TRAILING_ZEROES,
mOuterFadeUpLenBox = S.AddTextBox(_("Outer fade up length:"), wxT(""), 10); MIN_OuterFadeUpLen, MAX_OuterFadeUpLen
mOuterFadeUpLenBox->SetValidator(vldOuterFadeUpLen); )
.AddTextBox(_("Outer fade up length:"), wxT(""), 10);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
FloatingPointValidator<double> vldInnerFadeDownLen(2, &mInnerFadeDownLen, NumValidatorStyle::NO_TRAILING_ZEROES); mInnerFadeDownLenBox = S.Validator<FloatingPointValidator<double>>(
vldInnerFadeDownLen.SetRange(MIN_InnerFadeDownLen, MAX_InnerFadeDownLen); 2, &mInnerFadeDownLen, NumValidatorStyle::NO_TRAILING_ZEROES,
mInnerFadeDownLenBox = S.AddTextBox(_("Inner fade down length:"), wxT(""), 10); MIN_InnerFadeDownLen, MAX_InnerFadeDownLen
mInnerFadeDownLenBox->SetValidator(vldInnerFadeDownLen); )
.AddTextBox(_("Inner fade down length:"), wxT(""), 10);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
FloatingPointValidator<double> vldInnerFadeUpLen(2, &mInnerFadeUpLen, NumValidatorStyle::NO_TRAILING_ZEROES); mInnerFadeUpLenBox = S.Validator<FloatingPointValidator<double>>(
vldInnerFadeUpLen.SetRange(MIN_InnerFadeUpLen, MAX_InnerFadeUpLen); 2, &mInnerFadeUpLen, NumValidatorStyle::NO_TRAILING_ZEROES,
mInnerFadeUpLenBox = S.AddTextBox(_("Inner fade up length:"), wxT(""), 10); MIN_InnerFadeUpLen, MAX_InnerFadeUpLen
mInnerFadeUpLenBox->SetValidator(vldInnerFadeUpLen); )
.AddTextBox(_("Inner fade up length:"), wxT(""), 10);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
} }
S.EndMultiColumn(); S.EndMultiColumn();
S.StartMultiColumn(3, wxCENTER); S.StartMultiColumn(3, wxCENTER);
{ {
FloatingPointValidator<double> vldThresholdDb(2, &mThresholdDb, NumValidatorStyle::NO_TRAILING_ZEROES); mThresholdDbBox = S.Validator<FloatingPointValidator<double>>(
vldThresholdDb.SetRange(MIN_ThresholdDb, MAX_ThresholdDb); 2, &mThresholdDb, NumValidatorStyle::NO_TRAILING_ZEROES,
mThresholdDbBox = S.AddTextBox(_("Threshold:"), wxT(""), 10); MIN_ThresholdDb, MAX_ThresholdDb
mThresholdDbBox->SetValidator(vldThresholdDb); )
.AddTextBox(_("Threshold:"), wxT(""), 10);
S.AddUnits(_("dB")); S.AddUnits(_("dB"));
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -227,21 +227,21 @@ void EffectBassTreble::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol(2); S.SetStretchyCol(2);
// Bass control // Bass control
FloatingPointValidator<double> vldBass(1, &mBass); mBassT = S.Id(ID_Bass)
vldBass.SetRange(MIN_Bass, MAX_Bass); .Validator<FloatingPointValidator<double>>(
mBassT = S.Id(ID_Bass).AddTextBox(_("Ba&ss (dB):"), wxT(""), 10); 1, &mBass, NumValidatorStyle::DEFAULT, MIN_Bass, MAX_Bass)
.AddTextBox(_("Ba&ss (dB):"), wxT(""), 10);
mBassT->SetName(_("Bass (dB):")); mBassT->SetName(_("Bass (dB):"));
mBassT->SetValidator(vldBass);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mBassS = S.Id(ID_Bass).AddSlider( {}, 0, MAX_Bass * SCL_Bass, MIN_Bass * SCL_Bass); mBassS = S.Id(ID_Bass).AddSlider( {}, 0, MAX_Bass * SCL_Bass, MIN_Bass * SCL_Bass);
mBassS->SetName(_("Bass")); mBassS->SetName(_("Bass"));
// Treble control // Treble control
FloatingPointValidator<double> vldTreble(1, &mTreble); mTrebleT = S.Id(ID_Treble)
vldTreble.SetRange(MIN_Treble, MAX_Treble); .Validator<FloatingPointValidator<double>>(
mTrebleT = S.Id(ID_Treble).AddTextBox(_("&Treble (dB):"), wxT(""), 10); 1, &mTreble, NumValidatorStyle::DEFAULT, MIN_Treble, MAX_Treble)
mTrebleT->SetValidator(vldTreble); .AddTextBox(_("&Treble (dB):"), wxT(""), 10);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mTrebleS = S.Id(ID_Treble).AddSlider( {}, 0, MAX_Treble * SCL_Treble, MIN_Treble * SCL_Treble); mTrebleS = S.Id(ID_Treble).AddSlider( {}, 0, MAX_Treble * SCL_Treble, MIN_Treble * SCL_Treble);
@ -258,10 +258,10 @@ void EffectBassTreble::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol(2); S.SetStretchyCol(2);
// Gain control // Gain control
FloatingPointValidator<double> vldGain(1, &mGain); mGainT = S.Id(ID_Gain)
vldGain.SetRange(MIN_Gain, MAX_Gain); .Validator<FloatingPointValidator<double>>(
mGainT = S.Id(ID_Gain).AddTextBox(_("&Volume (dB):"), wxT(""), 10); 1, &mGain, NumValidatorStyle::DEFAULT, MIN_Gain, MAX_Gain)
mGainT->SetValidator(vldGain); .AddTextBox(_("&Volume (dB):"), wxT(""), 10);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mGainS = S.Id(ID_Gain).AddSlider( {}, 0, MAX_Gain * SCL_Gain, MIN_Gain * SCL_Gain); mGainS = S.Id(ID_Gain).AddSlider( {}, 0, MAX_Gain * SCL_Gain, MIN_Gain * SCL_Gain);

View File

@ -296,11 +296,13 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_CENTER); S.StartHorizontalLay(wxALIGN_CENTER);
{ {
FloatingPointValidator<double> vldSemitones(2, &m_dSemitonesChange, NumValidatorStyle::TWO_TRAILING_ZEROES); m_pTextCtrl_SemitonesChange = S.Id(ID_SemitonesChange)
m_pTextCtrl_SemitonesChange = .Validator<FloatingPointValidator<double>>(
S.Id(ID_SemitonesChange).AddTextBox(_("Semitones (half-steps):"), wxT(""), 12); 2, &m_dSemitonesChange,
NumValidatorStyle::TWO_TRAILING_ZEROES
)
.AddTextBox(_("Semitones (half-steps):"), wxT(""), 12);
m_pTextCtrl_SemitonesChange->SetName(_("Semitones (half-steps)")); m_pTextCtrl_SemitonesChange->SetName(_("Semitones (half-steps)"));
m_pTextCtrl_SemitonesChange->SetValidator(vldSemitones);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -310,17 +312,23 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(5, wxALIGN_CENTER); // 5, because AddTextBox adds a wxStaticText and a wxTextCtrl. S.StartMultiColumn(5, wxALIGN_CENTER); // 5, because AddTextBox adds a wxStaticText and a wxTextCtrl.
{ {
FloatingPointValidator<double> vldFromFrequency(3, &m_FromFrequency, NumValidatorStyle::THREE_TRAILING_ZEROES); m_pTextCtrl_FromFrequency = S.Id(ID_FromFrequency)
vldFromFrequency.SetMin(0.0); .Validator<FloatingPointValidator<double>>(
m_pTextCtrl_FromFrequency = S.Id(ID_FromFrequency).AddTextBox(_("from"), wxT(""), 12); 3, &m_FromFrequency,
NumValidatorStyle::THREE_TRAILING_ZEROES,
0.0
)
.AddTextBox(_("from"), wxT(""), 12);
m_pTextCtrl_FromFrequency->SetName(_("from (Hz)")); m_pTextCtrl_FromFrequency->SetName(_("from (Hz)"));
m_pTextCtrl_FromFrequency->SetValidator(vldFromFrequency);
FloatingPointValidator<double> vldToFrequency(3, &m_ToFrequency, NumValidatorStyle::THREE_TRAILING_ZEROES); m_pTextCtrl_ToFrequency = S.Id(ID_ToFrequency)
vldToFrequency.SetMin(0.0); .Validator<FloatingPointValidator<double>>(
m_pTextCtrl_ToFrequency = S.Id(ID_ToFrequency).AddTextBox(_("to"), wxT(""), 12); 3, &m_ToFrequency,
NumValidatorStyle::THREE_TRAILING_ZEROES,
0.0
)
.AddTextBox(_("to"), wxT(""), 12);
m_pTextCtrl_ToFrequency->SetName(_("to (Hz)")); m_pTextCtrl_ToFrequency->SetName(_("to (Hz)"));
m_pTextCtrl_ToFrequency->SetValidator(vldToFrequency);
S.AddUnits(_("Hz")); S.AddUnits(_("Hz"));
} }
@ -328,10 +336,13 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_CENTER); S.StartHorizontalLay(wxALIGN_CENTER);
{ {
FloatingPointValidator<double> vldPercentage(3, &m_dPercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES); m_pTextCtrl_PercentChange = S.Id(ID_PercentChange)
vldPercentage.SetRange(MIN_Percentage, MAX_Percentage); .Validator<FloatingPointValidator<double>>(
m_pTextCtrl_PercentChange = S.Id(ID_PercentChange).AddTextBox(_("Percent Change:"), wxT(""), 12); 3, &m_dPercentChange,
m_pTextCtrl_PercentChange->SetValidator(vldPercentage); NumValidatorStyle::THREE_TRAILING_ZEROES,
MIN_Percentage, MAX_Percentage
)
.AddTextBox(_("Percent Change:"), wxT(""), 12);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
@ -349,9 +360,9 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
#if USE_SBSMS #if USE_SBSMS
S.StartMultiColumn(2); S.StartMultiColumn(2);
{ {
mUseSBSMSCheckBox = S.AddCheckBox(_("Use high quality stretching (slow)"), mUseSBSMSCheckBox = S.Validator<wxGenericValidator>(&mUseSBSMS)
.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMS); mUseSBSMS);
mUseSBSMSCheckBox->SetValidator(wxGenericValidator(&mUseSBSMS));
} }
S.EndMultiColumn(); S.EndMultiColumn();
#endif #endif

View File

@ -313,17 +313,21 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
// Speed multiplier and percent change controls. // Speed multiplier and percent change controls.
S.StartMultiColumn(4, wxCENTER); S.StartMultiColumn(4, wxCENTER);
{ {
FloatingPointValidator<double> vldMultiplier(3, &mMultiplier, NumValidatorStyle::THREE_TRAILING_ZEROES); mpTextCtrl_Multiplier = S.Id(ID_Multiplier)
vldMultiplier.SetRange(MIN_Percentage / 100.0, ((MAX_Percentage / 100.0) + 1)); .Validator<FloatingPointValidator<double>>(
mpTextCtrl_Multiplier = 3, &mMultiplier,
S.Id(ID_Multiplier).AddTextBox(_("Speed Multiplier:"), wxT(""), 12); NumValidatorStyle::THREE_TRAILING_ZEROES,
mpTextCtrl_Multiplier->SetValidator(vldMultiplier); MIN_Percentage / 100.0, ((MAX_Percentage / 100.0) + 1)
)
.AddTextBox(_("Speed Multiplier:"), wxT(""), 12);
FloatingPointValidator<double> vldPercentage(3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES); mpTextCtrl_PercentChange = S.Id(ID_PercentChange)
vldPercentage.SetRange(MIN_Percentage, MAX_Percentage); .Validator<FloatingPointValidator<double>>(
mpTextCtrl_PercentChange = 3, &m_PercentChange,
S.Id(ID_PercentChange).AddTextBox(_("Percent Change:"), wxT(""), 12); NumValidatorStyle::THREE_TRAILING_ZEROES,
mpTextCtrl_PercentChange->SetValidator(vldPercentage); MIN_Percentage, MAX_Percentage
)
.AddTextBox(_("Percent Change:"), wxT(""), 12);
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -232,11 +232,12 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
// //
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
FloatingPointValidator<double> vldPercentage(3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES);
vldPercentage.SetRange(MIN_Percentage, MAX_Percentage);
m_pTextCtrl_PercentChange = S.Id(ID_PercentChange) m_pTextCtrl_PercentChange = S.Id(ID_PercentChange)
.Validator<FloatingPointValidator<double>>(
3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES,
MIN_Percentage, MAX_Percentage
)
.AddTextBox(_("Percent Change:"), wxT(""), 12); .AddTextBox(_("Percent Change:"), wxT(""), 12);
m_pTextCtrl_PercentChange->SetValidator(vldPercentage);
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -254,17 +255,23 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartHorizontalLay(wxALIGN_CENTER); S.StartHorizontalLay(wxALIGN_CENTER);
{ {
FloatingPointValidator<double> vldFromBPM(3, &m_FromBPM, NumValidatorStyle::THREE_TRAILING_ZEROES | NumValidatorStyle::ZERO_AS_BLANK);
m_pTextCtrl_FromBPM = S.Id(ID_FromBPM) m_pTextCtrl_FromBPM = S.Id(ID_FromBPM)
.Validator<FloatingPointValidator<double>>(
3, &m_FromBPM,
NumValidatorStyle::THREE_TRAILING_ZEROES
| NumValidatorStyle::ZERO_AS_BLANK)
/* i18n-hint: changing a quantity "from" one value "to" another */
.AddTextBox(_("from"), wxT(""), 12); .AddTextBox(_("from"), wxT(""), 12);
m_pTextCtrl_FromBPM->SetName(_("Beats per minute, from")); m_pTextCtrl_FromBPM->SetName(_("Beats per minute, from"));
m_pTextCtrl_FromBPM->SetValidator(vldFromBPM);
FloatingPointValidator<double> vldToBPM(3, &m_ToBPM, NumValidatorStyle::THREE_TRAILING_ZEROES | NumValidatorStyle::ZERO_AS_BLANK);
m_pTextCtrl_ToBPM = S.Id(ID_ToBPM) m_pTextCtrl_ToBPM = S.Id(ID_ToBPM)
.Validator<FloatingPointValidator<double>>(
3, &m_ToBPM,
NumValidatorStyle::THREE_TRAILING_ZEROES
| NumValidatorStyle::ZERO_AS_BLANK)
/* i18n-hint: changing a quantity "from" one value "to" another */
.AddTextBox(_("to"), wxT(""), 12); .AddTextBox(_("to"), wxT(""), 12);
m_pTextCtrl_ToBPM->SetName(_("Beats per minute, to")); m_pTextCtrl_ToBPM->SetName(_("Beats per minute, to"));
m_pTextCtrl_ToBPM->SetValidator(vldToBPM);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -275,24 +282,25 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartHorizontalLay(wxALIGN_CENTER); S.StartHorizontalLay(wxALIGN_CENTER);
{ {
FloatingPointValidator<double> vldFromLength(precision, &m_FromLength, NumValidatorStyle::TWO_TRAILING_ZEROES);
m_pTextCtrl_FromLength = S.Id(ID_FromLength) m_pTextCtrl_FromLength = S.Id(ID_FromLength)
.Validator<FloatingPointValidator<double>>(
precision, &m_FromLength,
NumValidatorStyle::TWO_TRAILING_ZEROES)
/* i18n-hint: changing a quantity "from" one value "to" another */
.AddTextBox(_("from"), wxT(""), 12); .AddTextBox(_("from"), wxT(""), 12);
m_pTextCtrl_FromLength->SetValidator(vldFromLength);
m_pTextCtrl_FromLength->Enable(false); // Disable because the value comes from the user selection. m_pTextCtrl_FromLength->Enable(false); // Disable because the value comes from the user selection.
FloatingPointValidator<double> vldToLength(2, &m_ToLength, NumValidatorStyle::TWO_TRAILING_ZEROES);
// min and max need same precision as what we're validating (bug 963)
double minLength = (m_FromLength * 100.0) / (100.0 + MAX_Percentage);
double maxLength = (m_FromLength * 100.0) / (100.0 + MIN_Percentage);
minLength = Internat::CompatibleToDouble(Internat::ToString(minLength, precision));
maxLength = Internat::CompatibleToDouble(Internat::ToString(maxLength, precision));
vldToLength.SetRange(minLength, maxLength);
m_pTextCtrl_ToLength = S.Id(ID_ToLength) m_pTextCtrl_ToLength = S.Id(ID_ToLength)
.Validator<FloatingPointValidator<double>>(
2, &m_ToLength, NumValidatorStyle::TWO_TRAILING_ZEROES,
// min and max need same precision as what we're validating (bug 963)
RoundValue( precision,
(m_FromLength * 100.0) / (100.0 + MIN_Percentage) ),
RoundValue( precision,
(m_FromLength * 100.0) / (100.0 + MAX_Percentage) )
)
/* i18n-hint: changing a quantity "from" one value "to" another */
.AddTextBox(_("to"), wxT(""), 12); .AddTextBox(_("to"), wxT(""), 12);
m_pTextCtrl_ToLength->SetValidator(vldToLength);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -301,9 +309,9 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
#if USE_SBSMS #if USE_SBSMS
S.StartMultiColumn(2); S.StartMultiColumn(2);
{ {
mUseSBSMSCheckBox = S.AddCheckBox(_("Use high quality stretching (slow)"), mUseSBSMSCheckBox = S.Validator<wxGenericValidator>(&mUseSBSMS)
.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMS); mUseSBSMS);
mUseSBSMSCheckBox->SetValidator(wxGenericValidator(&mUseSBSMS));
} }
S.EndMultiColumn(); S.EndMultiColumn();
#endif #endif

View File

@ -338,31 +338,35 @@ void EffectClickRemoval::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol(2); S.SetStretchyCol(2);
{ {
// Threshold // Threshold
IntegerValidator<int> vldThresh(&mThresholdLevel); mThreshT = S.Id(ID_Thresh)
vldThresh.SetRange(MIN_Threshold, MAX_Threshold); .Validator<IntegerValidator<int>>(
mThreshT = S.Id(ID_Thresh).AddTextBox(_("Threshold (lower is more sensitive):"), &mThresholdLevel, NumValidatorStyle::DEFAULT,
MIN_Threshold, MAX_Threshold
)
.AddTextBox(_("Threshold (lower is more sensitive):"),
wxT(""), wxT(""),
10); 10);
mThreshT->SetValidator(vldThresh);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mThreshS = S.Id(ID_Thresh).AddSlider( {}, mThresholdLevel, MAX_Threshold, MIN_Threshold); mThreshS = S.Id(ID_Thresh)
.Validator<wxGenericValidator>(&mThresholdLevel)
.AddSlider( {}, mThresholdLevel, MAX_Threshold, MIN_Threshold);
mThreshS->SetName(_("Threshold")); mThreshS->SetName(_("Threshold"));
mThreshS->SetValidator(wxGenericValidator(&mThresholdLevel));
mThreshS->SetMinSize(wxSize(150, -1)); mThreshS->SetMinSize(wxSize(150, -1));
// Click width // Click width
IntegerValidator<int> vldWidth(&mClickWidth); mWidthT = S.Id(ID_Width)
vldWidth.SetRange(MIN_Width, MAX_Width); .Validator<IntegerValidator<int>>(
mWidthT = S.Id(ID_Width).AddTextBox(_("Max Spike Width (higher is more sensitive):"), &mClickWidth, NumValidatorStyle::DEFAULT, MIN_Width, MAX_Width)
.AddTextBox(_("Max Spike Width (higher is more sensitive):"),
wxT(""), wxT(""),
10); 10);
mWidthT->SetValidator(vldWidth);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mWidthS = S.Id(ID_Width).AddSlider( {}, mClickWidth, MAX_Width, MIN_Width); mWidthS = S.Id(ID_Width)
.Validator<wxGenericValidator>(&mClickWidth)
.AddSlider( {}, mClickWidth, MAX_Width, MIN_Width);
mWidthS->SetName(_("Max Spike Width")); mWidthS->SetName(_("Max Spike Width"));
mWidthS->SetValidator(wxGenericValidator(&mClickWidth));
mWidthS->SetMinSize(wxSize(150, -1)); mWidthS->SetMinSize(wxSize(150, -1));
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -373,9 +373,9 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(4, wxCENTER); S.StartMultiColumn(4, wxCENTER);
{ {
mTypeChoiceCtrl = S.Id(ID_Type) mTypeChoiceCtrl = S.Id(ID_Type)
.Validator<wxGenericValidator>(&mParams.mTableChoiceIndx)
.AddChoice(_("Distortion type:"), .AddChoice(_("Distortion type:"),
LocalizedStrings(kTableTypeStrings, nTableTypes)); LocalizedStrings(kTableTypeStrings, nTableTypes));
mTypeChoiceCtrl->SetValidator(wxGenericValidator(&mParams.mTableChoiceIndx));
S.SetSizeHints(-1, -1); S.SetSizeHints(-1, -1);
mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(_("DC blocking filter"), mDCBlockCheckBox = S.Id(ID_DCBlock).AddCheckBox(_("DC blocking filter"),
@ -395,11 +395,12 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
// Upper threshold control // Upper threshold control
mThresholdTxt = S.AddVariableText(defaultLabel(0), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); mThresholdTxt = S.AddVariableText(defaultLabel(0), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
FloatingPointValidator<double> vldThreshold(2, &mParams.mThreshold_dB); mThresholdT = S.Id(ID_Threshold)
vldThreshold.SetRange(MIN_Threshold_dB, MAX_Threshold_dB); .Validator<FloatingPointValidator<double>>(
mThresholdT = S.Id(ID_Threshold).AddTextBox( {}, wxT(""), 10); 2, &mParams.mThreshold_dB, NumValidatorStyle::DEFAULT,
MIN_Threshold_dB, MAX_Threshold_dB)
.AddTextBox( {}, wxT(""), 10);
mThresholdT->SetName(defaultLabel(0)); mThresholdT->SetName(defaultLabel(0));
mThresholdT->SetValidator(vldThreshold);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mThresholdS = S.Id(ID_Threshold) mThresholdS = S.Id(ID_Threshold)
@ -411,11 +412,13 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
// Noise floor control // Noise floor control
mNoiseFloorTxt = S.AddVariableText(defaultLabel(1), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); mNoiseFloorTxt = S.AddVariableText(defaultLabel(1), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
FloatingPointValidator<double> vldfloor(2, &mParams.mNoiseFloor); mNoiseFloorT = S.Id(ID_NoiseFloor)
vldfloor.SetRange(MIN_NoiseFloor, MAX_NoiseFloor); .Validator<FloatingPointValidator<double>>(
mNoiseFloorT = S.Id(ID_NoiseFloor).AddTextBox( {}, wxT(""), 10); 2, &mParams.mNoiseFloor, NumValidatorStyle::DEFAULT,
MIN_NoiseFloor, MAX_NoiseFloor
)
.AddTextBox( {}, wxT(""), 10);
mNoiseFloorT->SetName(defaultLabel(1)); mNoiseFloorT->SetName(defaultLabel(1));
mNoiseFloorT->SetValidator(vldfloor);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mNoiseFloorS = S.Id(ID_NoiseFloor).AddSlider( {}, 0, MAX_NoiseFloor, MIN_NoiseFloor); mNoiseFloorS = S.Id(ID_NoiseFloor).AddSlider( {}, 0, MAX_NoiseFloor, MIN_NoiseFloor);
@ -436,11 +439,13 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
// Parameter1 control // Parameter1 control
mParam1Txt = S.AddVariableText(defaultLabel(2), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); mParam1Txt = S.AddVariableText(defaultLabel(2), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
FloatingPointValidator<double> vldparam1(2, &mParams.mParam1); mParam1T = S.Id(ID_Param1)
vldparam1.SetRange(MIN_Param1, MAX_Param1); .Validator<FloatingPointValidator<double>>(
mParam1T = S.Id(ID_Param1).AddTextBox( {}, wxT(""), 10); 2, &mParams.mParam1, NumValidatorStyle::DEFAULT,
MIN_Param1, MAX_Param1
)
.AddTextBox( {}, wxT(""), 10);
mParam1T->SetName(defaultLabel(2)); mParam1T->SetName(defaultLabel(2));
mParam1T->SetValidator(vldparam1);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mParam1S = S.Id(ID_Param1).AddSlider( {}, 0, MAX_Param1, MIN_Param1); mParam1S = S.Id(ID_Param1).AddSlider( {}, 0, MAX_Param1, MIN_Param1);
@ -449,11 +454,13 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
// Parameter2 control // Parameter2 control
mParam2Txt = S.AddVariableText(defaultLabel(3), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); mParam2Txt = S.AddVariableText(defaultLabel(3), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
FloatingPointValidator<double> vldParam2(2, &mParams.mParam2); mParam2T = S.Id(ID_Param2)
vldParam2.SetRange(MIN_Param2, MAX_Param2); .Validator<FloatingPointValidator<double>>(
mParam2T = S.Id(ID_Param2).AddTextBox( {}, wxT(""), 10); 2, &mParams.mParam2, NumValidatorStyle::DEFAULT,
MIN_Param2, MAX_Param2
)
.AddTextBox( {}, wxT(""), 10);
mParam2T->SetName(defaultLabel(3)); mParam2T->SetName(defaultLabel(3));
mParam2T->SetValidator(vldParam2);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mParam2S = S.Id(ID_Param2).AddSlider( {}, 0, MAX_Param2, MIN_Param2); mParam2S = S.Id(ID_Param2).AddSlider( {}, 0, MAX_Param2, MIN_Param2);
@ -462,11 +469,13 @@ void EffectDistortion::PopulateOrExchange(ShuttleGui & S)
// Repeats control // Repeats control
mRepeatsTxt = S.AddVariableText(defaultLabel(4), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); mRepeatsTxt = S.AddVariableText(defaultLabel(4), false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
IntegerValidator<int>vldRepeats(&mParams.mRepeats); mRepeatsT = S.Id(ID_Repeats)
vldRepeats.SetRange(MIN_Repeats, MAX_Repeats); .Validator<IntegerValidator<int>>(
mRepeatsT = S.Id(ID_Repeats).AddTextBox( {}, wxT(""), 10); &mParams.mRepeats, NumValidatorStyle::DEFAULT,
MIN_Repeats, MAX_Repeats
)
.AddTextBox( {}, wxT(""), 10);
mRepeatsT->SetName(defaultLabel(4)); mRepeatsT->SetName(defaultLabel(4));
mRepeatsT->SetValidator(vldRepeats);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mRepeatsS = S.Id(ID_Repeats).AddSlider( {}, DEF_Repeats, MAX_Repeats, MIN_Repeats); mRepeatsS = S.Id(ID_Repeats).AddSlider( {}, DEF_Repeats, MAX_Repeats, MIN_Repeats);

View File

@ -326,14 +326,19 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(0, 5); S.AddSpace(0, 5);
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
mDtmfSequenceT = S.Id(ID_Sequence)
.Validator([this]{
wxTextValidator vldDtmf(wxFILTER_INCLUDE_CHAR_LIST, &dtmfSequence); wxTextValidator vldDtmf(wxFILTER_INCLUDE_CHAR_LIST, &dtmfSequence);
vldDtmf.SetIncludes(wxArrayString(WXSIZEOF(kSymbols), kSymbols)); vldDtmf.SetIncludes(wxArrayString(WXSIZEOF(kSymbols), kSymbols));
mDtmfSequenceT = S.Id(ID_Sequence).AddTextBox(_("DTMF sequence:"), wxT(""), 10); return vldDtmf;
mDtmfSequenceT->SetValidator(vldDtmf); })
.AddTextBox(_("DTMF sequence:"), wxT(""), 10);
FloatingPointValidator<double> vldAmp(3, &dtmfAmplitude, NumValidatorStyle::NO_TRAILING_ZEROES); S.Id(ID_Amplitude)
vldAmp.SetRange(MIN_Amplitude, MAX_Amplitude); .Validator<FloatingPointValidator<double>>(
S.Id(ID_Amplitude).AddTextBox(_("Amplitude (0-1):"), wxT(""), 10)->SetValidator(vldAmp); 3, &dtmfAmplitude, NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_Amplitude, MAX_Amplitude)
.AddTextBox(_("Amplitude (0-1):"), wxT(""), 10);
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mDtmfDurationT = safenew mDtmfDurationT = safenew

View File

@ -167,13 +167,16 @@ void EffectEcho::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
{ {
FloatingPointValidator<double> vldDelay(3, &delay, NumValidatorStyle::NO_TRAILING_ZEROES); S.Validator<FloatingPointValidator<double>>(
vldDelay.SetRange(MIN_Delay, MAX_Delay); 3, &delay, NumValidatorStyle::NO_TRAILING_ZEROES,
S.AddTextBox(_("Delay time (seconds):"), wxT(""), 10)->SetValidator(vldDelay); MIN_Delay, MAX_Delay
)
.AddTextBox(_("Delay time (seconds):"), wxT(""), 10);
FloatingPointValidator<double> vldDecay(3, &decay, NumValidatorStyle::NO_TRAILING_ZEROES); S.Validator<FloatingPointValidator<double>>(
vldDecay.SetRange(MIN_Decay, MAX_Decay); 3, &decay, NumValidatorStyle::NO_TRAILING_ZEROES,
S.AddTextBox(_("Decay factor:"), wxT(""), 10)->SetValidator(vldDecay); MIN_Decay, MAX_Decay)
.AddTextBox(_("Decay factor:"), wxT(""), 10);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }

View File

@ -238,17 +238,13 @@ void EffectFindClipping::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
{ {
IntegerValidator<int> vldStart(&mStart); S.Validator<IntegerValidator<int>>(
vldStart.SetMin(MIN_Start); &mStart, NumValidatorStyle::DEFAULT, MIN_Start)
S.TieTextBox(_("Start threshold (samples):"), .TieTextBox(_("Start threshold (samples):"), mStart, 10);
mStart,
10)->SetValidator(vldStart);
IntegerValidator<int> vldStop(&mStop); S.Validator<IntegerValidator<int>>(
vldStop.SetMin(MIN_Stop); &mStop, NumValidatorStyle::DEFAULT, MIN_Stop)
S.TieTextBox(_("Stop threshold (samples):"), .TieTextBox(_("Stop threshold (samples):"), mStop, 10);
mStop,
10)->SetValidator(vldStop);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }

View File

@ -286,22 +286,24 @@ void EffectLoudness::PopulateOrExchange(ShuttleGui & S)
S.AddVariableText(_("Normalize"), false, S.AddVariableText(_("Normalize"), false,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
mNormalizeToCtl = S.AddChoice( {}, S
.Validator<wxGenericValidator>( &mNormalizeTo )
.AddChoice( {},
LocalizedStrings(kNormalizeTargetStrings, nAlgos), LocalizedStrings(kNormalizeTargetStrings, nAlgos),
mNormalizeTo mNormalizeTo
); );
mNormalizeToCtl->SetValidator(wxGenericValidator(&mNormalizeTo));
S.AddVariableText(_("to"), false, S.AddVariableText(_("to"), false,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
FloatingPointValidator<double> vldLevel(2, &mLUFSLevel, mLevelTextCtrl = S
NumValidatorStyle::ONE_TRAILING_ZERO); .Validator<FloatingPointValidator<double>>(
vldLevel.SetRange( MIN_LUFSLevel, MAX_LUFSLevel); 2, &mLUFSLevel,
NumValidatorStyle::ONE_TRAILING_ZERO,
mLevelTextCtrl = S.AddTextBox( {}, wxT(""), 10); MIN_LUFSLevel, MAX_LUFSLevel
)
.AddTextBox( {}, wxT(""), 10);
/* i18n-hint: LUFS is a particular method for measuring loudnesss */ /* i18n-hint: LUFS is a particular method for measuring loudnesss */
mLevelTextCtrl->SetName( _("Loudness LUFS")); mLevelTextCtrl->SetName( _("Loudness LUFS"));
mLevelTextCtrl->SetValidator(vldLevel);
/* i18n-hint: LUFS is a particular method for measuring loudnesss */ /* i18n-hint: LUFS is a particular method for measuring loudnesss */
mLeveldB = S.AddVariableText(_("LUFS"), false, mLeveldB = S.AddVariableText(_("LUFS"), false,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
@ -310,13 +312,15 @@ void EffectLoudness::PopulateOrExchange(ShuttleGui & S)
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
mStereoIndCheckBox = S.AddCheckBox(_("Normalize stereo channels independently"), mStereoIndCheckBox = S
.Validator<wxGenericValidator>( &mStereoInd )
.AddCheckBox(_("Normalize stereo channels independently"),
mStereoInd ? wxT("true") : wxT("false")); mStereoInd ? wxT("true") : wxT("false"));
mStereoIndCheckBox->SetValidator(wxGenericValidator(&mStereoInd));
mDualMonoCheckBox = S.AddCheckBox(_("Treat mono as dual-mono (recommended)"), mDualMonoCheckBox = S
.Validator<wxGenericValidator>( &mDualMono )
.AddCheckBox(_("Treat mono as dual-mono (recommended)"),
mDualMono ? wxT("true") : wxT("false")); mDualMono ? wxT("true") : wxT("false"));
mDualMonoCheckBox->SetValidator(wxGenericValidator(&mDualMono));
} }
S.EndVerticalLay(); S.EndVerticalLay();
} }

View File

@ -100,7 +100,6 @@ private:
wxStaticText *mLeveldB; wxStaticText *mLeveldB;
wxStaticText *mWarning; wxStaticText *mWarning;
wxCheckBox *mStereoIndCheckBox; wxCheckBox *mStereoIndCheckBox;
wxChoice *mNormalizeToCtl;
wxCheckBox *mDualMonoCheckBox; wxCheckBox *mDualMonoCheckBox;
Floats mTrackBuffer[2]; // MM: must be increased once surround channels are supported Floats mTrackBuffer[2]; // MM: must be increased once surround channels are supported

View File

@ -225,13 +225,13 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
S S.Validator<wxGenericValidator>(&mType)
.AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes)) .AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes));
->SetValidator(wxGenericValidator(&mType));
FloatingPointValidator<double> vldAmp(6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES); S.Validator<FloatingPointValidator<double>>(
vldAmp.SetRange(MIN_Amp, MAX_Amp); 6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, MIN_Amp, MAX_Amp
S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp); )
.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12);
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mNoiseDurationT = safenew mNoiseDurationT = safenew

View File

@ -1427,15 +1427,16 @@ struct ControlInfo {
void CreateControls(int id, ShuttleGui &S) const void CreateControls(int id, ShuttleGui &S) const
{ {
FloatingPointValidator<double> vld2(2);// precision. wxTextCtrl *const text = S.Id(id + 1)
if (formatAsInt) .Validator<FloatingPointValidator<double>>(
vld2.SetPrecision( 0 ); formatAsInt ? 0 : 2,
vld2.SetRange( valueMin, valueMax ); nullptr,
wxTextCtrl *const text = NumValidatorStyle::DEFAULT,
S.Id(id + 1).AddTextBox(textBoxCaption.Translation(), wxT(""), 0); valueMin, valueMax
S.SetStyle(wxSL_HORIZONTAL); )
text->SetValidator(vld2); .AddTextBox(textBoxCaption.Translation(), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL);
wxSlider *const slider = wxSlider *const slider =
S.Id(id) S.Id(id)
.AddSlider( {}, 0, sliderMax); .AddSlider( {}, 0, sliderMax);

View File

@ -717,40 +717,37 @@ void NoiseRemovalDialog::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(3, wxEXPAND); S.StartMultiColumn(3, wxEXPAND);
S.SetStretchyCol(2); S.SetStretchyCol(2);
{ {
wxTextValidator vld(wxFILTER_NUMERIC); mGainT = S.Id(ID_GAIN_TEXT)
mGainT = S.Id(ID_GAIN_TEXT).AddTextBox(_("Noise re&duction (dB):"), wxT(""), 0); .Validator<wxTextValidator>(wxFILTER_NUMERIC)
.AddTextBox(_("Noise re&duction (dB):"), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mGainT->SetValidator(vld);
mGainS = S.Id(ID_GAIN_SLIDER) mGainS = S.Id(ID_GAIN_SLIDER)
.AddSlider(wxT(""), 0, GAIN_MAX, GAIN_MIN); .AddSlider(wxT(""), 0, GAIN_MAX, GAIN_MIN);
mGainS->SetName(_("Noise reduction")); mGainS->SetName(_("Noise reduction"));
mGainS->SetSizeHints(150, -1); mGainS->SetSizeHints(150, -1);
mSensitivityT = S.Id(ID_SENSITIVITY_TEXT).AddTextBox(_("&Sensitivity (dB):"), mSensitivityT = S.Id(ID_SENSITIVITY_TEXT)
wxT(""), .Validator<wxTextValidator>(wxFILTER_NUMERIC)
0); .AddTextBox(_("&Sensitivity (dB):"), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mSensitivityT->SetValidator(vld);
mSensitivityS = S.Id(ID_SENSITIVITY_SLIDER) mSensitivityS = S.Id(ID_SENSITIVITY_SLIDER)
.AddSlider(wxT(""), 0, SENSITIVITY_MAX, SENSITIVITY_MIN); .AddSlider(wxT(""), 0, SENSITIVITY_MAX, SENSITIVITY_MIN);
mSensitivityS->SetName(_("Sensitivity")); mSensitivityS->SetName(_("Sensitivity"));
mSensitivityS->SetSizeHints(150, -1); mSensitivityS->SetSizeHints(150, -1);
mFreqT = S.Id(ID_FREQ_TEXT).AddTextBox(_("Fr&equency smoothing (Hz):"), mFreqT = S.Id(ID_FREQ_TEXT)
wxT(""), .Validator<wxTextValidator>(wxFILTER_NUMERIC)
0); .AddTextBox(_("Fr&equency smoothing (Hz):"), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mFreqT->SetValidator(vld);
mFreqS = S.Id(ID_FREQ_SLIDER) mFreqS = S.Id(ID_FREQ_SLIDER)
.AddSlider(wxT(""), 0, FREQ_MAX, FREQ_MIN); .AddSlider(wxT(""), 0, FREQ_MAX, FREQ_MIN);
mFreqS->SetName(_("Frequency smoothing")); mFreqS->SetName(_("Frequency smoothing"));
mFreqS->SetSizeHints(150, -1); mFreqS->SetSizeHints(150, -1);
mTimeT = S.Id(ID_TIME_TEXT).AddTextBox(_("Attac&k/decay time (secs):"), mTimeT = S.Id(ID_TIME_TEXT)
wxT(""), .Validator<wxTextValidator>(wxFILTER_NUMERIC)
0); .AddTextBox(_("Attac&k/decay time (secs):"), wxT(""), 0);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mTimeT->SetValidator(vld);
mTimeS = S.Id(ID_TIME_SLIDER) mTimeS = S.Id(ID_TIME_SLIDER)
.AddSlider(wxT(""), 0, TIME_MAX, TIME_MIN); .AddSlider(wxT(""), 0, TIME_MAX, TIME_MIN);
mTimeS->SetName(_("Attack/decay time")); mTimeS->SetName(_("Attack/decay time"));

View File

@ -293,34 +293,39 @@ void EffectNormalize::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartVerticalLay(false); S.StartVerticalLay(false);
{ {
mDCCheckBox = S.AddCheckBox(_("Remove DC offset (center on 0.0 vertically)"), mDCCheckBox = S.Validator<wxGenericValidator>(&mDC)
.AddCheckBox(_("Remove DC offset (center on 0.0 vertically)"),
mDC); mDC);
mDCCheckBox->SetValidator(wxGenericValidator(&mDC));
S.StartHorizontalLay(wxALIGN_LEFT, false); S.StartHorizontalLay(wxALIGN_LEFT, false);
{ {
mGainCheckBox = S mGainCheckBox = S
.Validator<wxGenericValidator>(&mGain)
.AddCheckBox(_("Normalize peak amplitude to "), .AddCheckBox(_("Normalize peak amplitude to "),
mGain); mGain);
mGainCheckBox->SetValidator(wxGenericValidator(&mGain));
mGainCheckBox->SetMinSize( mGainCheckBox->GetSize()); mGainCheckBox->SetMinSize( mGainCheckBox->GetSize());
FloatingPointValidator<double> vldLevel(2, &mPeakLevel, mLevelTextCtrl = S
NumValidatorStyle::ONE_TRAILING_ZERO); .Validator<FloatingPointValidator<double>>(
vldLevel.SetRange( MIN_PeakLevel, MAX_PeakLevel); 2,
&mPeakLevel,
mLevelTextCtrl = S.AddTextBox( {}, wxT(""), 10); NumValidatorStyle::ONE_TRAILING_ZERO,
mLevelTextCtrl->SetName( _("Peak amplitude dB")); MIN_PeakLevel,
mLevelTextCtrl->SetValidator(vldLevel); MAX_PeakLevel
)
.AddTextBox( {}, wxT(""), 10);
mLevelTextCtrl->SetName(_("Peak amplitude dB"));
mLeveldB = S.AddVariableText(_("dB"), false, mLeveldB = S.AddVariableText(_("dB"), false,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
mWarning = S.AddVariableText( {}, false, mWarning = S.AddVariableText( {}, false,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
mStereoIndCheckBox = S.AddCheckBox(_("Normalize stereo channels independently"),
mStereoIndCheckBox = S
.Validator<wxGenericValidator>(&mStereoInd)
.AddCheckBox(_("Normalize stereo channels independently"),
mStereoInd); mStereoInd);
mStereoIndCheckBox->SetValidator(wxGenericValidator(&mStereoInd));
} }
S.EndVerticalLay(); S.EndVerticalLay();
} }

View File

@ -194,18 +194,17 @@ void EffectPaulstretch::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
{ {
FloatingPointValidator<float> vldAmount(1, &mAmount); S.Validator<FloatingPointValidator<float>>(
vldAmount.SetMin(MIN_Amount); 1, &mAmount, NumValidatorStyle::DEFAULT, MIN_Amount)
/* i18n-hint: This is how many times longer the sound will be, e.g. applying /* i18n-hint: This is how many times longer the sound will be, e.g. applying
* the effect to a 1-second sample, with the default Stretch Factor of 10.0 * the effect to a 1-second sample, with the default Stretch Factor of 10.0
* will give an (approximately) 10 second sound * will give an (approximately) 10 second sound
*/ */
S.AddTextBox(_("Stretch Factor:"), wxT(""), 10)->SetValidator(vldAmount); .AddTextBox(_("Stretch Factor:"), wxT(""), 10);
FloatingPointValidator<float> vldTime(3, &mTime_resolution, NumValidatorStyle::ONE_TRAILING_ZERO); S.Validator<FloatingPointValidator<float>>(
vldTime.SetMin(MIN_Time); 3, &mTime_resolution, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Time)
S.AddTextBox(_("Time Resolution (seconds):"), wxT(""), 10)->SetValidator(vldTime); .AddTextBox(_("Time Resolution (seconds):"), wxT(""), 10);
} }
S.EndMultiColumn(); S.EndMultiColumn();
}; };

View File

@ -256,10 +256,10 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S)
{ {
S.SetStretchyCol(2); S.SetStretchyCol(2);
IntegerValidator<int> vldStages(&mStages); mStagesT = S.Id(ID_Stages)
vldStages.SetRange(MIN_Stages, MAX_Stages); .Validator<IntegerValidator<int>>(
mStagesT = S.Id(ID_Stages).AddTextBox(_("&Stages:"), wxT(""), 15); &mStages, NumValidatorStyle::DEFAULT, MIN_Stages, MAX_Stages)
mStagesT->SetValidator(vldStages); .AddTextBox(_("&Stages:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mStagesS = S.Id(ID_Stages).AddSlider( {}, DEF_Stages * SCL_Stages, MAX_Stages * SCL_Stages, MIN_Stages * SCL_Stages); mStagesS = S.Id(ID_Stages).AddSlider( {}, DEF_Stages * SCL_Stages, MAX_Stages * SCL_Stages, MIN_Stages * SCL_Stages);
@ -267,30 +267,30 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S)
mStagesS->SetLineSize(2); mStagesS->SetLineSize(2);
mStagesS->SetMinSize(wxSize(100, -1)); mStagesS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldDryWet(&mDryWet); mDryWetT = S.Id(ID_DryWet)
vldDryWet.SetRange(MIN_DryWet, MAX_DryWet); .Validator<IntegerValidator<int>>(
mDryWetT = S.Id(ID_DryWet).AddTextBox(_("&Dry/Wet:"), wxT(""), 15); &mDryWet, NumValidatorStyle::DEFAULT, MIN_DryWet, MAX_DryWet)
mDryWetT->SetValidator(vldDryWet); .AddTextBox(_("&Dry/Wet:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mDryWetS = S.Id(ID_DryWet).AddSlider( {}, DEF_DryWet * SCL_DryWet, MAX_DryWet * SCL_DryWet, MIN_DryWet * SCL_DryWet); mDryWetS = S.Id(ID_DryWet).AddSlider( {}, DEF_DryWet * SCL_DryWet, MAX_DryWet * SCL_DryWet, MIN_DryWet * SCL_DryWet);
mDryWetS->SetName(_("Dry Wet")); mDryWetS->SetName(_("Dry Wet"));
mDryWetS->SetMinSize(wxSize(100, -1)); mDryWetS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldFreq(5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO); mFreqT = S.Id(ID_Freq)
vldFreq.SetRange(MIN_Freq, MAX_Freq); .Validator<FloatingPointValidator<double>>(
mFreqT = S.Id(ID_Freq).AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 15); 5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Freq, MAX_Freq)
mFreqT->SetValidator(vldFreq); .AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mFreqS = S.Id(ID_Freq).AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, 0.0); mFreqS = S.Id(ID_Freq).AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, 0.0);
mFreqS ->SetName(_("LFO frequency in hertz")); mFreqS ->SetName(_("LFO frequency in hertz"));
mFreqS ->SetMinSize(wxSize(100, -1)); mFreqS ->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldPhase(1, &mPhase); mPhaseT = S.Id(ID_Phase)
vldPhase.SetRange(MIN_Phase, MAX_Phase); .Validator<FloatingPointValidator<double>>(
mPhaseT = S.Id(ID_Phase).AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 15); 1, &mPhase, NumValidatorStyle::DEFAULT, MIN_Phase, MAX_Phase)
mPhaseT->SetValidator(vldPhase); .AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mPhaseS = S.Id(ID_Phase).AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase); mPhaseS = S.Id(ID_Phase).AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase);
@ -298,20 +298,20 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S)
mPhaseS->SetLineSize(10); mPhaseS->SetLineSize(10);
mPhaseS->SetMinSize(wxSize(100, -1)); mPhaseS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldDepth(&mDepth); mDepthT = S.Id(ID_Depth)
vldDepth.SetRange(MIN_Depth, MAX_Depth); .Validator<IntegerValidator<int>>(
mDepthT = S.Id(ID_Depth).AddTextBox(_("Dept&h:"), wxT(""), 15); &mDepth, NumValidatorStyle::DEFAULT, MIN_Depth, MAX_Depth)
mDepthT->SetValidator(vldDepth); .AddTextBox(_("Dept&h:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth); mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth);
mDepthS->SetName(_("Depth in percent")); mDepthS->SetName(_("Depth in percent"));
mDepthS->SetMinSize(wxSize(100, -1)); mDepthS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldFeedback(&mFeedback); mFeedbackT = S.Id(ID_Feedback)
vldFeedback.SetRange(MIN_Feedback, MAX_Feedback); .Validator<IntegerValidator<int>>(
mFeedbackT = S.Id(ID_Feedback).AddTextBox(_("Feedbac&k (%):"), wxT(""), 15); &mFeedback, NumValidatorStyle::DEFAULT, MIN_Feedback, MAX_Feedback)
mFeedbackT->SetValidator(vldFeedback); .AddTextBox(_("Feedbac&k (%):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mFeedbackS = S.Id(ID_Feedback).AddSlider( {}, DEF_Feedback * SCL_Feedback, MAX_Feedback * SCL_Feedback, MIN_Feedback * SCL_Feedback); mFeedbackS = S.Id(ID_Feedback).AddSlider( {}, DEF_Feedback * SCL_Feedback, MAX_Feedback * SCL_Feedback, MIN_Feedback * SCL_Feedback);
@ -319,10 +319,10 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S)
mFeedbackS->SetLineSize(10); mFeedbackS->SetLineSize(10);
mFeedbackS->SetMinSize(wxSize(100, -1)); mFeedbackS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldoutgain(1, &mOutGain); mOutGainT = S.Id(ID_OutGain)
vldoutgain.SetRange(MIN_OutGain, MAX_OutGain); .Validator<FloatingPointValidator<double>>(
mOutGainT = S.Id(ID_OutGain).AddTextBox(_("&Output gain (dB):"), wxT(""), 12); 1, &mOutGain, NumValidatorStyle::DEFAULT, MIN_OutGain, MAX_OutGain)
mOutGainT->SetValidator(vldoutgain); .AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mOutGainS = S.Id(ID_OutGain).AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain); mOutGainS = S.Id(ID_OutGain).AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain);

View File

@ -172,10 +172,11 @@ void EffectRepeat::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartHorizontalLay(wxCENTER, false); S.StartHorizontalLay(wxCENTER, false);
{ {
IntegerValidator<int> vldRepeatCount(&repeatCount); mRepeatCount = S.Validator<IntegerValidator<int>>(
vldRepeatCount.SetRange(MIN_Count, 2147483647 / mProjectRate); &repeatCount, NumValidatorStyle::DEFAULT,
mRepeatCount = S.AddTextBox(_("Number of repeats to add:"), wxT(""), 12); MIN_Count, 2147483647 / mProjectRate
mRepeatCount->SetValidator(vldRepeatCount); )
.AddTextBox(_("Number of repeats to add:"), wxT(""), 12);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();

View File

@ -456,13 +456,14 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
wxASSERT(nTypes == WXSIZEOF(kTypeStrings)); wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
mFilterTypeCtl = S.Id(ID_Type) mFilterTypeCtl = S.Id(ID_Type)
.Validator<wxGenericValidator>(&mFilterType)
.AddChoice(_("&Filter Type:"), .AddChoice(_("&Filter Type:"),
LocalizedStrings(kTypeStrings, nTypes) LocalizedStrings(kTypeStrings, nTypes)
); );
mFilterTypeCtl->SetValidator(wxGenericValidator(&mFilterType));
S.SetSizeHints(-1, -1); S.SetSizeHints(-1, -1);
mFilterOrderCtl = S.Id(ID_Order) mFilterOrderCtl = S.Id(ID_Order)
.Validator<wxGenericValidator>(&mOrderIndex)
/*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/ /*i18n-hint: 'Order' means the complexity of the filter, and is a number between 1 and 10.*/
.AddChoice(_("O&rder:"), .AddChoice(_("O&rder:"),
[]{ []{
@ -472,41 +473,40 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
return orders; return orders;
}() }()
); );
mFilterOrderCtl->SetValidator(wxGenericValidator(&mOrderIndex));
S.SetSizeHints(-1, -1); S.SetSizeHints(-1, -1);
S.AddSpace(1, 1); S.AddSpace(1, 1);
FloatingPointValidator<float> vldRipple(1, &mRipple);
vldRipple.SetRange(MIN_Passband, MAX_Passband);
mRippleCtlP = S.AddVariableText(_("&Passband Ripple:"), false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); mRippleCtlP = S.AddVariableText(_("&Passband Ripple:"), false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
mRippleCtl = S.Id(ID_Ripple).AddTextBox( {}, wxT(""), 10); mRippleCtl = S.Id(ID_Ripple)
.Validator<FloatingPointValidator<float>>(
1, &mRipple, NumValidatorStyle::DEFAULT,
MIN_Passband, MAX_Passband)
.AddTextBox( {}, wxT(""), 10);
mRippleCtl->SetName(_("Passband Ripple (dB)")); mRippleCtl->SetName(_("Passband Ripple (dB)"));
mRippleCtl->SetValidator(vldRipple);
mRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); mRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
mFilterSubTypeCtl = S.Id(ID_SubType) mFilterSubTypeCtl = S.Id(ID_SubType)
.Validator<wxGenericValidator>(&mFilterSubtype)
.AddChoice(_("&Subtype:"), .AddChoice(_("&Subtype:"),
LocalizedStrings(kSubTypeStrings, nSubTypes) LocalizedStrings(kSubTypeStrings, nSubTypes)
); );
mFilterSubTypeCtl->SetValidator(wxGenericValidator(&mFilterSubtype));
S.SetSizeHints(-1, -1); S.SetSizeHints(-1, -1);
FloatingPointValidator<float> vldCutoff(1, &mCutoff); mCutoffCtl = S.Id(ID_Cutoff)
vldCutoff.SetRange(MIN_Cutoff, mNyquist - 1); .Validator<FloatingPointValidator<float>>(
1, &mCutoff, NumValidatorStyle::DEFAULT,
mCutoffCtl = S.Id(ID_Cutoff).AddTextBox(_("C&utoff:"), wxT(""), 10); MIN_Cutoff, mNyquist - 1)
.AddTextBox(_("C&utoff:"), wxT(""), 10);
mCutoffCtl->SetName(_("Cutoff (Hz)")); mCutoffCtl->SetName(_("Cutoff (Hz)"));
mCutoffCtl->SetValidator(vldCutoff);
S.AddUnits(_("Hz")); S.AddUnits(_("Hz"));
FloatingPointValidator<float> vldStopbandRipple(1, &mStopbandRipple);
vldStopbandRipple.SetRange(MIN_Stopband, MAX_Stopband);
mStopbandRippleCtlP = S.AddVariableText(_("Minimum S&topband Attenuation:"), false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); mStopbandRippleCtlP = S.AddVariableText(_("Minimum S&topband Attenuation:"), false, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);
mStopbandRippleCtl = S.Id(ID_StopbandRipple).AddTextBox( {}, wxT(""), 10); mStopbandRippleCtl = S.Id(ID_StopbandRipple)
.Validator<FloatingPointValidator<float>>(
1, &mStopbandRipple, NumValidatorStyle::DEFAULT,
MIN_Stopband, MAX_Stopband)
.AddTextBox( {}, wxT(""), 10);
mStopbandRippleCtl->SetName(_("Minimum S&topband Attenuation (dB)")); mStopbandRippleCtl->SetName(_("Minimum S&topband Attenuation (dB)"));
mStopbandRippleCtl->SetValidator(vldStopbandRipple);
mStopbandRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); mStopbandRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -206,13 +206,13 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(1, wxCENTER); S.StartMultiColumn(1, wxCENTER);
{ {
FloatingPointValidator<double>
vldRatePercentChangeStart(3, &m_RatePercentChangeStart, NumValidatorStyle::NO_TRAILING_ZEROES);
vldRatePercentChangeStart.SetRange(MIN_RatePercentStart, MAX_RatePercentStart);
m_pTextCtrl_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart) m_pTextCtrl_RatePercentChangeStart = S.Id(ID_RatePercentChangeStart)
.Validator<FloatingPointValidator<double>>(
3, &m_RatePercentChangeStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_RatePercentStart, MAX_RatePercentStart
)
.AddTextBox( {}, wxT(""), 12); .AddTextBox( {}, wxT(""), 12);
m_pTextCtrl_RatePercentChangeStart->SetValidator(vldRatePercentChangeStart);
} }
S.EndMultiColumn(); S.EndMultiColumn();
S.StartHorizontalLay(wxEXPAND, 0); S.StartHorizontalLay(wxEXPAND, 0);
@ -229,13 +229,13 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(1, wxCENTER); S.StartMultiColumn(1, wxCENTER);
{ {
FloatingPointValidator<double>
vldRatePercentChangeEnd(3, &m_RatePercentChangeEnd, NumValidatorStyle::NO_TRAILING_ZEROES);
vldRatePercentChangeEnd.SetRange(MIN_RatePercentEnd, MAX_RatePercentEnd);
m_pTextCtrl_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd) m_pTextCtrl_RatePercentChangeEnd = S.Id(ID_RatePercentChangeEnd)
.Validator<FloatingPointValidator<double>>(
3, &m_RatePercentChangeEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_RatePercentEnd, MAX_RatePercentEnd
)
.AddTextBox( {}, wxT(""), 12); .AddTextBox( {}, wxT(""), 12);
m_pTextCtrl_RatePercentChangeEnd->SetValidator(vldRatePercentChangeEnd);
} }
S.EndMultiColumn(); S.EndMultiColumn();
S.StartHorizontalLay(wxEXPAND, 0); S.StartHorizontalLay(wxEXPAND, 0);
@ -253,21 +253,22 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
FloatingPointValidator<double>
vldPitchHalfStepsStart(3, &m_PitchHalfStepsStart, NumValidatorStyle::NO_TRAILING_ZEROES);
vldPitchHalfStepsStart.SetRange(MIN_HalfStepsStart, MAX_HalfStepsStart);
m_pTextCtrl_PitchHalfStepsStart = S.Id(ID_PitchHalfStepsStart) m_pTextCtrl_PitchHalfStepsStart = S.Id(ID_PitchHalfStepsStart)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchHalfStepsStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_HalfStepsStart, MAX_HalfStepsStart
)
.AddTextBox(_("(semitones) [-12 to 12]:"), wxT(""), 12); .AddTextBox(_("(semitones) [-12 to 12]:"), wxT(""), 12);
m_pTextCtrl_PitchHalfStepsStart->SetValidator(vldPitchHalfStepsStart);
FloatingPointValidator<double>
vldPitchPercentChangeStart(3, &m_PitchPercentChangeStart, NumValidatorStyle::NO_TRAILING_ZEROES);
vldPitchPercentChangeStart.SetRange(MIN_PitchPercentStart, MAX_PitchPercentStart);
m_pTextCtrl_PitchPercentChangeStart = S.Id(ID_PitchPercentChangeStart) m_pTextCtrl_PitchPercentChangeStart = S.Id(ID_PitchPercentChangeStart)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchPercentChangeStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_PitchPercentStart, MAX_PitchPercentStart
)
.AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12); .AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12);
m_pTextCtrl_PitchPercentChangeStart->SetValidator(vldPitchPercentChangeStart);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -278,21 +279,20 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
FloatingPointValidator<double>
vldPitchHalfStepsEnd(3, &m_PitchHalfStepsEnd, NumValidatorStyle::NO_TRAILING_ZEROES);
vldPitchHalfStepsEnd.SetRange(MIN_HalfStepsEnd, MAX_HalfStepsEnd);
m_pTextCtrl_PitchHalfStepsEnd = S.Id(ID_PitchHalfStepsEnd) m_pTextCtrl_PitchHalfStepsEnd = S.Id(ID_PitchHalfStepsEnd)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchHalfStepsEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_HalfStepsEnd, MAX_HalfStepsEnd
)
.AddTextBox(_("(semitones) [-12 to 12]:"), wxT(""), 12); .AddTextBox(_("(semitones) [-12 to 12]:"), wxT(""), 12);
m_pTextCtrl_PitchHalfStepsEnd->SetValidator(vldPitchHalfStepsEnd);
FloatingPointValidator<double>
vldPitchPercentChangeEnd(3, &m_PitchPercentChangeEnd, NumValidatorStyle::NO_TRAILING_ZEROES);
vldPitchPercentChangeEnd.SetRange(MIN_PitchPercentStart, MAX_PitchPercentStart);
m_pTextCtrl_PitchPercentChangeEnd = S.Id(ID_PitchPercentChangeEnd) m_pTextCtrl_PitchPercentChangeEnd = S.Id(ID_PitchPercentChangeEnd)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchPercentChangeEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_PitchPercentStart, MAX_PitchPercentStart)
.AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12); .AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12);
m_pTextCtrl_PitchPercentChangeEnd->SetValidator(vldPitchPercentChangeEnd);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }

View File

@ -340,10 +340,9 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2, wxCENTER); S.StartMultiColumn(2, wxCENTER);
{ {
wxChoice *c = S S.Validator<wxGenericValidator>(&mWaveform)
.AddChoice(_("Waveform:"), .AddChoice(_("Waveform:"),
LocalizedStrings(kWaveStrings, nWaveforms)); LocalizedStrings(kWaveStrings, nWaveforms));
c->SetValidator(wxGenericValidator(&mWaveform));
if (mChirp) if (mChirp)
{ {
@ -369,27 +368,29 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartHorizontalLay(wxLEFT, 50); S.StartHorizontalLay(wxLEFT, 50);
{ {
FloatingPointValidator<double> vldStartFreq(6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES); t = S
vldStartFreq.SetRange( .Validator<FloatingPointValidator<double>>(
6, &mFrequency[0],
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_StartFreq, MIN_StartFreq,
ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0
); )
t = S.AddTextBox( {}, wxT(""), 12); .AddTextBox( {}, wxT(""), 12);
t->SetName(_("Frequency Hertz Start")); t->SetName(_("Frequency Hertz Start"));
t->SetValidator(vldStartFreq);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
S.StartHorizontalLay(wxLEFT, 50); S.StartHorizontalLay(wxLEFT, 50);
{ {
FloatingPointValidator<double> vldEndFreq(6, &mFrequency[1], NumValidatorStyle::NO_TRAILING_ZEROES); t = S
vldEndFreq.SetRange( .Validator<FloatingPointValidator<double>>(
6, &mFrequency[1],
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_EndFreq, MIN_EndFreq,
ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0
); )
t = S.AddTextBox( {}, wxT(""), 12); .AddTextBox( {}, wxT(""), 12);
t->SetName(_("Frequency Hertz End")); t->SetName(_("Frequency Hertz End"));
t->SetValidator(vldEndFreq);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -400,45 +401,48 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartHorizontalLay(wxLEFT, 50); S.StartHorizontalLay(wxLEFT, 50);
{ {
FloatingPointValidator<double> vldStartAmp(6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES); t = S
vldStartAmp.SetRange(MIN_StartAmp, MAX_StartAmp); .Validator<FloatingPointValidator<double>>(
t = S.AddTextBox( {}, wxT(""), 12); 6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_StartAmp, MAX_StartAmp
)
.AddTextBox( {}, wxT(""), 12);
t->SetName(_("Amplitude Start")); t->SetName(_("Amplitude Start"));
t->SetValidator(vldStartAmp);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
S.StartHorizontalLay(wxLEFT, 50); S.StartHorizontalLay(wxLEFT, 50);
{ {
FloatingPointValidator<double> vldEndAmp(6, &mAmplitude[1], NumValidatorStyle::NO_TRAILING_ZEROES); t = S
vldEndAmp.SetRange(MIN_EndAmp, MAX_EndAmp); .Validator<FloatingPointValidator<double>>(
t = S.AddTextBox( {}, wxT(""), 12); 6, &mAmplitude[1], NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_EndAmp, MAX_EndAmp
)
.AddTextBox( {}, wxT(""), 12);
t->SetName(_("Amplitude End")); t->SetName(_("Amplitude End"));
t->SetValidator(vldEndAmp);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
c = S S.Validator<wxGenericValidator>(&mInterpolation)
.AddChoice(_("Interpolation:"), .AddChoice(_("Interpolation:"),
LocalizedStrings(kInterStrings, nInterpolations)); LocalizedStrings(kInterStrings, nInterpolations));
c->SetValidator(wxGenericValidator(&mInterpolation));
} }
else else
{ {
FloatingPointValidator<double> vldFrequency(6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES); t = S.Validator<FloatingPointValidator<double>>(
vldFrequency.SetRange( 6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_Frequency, MIN_Frequency,
ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0
); )
t = S.AddTextBox(_("Frequency (Hz):"), wxT(""), 12); .AddTextBox(_("Frequency (Hz):"), wxT(""), 12);
t->SetValidator(vldFrequency);
FloatingPointValidator<double> vldAmplitude(6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES); t = S.Validator<FloatingPointValidator<double>>(
vldAmplitude.SetRange(MIN_Amplitude, MAX_Amplitude); 6, &mAmplitude[0], NumValidatorStyle::NO_TRAILING_ZEROES,
t = S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12); MIN_Amplitude, MAX_Amplitude
t->SetValidator(vldAmplitude); )
.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12);
} }
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));

View File

@ -754,18 +754,20 @@ void EffectTruncSilence::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL); S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL);
{ {
// Threshold // Threshold
FloatingPointValidator<double> vldThreshold(3, &mThresholdDB, mThresholdText = S
NumValidatorStyle::NO_TRAILING_ZEROES); .Validator<FloatingPointValidator<double>>(
vldThreshold.SetRange(MIN_Threshold, MAX_Threshold); 3, &mThresholdDB, NumValidatorStyle::NO_TRAILING_ZEROES,
mThresholdText = S.AddTextBox(_("Threshold:"), wxT(""), 0); MIN_Threshold, MAX_Threshold
mThresholdText->SetValidator(vldThreshold); )
.AddTextBox(_("Threshold:"), wxT(""), 0);
S.AddUnits(_("dB")); S.AddUnits(_("dB"));
// Ignored silence // Ignored silence
FloatingPointValidator<double> vldDur(3, &mInitialAllowedSilence, NumValidatorStyle::NO_TRAILING_ZEROES); mInitialAllowedSilenceT = S.Validator<FloatingPointValidator<double>>(
vldDur.SetRange(MIN_Minimum, MAX_Minimum); 3, &mInitialAllowedSilence,
mInitialAllowedSilenceT = S.AddTextBox(_("Duration:"), wxT(""), 12); NumValidatorStyle::NO_TRAILING_ZEROES,
mInitialAllowedSilenceT->SetValidator(vldDur); MIN_Minimum, MAX_Minimum)
.AddTextBox(_("Duration:"), wxT(""), 12);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
} }
S.EndMultiColumn(); S.EndMultiColumn();
@ -778,8 +780,8 @@ void EffectTruncSilence::PopulateOrExchange(ShuttleGui & S)
{ {
// Action choices // Action choices
auto actionChoices = LocalizedStrings(kActionStrings, nActions); auto actionChoices = LocalizedStrings(kActionStrings, nActions);
mActionChoice = S.AddChoice( {}, actionChoices ); mActionChoice = S.Validator<wxGenericValidator>(&mActionIndex)
mActionChoice->SetValidator(wxGenericValidator(&mActionIndex)); .AddChoice( {}, actionChoices );
S.SetSizeHints(-1, -1); S.SetSizeHints(-1, -1);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
@ -787,16 +789,20 @@ void EffectTruncSilence::PopulateOrExchange(ShuttleGui & S)
{ {
// Truncation / Compression factor // Truncation / Compression factor
FloatingPointValidator<double> vldTrunc(3, &mTruncLongestAllowedSilence, NumValidatorStyle::NO_TRAILING_ZEROES); mTruncLongestAllowedSilenceT = S.Validator<FloatingPointValidator<double>>(
vldTrunc.SetRange(MIN_Truncate, MAX_Truncate); 3, &mTruncLongestAllowedSilence,
mTruncLongestAllowedSilenceT = S.AddTextBox(_("Truncate to:"), wxT(""), 12); NumValidatorStyle::NO_TRAILING_ZEROES,
mTruncLongestAllowedSilenceT->SetValidator(vldTrunc); MIN_Truncate, MAX_Truncate
)
.AddTextBox(_("Truncate to:"), wxT(""), 12);
S.AddUnits(_("seconds")); S.AddUnits(_("seconds"));
FloatingPointValidator<double> vldComp(3, &mSilenceCompressPercent, NumValidatorStyle::NO_TRAILING_ZEROES); mSilenceCompressPercentT = S.Validator<FloatingPointValidator<double>>(
vldComp.SetRange(MIN_Compress, MAX_Compress); 3, &mSilenceCompressPercent,
mSilenceCompressPercentT = S.AddTextBox(_("Compress to:"), wxT(""), 12); NumValidatorStyle::NO_TRAILING_ZEROES,
mSilenceCompressPercentT->SetValidator(vldComp); MIN_Compress, MAX_Compress
)
.AddTextBox(_("Compress to:"), wxT(""), 12);
S.AddUnits(_("%")); S.AddUnits(_("%"));
} }
S.EndMultiColumn(); S.EndMultiColumn();

View File

@ -811,9 +811,6 @@ void VSTEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartStatic(_("Buffer Size")); S.StartStatic(_("Buffer Size"));
{ {
IntegerValidator<int> vld(&mBufferSize);
vld.SetRange(8, 1048576 * 1);
S.AddVariableText(wxString() + S.AddVariableText(wxString() +
_("The buffer size controls the number of samples sent to the effect ") + _("The buffer size controls the number of samples sent to the effect ") +
_("on each iteration. Smaller values will cause slower processing and ") + _("on each iteration. Smaller values will cause slower processing and ") +
@ -824,11 +821,12 @@ void VSTEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_LEFT); S.StartHorizontalLay(wxALIGN_LEFT);
{ {
wxTextCtrl *t; wxTextCtrl *t;
t = S.TieNumericTextBox(_("&Buffer Size (8 to 1048576 samples):"), t = S.Validator<IntegerValidator<int>>(
&mBufferSize, NumValidatorStyle::DEFAULT, 8, 1048576 * 1)
.TieNumericTextBox(_("&Buffer Size (8 to 1048576 samples):"),
mBufferSize, mBufferSize,
12); 12);
t->SetMinSize(wxSize(100, -1)); t->SetMinSize(wxSize(100, -1));
t->SetValidator(vld);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }

View File

@ -240,20 +240,19 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S)
{ {
S.SetStretchyCol(2); S.SetStretchyCol(2);
FloatingPointValidator<double> vldfreq(5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO); mFreqT = S.Id(ID_Freq)
vldfreq.SetRange(MIN_Freq, MAX_Freq); .Validator<FloatingPointValidator<double>>(
mFreqT = S.Id(ID_Freq).AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 12); 5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Freq, MAX_Freq)
mFreqT->SetValidator(vldfreq); .AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mFreqS = S.Id(ID_Freq).AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, MIN_Freq * SCL_Freq); mFreqS = S.Id(ID_Freq).AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, MIN_Freq * SCL_Freq);
mFreqS->SetName(_("LFO frequency in hertz")); mFreqS->SetName(_("LFO frequency in hertz"));
mFreqS->SetMinSize(wxSize(100, -1)); mFreqS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldphase(1, &mPhase); mPhaseT = S.Id(ID_Phase)
vldphase.SetRange(MIN_Phase, MAX_Phase); .Validator<FloatingPointValidator<double>>(
mPhaseT = S.Id(ID_Phase).AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 12); 1, &mPhase, NumValidatorStyle::DEFAULT, MIN_Phase, MAX_Phase)
mPhaseT->SetValidator(vldphase); .AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mPhaseS = S.Id(ID_Phase).AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase); mPhaseS = S.Id(ID_Phase).AddSlider( {}, DEF_Phase * SCL_Phase, MAX_Phase * SCL_Phase, MIN_Phase * SCL_Phase);
@ -261,40 +260,40 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S)
mPhaseS->SetLineSize(10); mPhaseS->SetLineSize(10);
mPhaseS->SetMinSize(wxSize(100, -1)); mPhaseS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vlddepth(&mDepth); mDepthT = S.Id(ID_Depth)
vlddepth.SetRange(MIN_Depth, MAX_Depth); .Validator<IntegerValidator<int>>(
mDepthT = S.Id(ID_Depth).AddTextBox(_("Dept&h (%):"), wxT(""), 12); &mDepth, NumValidatorStyle::DEFAULT, MIN_Depth, MAX_Depth)
mDepthT->SetValidator(vlddepth); .AddTextBox(_("Dept&h (%):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth); mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth);
mDepthS->SetName(_("Depth in percent")); mDepthS->SetName(_("Depth in percent"));
mDepthS->SetMinSize(wxSize(100, -1)); mDepthS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldres(1, &mRes); mResT = S.Id(ID_Res)
vldres.SetRange(MIN_Res, MAX_Res); .Validator<FloatingPointValidator<double>>(
mResT = S.Id(ID_Res).AddTextBox(_("Reso&nance:"), wxT(""), 12); 1, &mRes, NumValidatorStyle::DEFAULT, MIN_Res, MAX_Res)
mResT->SetValidator(vldres); .AddTextBox(_("Reso&nance:"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mResS = S.Id(ID_Res).AddSlider( {}, DEF_Res * SCL_Res, MAX_Res * SCL_Res, MIN_Res * SCL_Res); mResS = S.Id(ID_Res).AddSlider( {}, DEF_Res * SCL_Res, MAX_Res * SCL_Res, MIN_Res * SCL_Res);
mResS->SetName(_("Resonance")); mResS->SetName(_("Resonance"));
mResS->SetMinSize(wxSize(100, -1)); mResS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldfreqoffset(&mFreqOfs); mFreqOfsT = S.Id(ID_FreqOfs)
vldfreqoffset.SetRange(MIN_FreqOfs, MAX_FreqOfs); .Validator<IntegerValidator<int>>(
mFreqOfsT = S.Id(ID_FreqOfs).AddTextBox(_("Wah Frequency Offse&t (%):"), wxT(""), 12); &mFreqOfs, NumValidatorStyle::DEFAULT, MIN_FreqOfs, MAX_FreqOfs)
mFreqOfsT->SetValidator(vldfreqoffset); .AddTextBox(_("Wah Frequency Offse&t (%):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mFreqOfsS = S.Id(ID_FreqOfs).AddSlider( {}, DEF_FreqOfs * SCL_FreqOfs, MAX_FreqOfs * SCL_FreqOfs, MIN_FreqOfs * SCL_FreqOfs); mFreqOfsS = S.Id(ID_FreqOfs).AddSlider( {}, DEF_FreqOfs * SCL_FreqOfs, MAX_FreqOfs * SCL_FreqOfs, MIN_FreqOfs * SCL_FreqOfs);
mFreqOfsT->SetName(_("Wah frequency offset in percent")); mFreqOfsT->SetName(_("Wah frequency offset in percent"));
mFreqOfsT->SetMinSize(wxSize(100, -1)); mFreqOfsT->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldoutgain(1, &mOutGain); mOutGainT = S.Id(ID_OutGain)
vldoutgain.SetRange(MIN_OutGain, MAX_OutGain); .Validator<FloatingPointValidator<double>>(
mOutGainT = S.Id(ID_OutGain).AddTextBox(_("&Output gain (dB):"), wxT(""), 12); 1, &mOutGain, NumValidatorStyle::DEFAULT, MIN_OutGain, MAX_OutGain)
mOutGainT->SetValidator(vldoutgain); .AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL); S.SetStyle(wxSL_HORIZONTAL);
mOutGainS = S.Id(ID_OutGain).AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain); mOutGainS = S.Id(ID_OutGain).AddSlider( {}, DEF_OutGain * SCL_OutGain, MAX_OutGain * SCL_OutGain, MIN_OutGain * SCL_OutGain);

View File

@ -2635,8 +2635,9 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
{ {
S.AddSpace(10, 10); S.AddSpace(10, 10);
wxTextCtrl *item = S.Id(ID_Text + i).AddTextBox( {}, wxT(""), 12); auto item = S.Id(ID_Text + i)
item->SetValidator(wxGenericValidator(&ctrl.valStr)); .Validator<wxGenericValidator>(&ctrl.valStr)
.AddTextBox( {}, wxT(""), 12);
item->SetName(prompt); item->SetName(prompt);
} }
else if (ctrl.type == NYQ_CTRL_CHOICE) else if (ctrl.type == NYQ_CTRL_CHOICE)
@ -2702,33 +2703,32 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
S.AddSpace(10, 10); S.AddSpace(10, 10);
} }
wxTextCtrl *item = S.Id(ID_Text+i).AddTextBox( {}, wxT(""), S.Id(ID_Text+i);
(ctrl.type == NYQ_CTRL_INT_TEXT ||
ctrl.type == NYQ_CTRL_FLOAT_TEXT) ? 25 : 12);
item->SetName(prompt);
double range = ctrl.high - ctrl.low;
if (ctrl.type == NYQ_CTRL_FLOAT || ctrl.type == NYQ_CTRL_FLOAT_TEXT) if (ctrl.type == NYQ_CTRL_FLOAT || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
{ {
double range = ctrl.high - ctrl.low;
S.Validator<FloatingPointValidator<double>>(
// > 12 decimal places can cause rounding errors in display. // > 12 decimal places can cause rounding errors in display.
FloatingPointValidator<double> vld(12, &ctrl.val); 12, &ctrl.val,
vld.SetRange(ctrl.low, ctrl.high);
// Set number of decimal places // Set number of decimal places
auto style = range < 10 ? NumValidatorStyle::THREE_TRAILING_ZEROES : (range < 10
range < 100 ? NumValidatorStyle::TWO_TRAILING_ZEROES : ? NumValidatorStyle::THREE_TRAILING_ZEROES
NumValidatorStyle::ONE_TRAILING_ZERO; : range < 100
vld.SetStyle(style); ? NumValidatorStyle::TWO_TRAILING_ZEROES
: NumValidatorStyle::ONE_TRAILING_ZERO),
item->SetValidator(vld); ctrl.low, ctrl.high
);
} }
else else
{ {
IntegerValidator<double> vld(&ctrl.val); S.Validator<IntegerValidator<double>>(
vld.SetRange((int) ctrl.low, (int) ctrl.high); &ctrl.val, NumValidatorStyle::DEFAULT,
item->SetValidator(vld); (int) ctrl.low, (int) ctrl.high);
} }
wxTextCtrl *item = S.AddTextBox( {}, wxT(""),
(ctrl.type == NYQ_CTRL_INT_TEXT ||
ctrl.type == NYQ_CTRL_FLOAT_TEXT) ? 25 : 12);
item->SetName(prompt);
if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_FLOAT) if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_FLOAT)
{ {

View File

@ -657,19 +657,21 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
else else
{ {
mValues[p] = value; mValues[p] = value;
FloatingPointValidator<float> vld(6, &mValues[p]);
vld.SetRange(mParameters[p].minValue, mParameters[p].maxValue);
float range = mParameters[p].maxValue - mParameters[p].minValue; float range = mParameters[p].maxValue - mParameters[p].minValue;
auto style = range < 10 ? NumValidatorStyle::THREE_TRAILING_ZEROES :
range < 100 ? NumValidatorStyle::TWO_TRAILING_ZEROES :
NumValidatorStyle::ONE_TRAILING_ZERO;
vld.SetStyle(style);
S.Id(ID_Texts + p); S.Id(ID_Texts + p);
mFields[p] = S.AddTextBox( {}, wxT(""), 12); mFields[p] = S
.Validator<FloatingPointValidator<float>>(
6, &mValues[p],
(range < 10
? NumValidatorStyle::THREE_TRAILING_ZEROES
: range < 100
? NumValidatorStyle::TWO_TRAILING_ZEROES
: NumValidatorStyle::ONE_TRAILING_ZERO),
mParameters[p].minValue, mParameters[p].maxValue)
.AddTextBox( {}, wxT(""), 12);
mFields[p]->SetName(labelText); mFields[p]->SetName(labelText);
mFields[p]->SetValidator(vld);
if (!tip.empty()) if (!tip.empty())
{ {
mFields[p]->SetToolTip(tip); mFields[p]->SetToolTip(tip);

View File

@ -280,10 +280,8 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
S.StartVerticalLay(); S.StartVerticalLay();
{ {
mTextCtrl = S.AddTextBox( {}, mTextCtrl = S.Validator<wxTextValidator>(wxFILTER_NUMERIC)
wxEmptyString, .AddTextBox( {}, wxEmptyString, 15);
15);
mTextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
mSlider = safenew ASlider(this, mSlider = safenew ASlider(this,
wxID_ANY, wxID_ANY,

View File

@ -2005,14 +2005,14 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
S.AddFixedText(_("Higher refresh rates make the meter show more frequent\nchanges. A rate of 30 per second or less should prevent\nthe meter affecting audio quality on slower machines.")); S.AddFixedText(_("Higher refresh rates make the meter show more frequent\nchanges. A rate of 30 per second or less should prevent\nthe meter affecting audio quality on slower machines."));
S.StartHorizontalLay(); S.StartHorizontalLay();
{ {
rate = S.AddTextBox(_("Meter refresh rate per second [1-100]: "), rate = S
.Validator<IntegerValidator<long>>(
&mMeterRefreshRate, NumValidatorStyle::DEFAULT,
MIN_REFRESH_RATE, MAX_REFRESH_RATE)
.AddTextBox(_("Meter refresh rate per second [1-100]: "),
wxString::Format(wxT("%d"), meterRefreshRate), wxString::Format(wxT("%d"), meterRefreshRate),
10); 10);
rate->SetName(_("Meter refresh rate per second [1-100]")); rate->SetName(_("Meter refresh rate per second [1-100]"));
IntegerValidator<long> vld(&mMeterRefreshRate);
vld.SetRange(MIN_REFRESH_RATE, MAX_REFRESH_RATE);
rate->SetValidator(vld);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }

View File

@ -551,4 +551,9 @@ bool FloatingPointValidatorBase::ValidatePrecision(const wxString& s) const
return ( (int)(posExp - posSep) - 1 <= (int)m_precision ); return ( (int)(posExp - posSep) - 1 <= (int)m_precision );
} }
double RoundValue(int precision, double value)
{
return Internat::CompatibleToDouble( Internat::ToString(value, precision) );
}
#endif // wxUSE_VALIDATORS && wxUSE_TEXTCTRL #endif // wxUSE_VALIDATORS && wxUSE_TEXTCTRL

View File

@ -505,6 +505,10 @@ MakeFloatingPointValidator(int precision, T *value, NumValidatorStyle style = Nu
return FloatingPointValidator<T>(precision, value, style); return FloatingPointValidator<T>(precision, value, style);
} }
// Sometimes useful for specifying max and min values for validators, when they
// must have the same precision as the validated value
double RoundValue(int precision, double value);
#endif // wxUSE_VALIDATORS #endif // wxUSE_VALIDATORS
#endif // _WIDGETS_VALNUM_H_ #endif // _WIDGETS_VALNUM_H_