mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-23 07:40:05 +02:00
Bug 891: Changing low or high frequency in spectral selection toolbar...
... will not change the opposite bound, but will instead be constrained by it.
This commit is contained in:
parent
9bb5ed2c06
commit
cf9851c313
@ -265,6 +265,10 @@ void SpectralSelectionBar::ModifySpectralSelection(bool done)
|
||||
top = SelectedRegion::UndefinedFrequency;
|
||||
}
|
||||
|
||||
mLow = bottom;
|
||||
mHigh = top;
|
||||
SetBounds();
|
||||
|
||||
// Notify project and track panel, which may change
|
||||
// the values again, and call back to us in SetFrequencies()
|
||||
mListener->SSBL_ModifySpectralSelection(bottom, top, done);
|
||||
@ -349,11 +353,25 @@ void SpectralSelectionBar::ValuesToControls()
|
||||
mWidthCtrl->SetValue(mWidth);
|
||||
}
|
||||
else {
|
||||
SetBounds();
|
||||
mLowCtrl->SetValue(mLow);
|
||||
mHighCtrl->SetValue(mHigh);
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetBounds()
|
||||
{
|
||||
if (mHigh >= 0)
|
||||
mLowCtrl->SetMaxValue(mHigh);
|
||||
else
|
||||
mLowCtrl->ResetMaxValue();
|
||||
|
||||
if (mLow >= 0)
|
||||
mHighCtrl->SetMinValue(mLow);
|
||||
else
|
||||
mHighCtrl->ResetMinValue();
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetFrequencies(double bottom, double top)
|
||||
{
|
||||
mLow = bottom;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
private:
|
||||
|
||||
void ValuesToControls();
|
||||
void SetBounds();
|
||||
void OnUpdate(wxCommandEvent &evt);
|
||||
void OnCtrl(wxCommandEvent &evt);
|
||||
void OnChoice(wxCommandEvent &evt);
|
||||
|
@ -531,6 +531,9 @@ NumericConverter::NumericConverter(Type type,
|
||||
double value,
|
||||
double sampleRate)
|
||||
{
|
||||
ResetMinValue();
|
||||
ResetMaxValue();
|
||||
|
||||
mDefaultNdx = 0;
|
||||
|
||||
mType = type;
|
||||
@ -904,7 +907,7 @@ void NumericConverter::ControlsToValue()
|
||||
t = frames * 1.001 / 30.;
|
||||
}
|
||||
|
||||
mValue = t;
|
||||
mValue = std::max(mMinValue, std::min(mMaxValue, t));
|
||||
}
|
||||
|
||||
void NumericConverter::SetFormatName(const wxString & formatName)
|
||||
@ -935,6 +938,35 @@ void NumericConverter::SetValue(double newValue)
|
||||
ControlsToValue();
|
||||
}
|
||||
|
||||
void NumericConverter::SetMinValue(double minValue)
|
||||
{
|
||||
mMinValue = minValue;
|
||||
if (mMaxValue < minValue)
|
||||
mMaxValue = minValue;
|
||||
if (mValue < minValue)
|
||||
SetValue(minValue);
|
||||
}
|
||||
|
||||
void NumericConverter::ResetMinValue()
|
||||
{
|
||||
mMinValue = std::numeric_limits<double>::min();
|
||||
}
|
||||
|
||||
void NumericConverter::SetMaxValue(double maxValue)
|
||||
{
|
||||
mMaxValue = maxValue;
|
||||
if (mMinValue > maxValue) {
|
||||
mMinValue = maxValue;
|
||||
}
|
||||
if (mValue > maxValue)
|
||||
SetValue(maxValue);
|
||||
}
|
||||
|
||||
void NumericConverter::ResetMaxValue()
|
||||
{
|
||||
mMaxValue = std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
double NumericConverter::GetValue()
|
||||
{
|
||||
ControlsToValue();
|
||||
@ -1073,6 +1105,8 @@ void NumericConverter::Adjust(int steps, int dir)
|
||||
mValue = 0.;
|
||||
}
|
||||
|
||||
mValue = std::max(mMinValue, std::min(mMaxValue, mValue));
|
||||
|
||||
mValue /= mScalingFactor;
|
||||
|
||||
if (!mNtscDrop)
|
||||
@ -1615,7 +1649,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event)
|
||||
if (!mReadOnly && (keyCode >= '0' && keyCode <= '9')) {
|
||||
int digitPosition = mDigits[mFocusedDigit].pos;
|
||||
if (mValueString[digitPosition] == wxChar('-')) {
|
||||
mValue = 0;
|
||||
mValue = std::max(mMinValue, std::min(mMaxValue, 0.0));
|
||||
ValueToControls();
|
||||
// Beware relocation of the string
|
||||
digitPosition = mDigits[mFocusedDigit].pos;
|
||||
|
@ -71,6 +71,10 @@ public:
|
||||
void SetFormatString(const wxString & formatString);
|
||||
void SetSampleRate(double sampleRate);
|
||||
void SetValue(double newValue);
|
||||
void SetMinValue(double minValue);
|
||||
void ResetMinValue();
|
||||
void SetMaxValue(double maxValue);
|
||||
void ResetMaxValue();
|
||||
double GetValue();
|
||||
|
||||
wxString GetString();
|
||||
@ -95,6 +99,9 @@ protected:
|
||||
|
||||
double mValue;
|
||||
|
||||
double mMinValue;
|
||||
double mMaxValue;
|
||||
|
||||
wxString mFormatString;
|
||||
|
||||
NumericFieldArray mFields;
|
||||
|
Loading…
x
Reference in New Issue
Block a user