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