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()
{
ShuttleGui S(this, eIsCreating);
wxControl *item;
// Strings don't need to be translated because this class doesn't
// ever get used in a stable release.
@ -171,47 +170,47 @@ void BenchmarkDialog::MakeBenchmarkDialog()
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(""),
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(""),
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(""),
12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mDataSizeStr));
///
/* i18n-hint: A "seed" is a number that initializes a
pseudorandom number generating algorithm */
item = S.Id(RandSeedID).AddTextBox(_("Random Seed:"),
S.Id(RandSeedID)
.Validator<wxTextValidator>(wxFILTER_NUMERIC, &mRandSeedStr)
/* i18n-hint: A "seed" is a number that initializes a
pseudorandom number generating algorithm */
.AddTextBox(_("Random Seed:"),
wxT(""),
12);
item->SetValidator(wxTextValidator(wxFILTER_NUMERIC,
&mRandSeedStr));
}
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);
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);
item->SetValidator(wxGenericValidator(&mEditDetail));
//
mText = S.Id(StaticTextID).AddTextWindow(wxT(""));

View File

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

View File

@ -123,6 +123,24 @@ namespace DialogDefinition {
struct Item {
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:
ShuttleGui & Optional( bool & bVar );
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().
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);

View File

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

View File

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

View File

@ -227,21 +227,21 @@ void EffectBassTreble::PopulateOrExchange(ShuttleGui & S)
S.SetStretchyCol(2);
// Bass control
FloatingPointValidator<double> vldBass(1, &mBass);
vldBass.SetRange(MIN_Bass, MAX_Bass);
mBassT = S.Id(ID_Bass).AddTextBox(_("Ba&ss (dB):"), wxT(""), 10);
mBassT = S.Id(ID_Bass)
.Validator<FloatingPointValidator<double>>(
1, &mBass, NumValidatorStyle::DEFAULT, MIN_Bass, MAX_Bass)
.AddTextBox(_("Ba&ss (dB):"), wxT(""), 10);
mBassT->SetName(_("Bass (dB):"));
mBassT->SetValidator(vldBass);
S.SetStyle(wxSL_HORIZONTAL);
mBassS = S.Id(ID_Bass).AddSlider( {}, 0, MAX_Bass * SCL_Bass, MIN_Bass * SCL_Bass);
mBassS->SetName(_("Bass"));
// Treble control
FloatingPointValidator<double> vldTreble(1, &mTreble);
vldTreble.SetRange(MIN_Treble, MAX_Treble);
mTrebleT = S.Id(ID_Treble).AddTextBox(_("&Treble (dB):"), wxT(""), 10);
mTrebleT->SetValidator(vldTreble);
mTrebleT = S.Id(ID_Treble)
.Validator<FloatingPointValidator<double>>(
1, &mTreble, NumValidatorStyle::DEFAULT, MIN_Treble, MAX_Treble)
.AddTextBox(_("&Treble (dB):"), wxT(""), 10);
S.SetStyle(wxSL_HORIZONTAL);
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);
// Gain control
FloatingPointValidator<double> vldGain(1, &mGain);
vldGain.SetRange(MIN_Gain, MAX_Gain);
mGainT = S.Id(ID_Gain).AddTextBox(_("&Volume (dB):"), wxT(""), 10);
mGainT->SetValidator(vldGain);
mGainT = S.Id(ID_Gain)
.Validator<FloatingPointValidator<double>>(
1, &mGain, NumValidatorStyle::DEFAULT, MIN_Gain, MAX_Gain)
.AddTextBox(_("&Volume (dB):"), wxT(""), 10);
S.SetStyle(wxSL_HORIZONTAL);
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);
{
FloatingPointValidator<double> vldSemitones(2, &m_dSemitonesChange, NumValidatorStyle::TWO_TRAILING_ZEROES);
m_pTextCtrl_SemitonesChange =
S.Id(ID_SemitonesChange).AddTextBox(_("Semitones (half-steps):"), wxT(""), 12);
m_pTextCtrl_SemitonesChange = S.Id(ID_SemitonesChange)
.Validator<FloatingPointValidator<double>>(
2, &m_dSemitonesChange,
NumValidatorStyle::TWO_TRAILING_ZEROES
)
.AddTextBox(_("Semitones (half-steps):"), wxT(""), 12);
m_pTextCtrl_SemitonesChange->SetName(_("Semitones (half-steps)"));
m_pTextCtrl_SemitonesChange->SetValidator(vldSemitones);
}
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.
{
FloatingPointValidator<double> vldFromFrequency(3, &m_FromFrequency, NumValidatorStyle::THREE_TRAILING_ZEROES);
vldFromFrequency.SetMin(0.0);
m_pTextCtrl_FromFrequency = S.Id(ID_FromFrequency).AddTextBox(_("from"), wxT(""), 12);
m_pTextCtrl_FromFrequency = S.Id(ID_FromFrequency)
.Validator<FloatingPointValidator<double>>(
3, &m_FromFrequency,
NumValidatorStyle::THREE_TRAILING_ZEROES,
0.0
)
.AddTextBox(_("from"), wxT(""), 12);
m_pTextCtrl_FromFrequency->SetName(_("from (Hz)"));
m_pTextCtrl_FromFrequency->SetValidator(vldFromFrequency);
FloatingPointValidator<double> vldToFrequency(3, &m_ToFrequency, NumValidatorStyle::THREE_TRAILING_ZEROES);
vldToFrequency.SetMin(0.0);
m_pTextCtrl_ToFrequency = S.Id(ID_ToFrequency).AddTextBox(_("to"), wxT(""), 12);
m_pTextCtrl_ToFrequency = S.Id(ID_ToFrequency)
.Validator<FloatingPointValidator<double>>(
3, &m_ToFrequency,
NumValidatorStyle::THREE_TRAILING_ZEROES,
0.0
)
.AddTextBox(_("to"), wxT(""), 12);
m_pTextCtrl_ToFrequency->SetName(_("to (Hz)"));
m_pTextCtrl_ToFrequency->SetValidator(vldToFrequency);
S.AddUnits(_("Hz"));
}
@ -328,10 +336,13 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_CENTER);
{
FloatingPointValidator<double> vldPercentage(3, &m_dPercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES);
vldPercentage.SetRange(MIN_Percentage, MAX_Percentage);
m_pTextCtrl_PercentChange = S.Id(ID_PercentChange).AddTextBox(_("Percent Change:"), wxT(""), 12);
m_pTextCtrl_PercentChange->SetValidator(vldPercentage);
m_pTextCtrl_PercentChange = S.Id(ID_PercentChange)
.Validator<FloatingPointValidator<double>>(
3, &m_dPercentChange,
NumValidatorStyle::THREE_TRAILING_ZEROES,
MIN_Percentage, MAX_Percentage
)
.AddTextBox(_("Percent Change:"), wxT(""), 12);
}
S.EndHorizontalLay();
@ -349,9 +360,9 @@ void EffectChangePitch::PopulateOrExchange(ShuttleGui & S)
#if USE_SBSMS
S.StartMultiColumn(2);
{
mUseSBSMSCheckBox = S.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMSCheckBox = S.Validator<wxGenericValidator>(&mUseSBSMS)
.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMS);
mUseSBSMSCheckBox->SetValidator(wxGenericValidator(&mUseSBSMS));
}
S.EndMultiColumn();
#endif

