mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
Rearrange setting time & freq formats for numeric controls...
... Just one low-level function for each that simply sets; just one high-level function for each that also pushes notifications; and to make that work, toolbars need some rewriting to avoid recursion when the notifications they post come back to them.
This commit is contained in:
parent
441763cabd
commit
35892fc869
@ -1574,13 +1574,15 @@ const NumericFormatSymbol & AudacityProject::AS_GetSelectionFormat()
|
||||
void AudacityProject::AS_SetSelectionFormat(const NumericFormatSymbol & format)
|
||||
{
|
||||
auto &project = *this;
|
||||
mSelectionFormat = format;
|
||||
SetSelectionFormat( format );
|
||||
|
||||
gPrefs->Write(wxT("/SelectionFormat"), mSelectionFormat.Internal());
|
||||
gPrefs->Flush();
|
||||
|
||||
if (SnapSelection())
|
||||
TrackPanel::Get( project ).Refresh(false);
|
||||
|
||||
SelectionBar::Get( project ).SetSelectionFormat(format);
|
||||
}
|
||||
|
||||
double AudacityProject::SSBL_GetRate() const
|
||||
@ -1599,11 +1601,17 @@ const NumericFormatSymbol & AudacityProject::SSBL_GetFrequencySelectionFormatNam
|
||||
|
||||
void AudacityProject::SSBL_SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
mFrequencySelectionFormatName = formatName;
|
||||
auto &project = *this;
|
||||
|
||||
SetFrequencySelectionFormatName( formatName );
|
||||
|
||||
gPrefs->Write(wxT("/FrequencySelectionFormatName"),
|
||||
mFrequencySelectionFormatName.Internal());
|
||||
gPrefs->Flush();
|
||||
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
SpectralSelectionBar::Get( project ).SetFrequencySelectionFormatName(formatName);
|
||||
#endif
|
||||
}
|
||||
|
||||
const NumericFormatSymbol & AudacityProject::SSBL_GetBandwidthSelectionFormatName()
|
||||
@ -1613,11 +1621,17 @@ const NumericFormatSymbol & AudacityProject::SSBL_GetBandwidthSelectionFormatNam
|
||||
|
||||
void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
mBandwidthSelectionFormatName = formatName;
|
||||
auto &project = *this;
|
||||
|
||||
SetBandwidthSelectionFormatName( formatName );
|
||||
|
||||
gPrefs->Write(wxT("/BandwidthSelectionFormatName"),
|
||||
mBandwidthSelectionFormatName.Internal());
|
||||
gPrefs->Flush();
|
||||
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
SpectralSelectionBar::Get( project ).SetBandwidthSelectionFormatName(formatName);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AudacityProject::SSBL_ModifySpectralSelection(double &bottom, double &top, bool done)
|
||||
@ -1649,11 +1663,7 @@ const NumericFormatSymbol & AudacityProject::GetFrequencySelectionFormatName() c
|
||||
|
||||
void AudacityProject::SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
auto &project = *this;
|
||||
SSBL_SetFrequencySelectionFormatName(formatName);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
SpectralSelectionBar::Get( project ).SetFrequencySelectionFormatName(formatName);
|
||||
#endif
|
||||
mFrequencySelectionFormatName = formatName;
|
||||
}
|
||||
|
||||
const NumericFormatSymbol & AudacityProject::GetBandwidthSelectionFormatName() const
|
||||
@ -1663,18 +1673,12 @@ const NumericFormatSymbol & AudacityProject::GetBandwidthSelectionFormatName() c
|
||||
|
||||
void AudacityProject::SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
auto &project = *this;
|
||||
SSBL_SetBandwidthSelectionFormatName(formatName);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
SpectralSelectionBar::Get( project ).SetBandwidthSelectionFormatName(formatName);
|
||||
#endif
|
||||
mBandwidthSelectionFormatName = formatName;
|
||||
}
|
||||
|
||||
void AudacityProject::SetSelectionFormat(const NumericFormatSymbol & format)
|
||||
{
|
||||
auto &project = *this;
|
||||
AS_SetSelectionFormat(format);
|
||||
SelectionBar::Get( project ).SetSelectionFormat(format);
|
||||
mSelectionFormat = format;
|
||||
}
|
||||
|
||||
const NumericFormatSymbol & AudacityProject::GetSelectionFormat() const
|
||||
@ -3496,15 +3500,15 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("selectionformat")))
|
||||
SetSelectionFormat(
|
||||
AS_SetSelectionFormat(
|
||||
NumericConverter::LookupFormat( NumericConverter::TIME, value) );
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("frequencyformat")))
|
||||
SetFrequencySelectionFormatName(
|
||||
SSBL_SetFrequencySelectionFormatName(
|
||||
NumericConverter::LookupFormat( NumericConverter::FREQUENCY, value ) );
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("bandwidthformat")))
|
||||
SetBandwidthSelectionFormatName(
|
||||
SSBL_SetBandwidthSelectionFormatName(
|
||||
NumericConverter::LookupFormat( NumericConverter::BANDWIDTH, value ) );
|
||||
} // while
|
||||
|
||||
|
@ -306,10 +306,6 @@ class AUDACITY_DLL_API TrackPanel final
|
||||
|
||||
void DisplaySelection();
|
||||
|
||||
// These two are neither used nor defined as of Nov-2011
|
||||
// void SetSelectionFormat(int iformat)
|
||||
// void SetSnapTo(int snapto)
|
||||
|
||||
void HandlePageUpKey();
|
||||
void HandlePageDownKey();
|
||||
AudacityProject * GetProject() const override;
|
||||
|
@ -666,11 +666,15 @@ void SelectionBar::SetSnapTo(int snap)
|
||||
|
||||
void SelectionBar::SetSelectionFormat(const NumericFormatSymbol & format)
|
||||
{
|
||||
mStartTime->SetFormatString(mStartTime->GetBuiltinFormat(format));
|
||||
bool changed =
|
||||
mStartTime->SetFormatString(mStartTime->GetBuiltinFormat(format));
|
||||
|
||||
wxCommandEvent e;
|
||||
e.SetInt(mStartTime->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
// Test first whether changed, to avoid infinite recursion from OnUpdate
|
||||
if ( changed ) {
|
||||
wxCommandEvent e;
|
||||
e.SetInt(mStartTime->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionBar::SetRate(double rate)
|
||||
|
@ -467,21 +467,27 @@ void SpectralSelectionBar::SetFrequencies(double bottom, double top)
|
||||
void SpectralSelectionBar::SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
|
||||
frequencyCtrl->SetFormatName(formatName);
|
||||
|
||||
wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
|
||||
e.SetInt(frequencyCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
bool changed =
|
||||
frequencyCtrl->SetFormatName(formatName);
|
||||
// Test first whether changed, to avoid infinite recursion from OnUpdate
|
||||
if (changed) {
|
||||
wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
|
||||
e.SetInt(frequencyCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
if (mbCenterAndWidth) {
|
||||
mWidthCtrl->SetFormatName(formatName);
|
||||
|
||||
wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
|
||||
e.SetInt(mWidthCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
bool changed =
|
||||
mWidthCtrl->SetFormatName(formatName);
|
||||
// Test first whether changed, to avoid infinite recursion from OnUpdate
|
||||
if (changed) {
|
||||
wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
|
||||
e.SetInt(mWidthCtrl->GetFormatIndex());
|
||||
OnUpdate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1051,17 +1051,23 @@ void NumericConverter::ControlsToValue()
|
||||
mValue = std::max(mMinValue, std::min(mMaxValue, t));
|
||||
}
|
||||
|
||||
void NumericConverter::SetFormatName(const NumericFormatSymbol & formatName)
|
||||
bool NumericConverter::SetFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
return
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
}
|
||||
|
||||
void NumericConverter::SetFormatString(const wxString & formatString)
|
||||
bool NumericConverter::SetFormatString(const wxString & formatString)
|
||||
{
|
||||
mFormatString = formatString;
|
||||
ParseFormatString(mFormatString);
|
||||
ValueToControls();
|
||||
ControlsToValue();
|
||||
if (mFormatString != formatString) {
|
||||
mFormatString = formatString;
|
||||
ParseFormatString(mFormatString);
|
||||
ValueToControls();
|
||||
ControlsToValue();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void NumericConverter::SetSampleRate(double sampleRate)
|
||||
@ -1366,19 +1372,24 @@ void NumericTextCtrl::UpdateAutoFocus()
|
||||
}
|
||||
}
|
||||
|
||||
void NumericTextCtrl::SetFormatName(const NumericFormatSymbol & formatName)
|
||||
bool NumericTextCtrl::SetFormatName(const NumericFormatSymbol & formatName)
|
||||
{
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
return
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
}
|
||||
|
||||
void NumericTextCtrl::SetFormatString(const wxString & formatString)
|
||||
bool NumericTextCtrl::SetFormatString(const wxString & formatString)
|
||||
{
|
||||
NumericConverter::SetFormatString(formatString);
|
||||
Layout();
|
||||
Fit();
|
||||
ValueToControls();
|
||||
ControlsToValue();
|
||||
UpdateAutoFocus();
|
||||
auto result =
|
||||
NumericConverter::SetFormatString(formatString);
|
||||
if (result) {
|
||||
Layout();
|
||||
Fit();
|
||||
ValueToControls();
|
||||
ControlsToValue();
|
||||
UpdateAutoFocus();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void NumericTextCtrl::SetSampleRate(double sampleRate)
|
||||
|
@ -83,8 +83,13 @@ private:
|
||||
|
||||
public:
|
||||
void PrintDebugInfo();
|
||||
void SetFormatName(const NumericFormatSymbol & formatName);
|
||||
void SetFormatString(const wxString & formatString);
|
||||
|
||||
// returns true iff the format name really changed:
|
||||
bool SetFormatName(const NumericFormatSymbol & formatName);
|
||||
|
||||
// returns true iff the format string really changed:
|
||||
bool SetFormatString(const wxString & formatString);
|
||||
|
||||
void SetSampleRate(double sampleRate);
|
||||
void SetValue(double newValue);
|
||||
void SetMinValue(double minValue);
|
||||
@ -187,8 +192,12 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
|
||||
|
||||
void SetSampleRate(double sampleRate);
|
||||
void SetValue(double newValue);
|
||||
void SetFormatString(const wxString & formatString);
|
||||
void SetFormatName(const NumericFormatSymbol & formatName);
|
||||
|
||||
// returns true iff the format string really changed:
|
||||
bool SetFormatString(const wxString & formatString);
|
||||
|
||||
// returns true iff the format name really changed:
|
||||
bool SetFormatName(const NumericFormatSymbol & formatName);
|
||||
|
||||
void SetFieldFocus(int /* digit */);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user