View File

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

View File

@ -232,11 +232,12 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
//
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)
.Validator<FloatingPointValidator<double>>(
3, &m_PercentChange, NumValidatorStyle::THREE_TRAILING_ZEROES,
MIN_Percentage, MAX_Percentage
)
.AddTextBox(_("Percent Change:"), wxT(""), 12);
m_pTextCtrl_PercentChange->SetValidator(vldPercentage);
}
S.EndMultiColumn();
@ -254,17 +255,23 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
{
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)
.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);
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)
.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);
m_pTextCtrl_ToBPM->SetName(_("Beats per minute, to"));
m_pTextCtrl_ToBPM->SetValidator(vldToBPM);
}
S.EndHorizontalLay();
}
@ -275,24 +282,25 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
{
S.StartHorizontalLay(wxALIGN_CENTER);
{
FloatingPointValidator<double> vldFromLength(precision, &m_FromLength, NumValidatorStyle::TWO_TRAILING_ZEROES);
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);
m_pTextCtrl_FromLength->SetValidator(vldFromLength);
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)
.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);
m_pTextCtrl_ToLength->SetValidator(vldToLength);
}
S.EndHorizontalLay();
}
@ -301,9 +309,9 @@ void EffectChangeTempo::PopulateOrExchange(ShuttleGui & S)
#if USE_SBSMS
S.StartMultiColumn(2);
{
mUseSBSMSCheckBox = S.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMSCheckBox = S.Validator<wxGenericValidator>(&mUseSBSMS)
.AddCheckBox(_("Use high quality stretching (slow)"),
mUseSBSMS);
mUseSBSMSCheckBox->SetValidator(wxGenericValidator(&mUseSBSMS));
}
S.EndMultiColumn();
#endif

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -100,7 +100,6 @@ private:
wxStaticText *mLeveldB;
wxStaticText *mWarning;
wxCheckBox *mStereoIndCheckBox;
wxChoice *mNormalizeToCtl;
wxCheckBox *mDualMonoCheckBox;
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
.AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes))
->SetValidator(wxGenericValidator(&mType));
S.Validator<wxGenericValidator>(&mType)
.AddChoice(_("Noise type:"), LocalizedStrings(kTypeStrings, nTypes));
FloatingPointValidator<double> vldAmp(6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES);
vldAmp.SetRange(MIN_Amp, MAX_Amp);
S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp);
S.Validator<FloatingPointValidator<double>>(
6, &mAmp, NumValidatorStyle::NO_TRAILING_ZEROES, MIN_Amp, MAX_Amp
)
.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12);
S.AddPrompt(_("Duration:"));
mNoiseDurationT = safenew

View File

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

View File

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

View File

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

View File

@ -194,18 +194,17 @@ void EffectPaulstretch::PopulateOrExchange(ShuttleGui & S)
{
S.StartMultiColumn(2, wxALIGN_CENTER);
{
FloatingPointValidator<float> vldAmount(1, &mAmount);
vldAmount.SetMin(MIN_Amount);
S.Validator<FloatingPointValidator<float>>(
1, &mAmount, NumValidatorStyle::DEFAULT, MIN_Amount)
/* 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
* will give an (approximately) 10 second sound
*/
.AddTextBox(_("Stretch Factor:"), wxT(""), 10);
/* 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
* will give an (approximately) 10 second sound
*/
S.AddTextBox(_("Stretch Factor:"), wxT(""), 10)->SetValidator(vldAmount);
FloatingPointValidator<float> vldTime(3, &mTime_resolution, NumValidatorStyle::ONE_TRAILING_ZERO);
vldTime.SetMin(MIN_Time);
S.AddTextBox(_("Time Resolution (seconds):"), wxT(""), 10)->SetValidator(vldTime);
S.Validator<FloatingPointValidator<float>>(
3, &mTime_resolution, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Time)
.AddTextBox(_("Time Resolution (seconds):"), wxT(""), 10);
}
S.EndMultiColumn();
};

View File

@ -256,10 +256,10 @@ void EffectPhaser::PopulateOrExchange(ShuttleGui & S)
{
S.SetStretchyCol(2);
IntegerValidator<int> vldStages(&mStages);
vldStages.SetRange(MIN_Stages, MAX_Stages);
mStagesT = S.Id(ID_Stages).AddTextBox(_("&Stages:"), wxT(""), 15);
mStagesT->SetValidator(vldStages);
mStagesT = S.Id(ID_Stages)
.Validator<IntegerValidator<int>>(
&mStages, NumValidatorStyle::DEFAULT, MIN_Stages, MAX_Stages)
.AddTextBox(_("&Stages:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldDryWet(&mDryWet);
vldDryWet.SetRange(MIN_DryWet, MAX_DryWet);
mDryWetT = S.Id(ID_DryWet).AddTextBox(_("&Dry/Wet:"), wxT(""), 15);
mDryWetT->SetValidator(vldDryWet);
mDryWetT = S.Id(ID_DryWet)
.Validator<IntegerValidator<int>>(
&mDryWet, NumValidatorStyle::DEFAULT, MIN_DryWet, MAX_DryWet)
.AddTextBox(_("&Dry/Wet:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
mDryWetS = S.Id(ID_DryWet).AddSlider( {}, DEF_DryWet * SCL_DryWet, MAX_DryWet * SCL_DryWet, MIN_DryWet * SCL_DryWet);
mDryWetS->SetName(_("Dry Wet"));
mDryWetS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldFreq(5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO);
vldFreq.SetRange(MIN_Freq, MAX_Freq);
mFreqT = S.Id(ID_Freq).AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 15);
mFreqT->SetValidator(vldFreq);
mFreqT = S.Id(ID_Freq)
.Validator<FloatingPointValidator<double>>(
5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Freq, MAX_Freq)
.AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
mFreqS = S.Id(ID_Freq).AddSlider( {}, DEF_Freq * SCL_Freq, MAX_Freq * SCL_Freq, 0.0);
mFreqS ->SetName(_("LFO frequency in hertz"));
mFreqS ->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldPhase(1, &mPhase);
vldPhase.SetRange(MIN_Phase, MAX_Phase);
mPhaseT = S.Id(ID_Phase).AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 15);
mPhaseT->SetValidator(vldPhase);
mPhaseT = S.Id(ID_Phase)
.Validator<FloatingPointValidator<double>>(
1, &mPhase, NumValidatorStyle::DEFAULT, MIN_Phase, MAX_Phase)
.AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldDepth(&mDepth);
vldDepth.SetRange(MIN_Depth, MAX_Depth);
mDepthT = S.Id(ID_Depth).AddTextBox(_("Dept&h:"), wxT(""), 15);
mDepthT->SetValidator(vldDepth);
mDepthT = S.Id(ID_Depth)
.Validator<IntegerValidator<int>>(
&mDepth, NumValidatorStyle::DEFAULT, MIN_Depth, MAX_Depth)
.AddTextBox(_("Dept&h:"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth);
mDepthS->SetName(_("Depth in percent"));
mDepthS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldFeedback(&mFeedback);
vldFeedback.SetRange(MIN_Feedback, MAX_Feedback);
mFeedbackT = S.Id(ID_Feedback).AddTextBox(_("Feedbac&k (%):"), wxT(""), 15);
mFeedbackT->SetValidator(vldFeedback);
mFeedbackT = S.Id(ID_Feedback)
.Validator<IntegerValidator<int>>(
&mFeedback, NumValidatorStyle::DEFAULT, MIN_Feedback, MAX_Feedback)
.AddTextBox(_("Feedbac&k (%):"), wxT(""), 15);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldoutgain(1, &mOutGain);
vldoutgain.SetRange(MIN_OutGain, MAX_OutGain);
mOutGainT = S.Id(ID_OutGain).AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
mOutGainT->SetValidator(vldoutgain);
mOutGainT = S.Id(ID_OutGain)
.Validator<FloatingPointValidator<double>>(
1, &mOutGain, NumValidatorStyle::DEFAULT, MIN_OutGain, MAX_OutGain)
.AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
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);
{
IntegerValidator<int> vldRepeatCount(&repeatCount);
vldRepeatCount.SetRange(MIN_Count, 2147483647 / mProjectRate);
mRepeatCount = S.AddTextBox(_("Number of repeats to add:"), wxT(""), 12);
mRepeatCount->SetValidator(vldRepeatCount);
mRepeatCount = S.Validator<IntegerValidator<int>>(
&repeatCount, NumValidatorStyle::DEFAULT,
MIN_Count, 2147483647 / mProjectRate
)
.AddTextBox(_("Number of repeats to add:"), wxT(""), 12);
}
S.EndHorizontalLay();

View File

@ -456,13 +456,14 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
wxASSERT(nTypes == WXSIZEOF(kTypeStrings));
mFilterTypeCtl = S.Id(ID_Type)
.Validator<wxGenericValidator>(&mFilterType)
.AddChoice(_("&Filter Type:"),
LocalizedStrings(kTypeStrings, nTypes)
);
mFilterTypeCtl->SetValidator(wxGenericValidator(&mFilterType));
S.SetSizeHints(-1, -1);
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.*/
.AddChoice(_("O&rder:"),
[]{
@ -472,41 +473,40 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
return orders;
}()
);
mFilterOrderCtl->SetValidator(wxGenericValidator(&mOrderIndex));
S.SetSizeHints(-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);
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->SetValidator(vldRipple);
mRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
mFilterSubTypeCtl = S.Id(ID_SubType)
.Validator<wxGenericValidator>(&mFilterSubtype)
.AddChoice(_("&Subtype:"),
LocalizedStrings(kSubTypeStrings, nSubTypes)
);
mFilterSubTypeCtl->SetValidator(wxGenericValidator(&mFilterSubtype));
S.SetSizeHints(-1, -1);
FloatingPointValidator<float> vldCutoff(1, &mCutoff);
vldCutoff.SetRange(MIN_Cutoff, mNyquist - 1);
mCutoffCtl = S.Id(ID_Cutoff).AddTextBox(_("C&utoff:"), wxT(""), 10);
mCutoffCtl = S.Id(ID_Cutoff)
.Validator<FloatingPointValidator<float>>(
1, &mCutoff, NumValidatorStyle::DEFAULT,
MIN_Cutoff, mNyquist - 1)
.AddTextBox(_("C&utoff:"), wxT(""), 10);
mCutoffCtl->SetName(_("Cutoff (Hz)"));
mCutoffCtl->SetValidator(vldCutoff);
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);
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->SetValidator(vldStopbandRipple);
mStopbandRippleCtlU = S.AddVariableText(_("dB"), false, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
}
S.EndMultiColumn();

View File

@ -206,13 +206,13 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{
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)
.Validator<FloatingPointValidator<double>>(
3, &m_RatePercentChangeStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_RatePercentStart, MAX_RatePercentStart
)
.AddTextBox( {}, wxT(""), 12);
m_pTextCtrl_RatePercentChangeStart->SetValidator(vldRatePercentChangeStart);
}
S.EndMultiColumn();
S.StartHorizontalLay(wxEXPAND, 0);
@ -229,13 +229,13 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{
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)
.Validator<FloatingPointValidator<double>>(
3, &m_RatePercentChangeEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_RatePercentEnd, MAX_RatePercentEnd
)
.AddTextBox( {}, wxT(""), 12);
m_pTextCtrl_RatePercentChangeEnd->SetValidator(vldRatePercentChangeEnd);
}
S.EndMultiColumn();
S.StartHorizontalLay(wxEXPAND, 0);
@ -253,21 +253,22 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{
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)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchHalfStepsStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_HalfStepsStart, MAX_HalfStepsStart
)
.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)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchPercentChangeStart,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_PitchPercentStart, MAX_PitchPercentStart
)
.AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12);
m_pTextCtrl_PitchPercentChangeStart->SetValidator(vldPitchPercentChangeStart);
}
S.EndMultiColumn();
}
@ -278,21 +279,20 @@ void EffectTimeScale::PopulateOrExchange(ShuttleGui & S)
{
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)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchHalfStepsEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_HalfStepsEnd, MAX_HalfStepsEnd
)
.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)
.Validator<FloatingPointValidator<double>>(
3, &m_PitchPercentChangeEnd,
NumValidatorStyle::NO_TRAILING_ZEROES,
MIN_PitchPercentStart, MAX_PitchPercentStart)
.AddTextBox(_("(%) [-50 to 100]:"), wxT(""), 12);
m_pTextCtrl_PitchPercentChangeEnd->SetValidator(vldPitchPercentChangeEnd);
}
S.EndMultiColumn();
}

View File

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

View File

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

View File

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

View File

@ -239,21 +239,20 @@ void EffectWahwah::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(3, wxEXPAND);
{
S.SetStretchyCol(2);
FloatingPointValidator<double> vldfreq(5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO);
vldfreq.SetRange(MIN_Freq, MAX_Freq);
mFreqT = S.Id(ID_Freq).AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 12);
mFreqT->SetValidator(vldfreq);
mFreqT = S.Id(ID_Freq)
.Validator<FloatingPointValidator<double>>(
5, &mFreq, NumValidatorStyle::ONE_TRAILING_ZERO, MIN_Freq, MAX_Freq)
.AddTextBox(_("LFO Freq&uency (Hz):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldphase(1, &mPhase);
vldphase.SetRange(MIN_Phase, MAX_Phase);
mPhaseT = S.Id(ID_Phase).AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 12);
mPhaseT->SetValidator(vldphase);
mPhaseT = S.Id(ID_Phase)
.Validator<FloatingPointValidator<double>>(
1, &mPhase, NumValidatorStyle::DEFAULT, MIN_Phase, MAX_Phase)
.AddTextBox(_("LFO Sta&rt Phase (deg.):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vlddepth(&mDepth);
vlddepth.SetRange(MIN_Depth, MAX_Depth);
mDepthT = S.Id(ID_Depth).AddTextBox(_("Dept&h (%):"), wxT(""), 12);
mDepthT->SetValidator(vlddepth);
mDepthT = S.Id(ID_Depth)
.Validator<IntegerValidator<int>>(
&mDepth, NumValidatorStyle::DEFAULT, MIN_Depth, MAX_Depth)
.AddTextBox(_("Dept&h (%):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
mDepthS = S.Id(ID_Depth).AddSlider( {}, DEF_Depth * SCL_Depth, MAX_Depth * SCL_Depth, MIN_Depth * SCL_Depth);
mDepthS->SetName(_("Depth in percent"));
mDepthS->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldres(1, &mRes);
vldres.SetRange(MIN_Res, MAX_Res);
mResT = S.Id(ID_Res).AddTextBox(_("Reso&nance:"), wxT(""), 12);
mResT->SetValidator(vldres);
mResT = S.Id(ID_Res)
.Validator<FloatingPointValidator<double>>(
1, &mRes, NumValidatorStyle::DEFAULT, MIN_Res, MAX_Res)
.AddTextBox(_("Reso&nance:"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
mResS = S.Id(ID_Res).AddSlider( {}, DEF_Res * SCL_Res, MAX_Res * SCL_Res, MIN_Res * SCL_Res);
mResS->SetName(_("Resonance"));
mResS->SetMinSize(wxSize(100, -1));
IntegerValidator<int> vldfreqoffset(&mFreqOfs);
vldfreqoffset.SetRange(MIN_FreqOfs, MAX_FreqOfs);
mFreqOfsT = S.Id(ID_FreqOfs).AddTextBox(_("Wah Frequency Offse&t (%):"), wxT(""), 12);
mFreqOfsT->SetValidator(vldfreqoffset);
mFreqOfsT = S.Id(ID_FreqOfs)
.Validator<IntegerValidator<int>>(
&mFreqOfs, NumValidatorStyle::DEFAULT, MIN_FreqOfs, MAX_FreqOfs)
.AddTextBox(_("Wah Frequency Offse&t (%):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
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->SetMinSize(wxSize(100, -1));
FloatingPointValidator<double> vldoutgain(1, &mOutGain);
vldoutgain.SetRange(MIN_OutGain, MAX_OutGain);
mOutGainT = S.Id(ID_OutGain).AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
mOutGainT->SetValidator(vldoutgain);
mOutGainT = S.Id(ID_OutGain)
.Validator<FloatingPointValidator<double>>(
1, &mOutGain, NumValidatorStyle::DEFAULT, MIN_OutGain, MAX_OutGain)
.AddTextBox(_("&Output gain (dB):"), wxT(""), 12);
S.SetStyle(wxSL_HORIZONTAL);
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);
wxTextCtrl *item = S.Id(ID_Text + i).AddTextBox( {}, wxT(""), 12);
item->SetValidator(wxGenericValidator(&ctrl.valStr));
auto item = S.Id(ID_Text + i)
.Validator<wxGenericValidator>(&ctrl.valStr)
.AddTextBox( {}, wxT(""), 12);
item->SetName(prompt);
}
else if (ctrl.type == NYQ_CTRL_CHOICE)
@ -2702,33 +2703,32 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
S.AddSpace(10, 10);
}
wxTextCtrl *item = S.Id(ID_Text+i).AddTextBox( {}, wxT(""),
(ctrl.type == NYQ_CTRL_INT_TEXT ||
ctrl.type == NYQ_CTRL_FLOAT_TEXT) ? 25 : 12);
item->SetName(prompt);
double range = ctrl.high - ctrl.low;
S.Id(ID_Text+i);
if (ctrl.type == NYQ_CTRL_FLOAT || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
{
// > 12 decimal places can cause rounding errors in display.
FloatingPointValidator<double> vld(12, &ctrl.val);
vld.SetRange(ctrl.low, ctrl.high);
// Set number of decimal places
auto style = range < 10 ? NumValidatorStyle::THREE_TRAILING_ZEROES :
range < 100 ? NumValidatorStyle::TWO_TRAILING_ZEROES :
NumValidatorStyle::ONE_TRAILING_ZERO;
vld.SetStyle(style);
item->SetValidator(vld);
double range = ctrl.high - ctrl.low;
S.Validator<FloatingPointValidator<double>>(
// > 12 decimal places can cause rounding errors in display.
12, &ctrl.val,
// Set number of decimal places
(range < 10
? NumValidatorStyle::THREE_TRAILING_ZEROES
: range < 100
? NumValidatorStyle::TWO_TRAILING_ZEROES
: NumValidatorStyle::ONE_TRAILING_ZERO),
ctrl.low, ctrl.high
);
}
else
{
IntegerValidator<double> vld(&ctrl.val);
vld.SetRange((int) ctrl.low, (int) ctrl.high);
item->SetValidator(vld);
S.Validator<IntegerValidator<double>>(
&ctrl.val, NumValidatorStyle::DEFAULT,
(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)
{

View File

@ -657,19 +657,21 @@ void VampEffect::PopulateOrExchange(ShuttleGui & S)
else
{
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;
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);
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]->SetValidator(vld);
if (!tip.empty())
{
mFields[p]->SetToolTip(tip);

View File

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

View File

@ -551,4 +551,9 @@ bool FloatingPointValidatorBase::ValidatePrecision(const wxString& s) const
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

View File

@ -505,6 +505,10 @@ MakeFloatingPointValidator(int precision, T *value, NumValidatorStyle style = Nu
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 // _WIDGETS_VALNUM_H_