1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-18 17:10:05 +02:00

Fix spectral preferences extra caching issue.

This commit is contained in:
James Crook 2018-02-18 16:55:26 +00:00 committed by Paul Licameli
parent 6a5a61d39a
commit 4724c6a131
6 changed files with 40 additions and 8 deletions

View File

@ -4895,9 +4895,15 @@ void AudacityProject::OnPreferences(const CommandContext &WXUNUSED(context) )
} }
} }
#include "./prefs/SpectrogramSettings.h"
#include "./prefs/WaveformSettings.h"
void AudacityProject::OnReloadPreferences(const CommandContext &WXUNUSED(context) ) void AudacityProject::OnReloadPreferences(const CommandContext &WXUNUSED(context) )
{ {
{ {
SpectrogramSettings::defaults().LoadPrefs();
WaveformSettings::defaults().LoadPrefs();
GlobalPrefsDialog dialog(this /* parent */ ); GlobalPrefsDialog dialog(this /* parent */ );
wxCommandEvent Evt; wxCommandEvent Evt;
//dialog.Show(); //dialog.Show();

View File

@ -739,6 +739,23 @@ void WaveTrack::SetSpectrogramSettings(std::unique_ptr<SpectrogramSettings> &&pS
} }
} }
void WaveTrack::UseSpectralPrefs( bool bUse )
{
if( bUse ){
if( !mpSpectrumSettings )
return;
// reset it, and next we will be getting the defaults.
mpSpectrumSettings.reset();
}
else {
if( mpSpectrumSettings )
return;
GetIndependentSpectrogramSettings();
}
}
const WaveformSettings &WaveTrack::GetWaveformSettings() const const WaveformSettings &WaveTrack::GetWaveformSettings() const
{ {
if (mpWaveformSettings) if (mpWaveformSettings)

View File

@ -155,7 +155,7 @@ private:
WaveformSettings &GetWaveformSettings(); WaveformSettings &GetWaveformSettings();
WaveformSettings &GetIndependentWaveformSettings(); WaveformSettings &GetIndependentWaveformSettings();
void SetWaveformSettings(std::unique_ptr<WaveformSettings> &&pSettings); void SetWaveformSettings(std::unique_ptr<WaveformSettings> &&pSettings);
void UseSpectralPrefs( bool bUse=true );
// //
// High-level editing // High-level editing
// //

View File

@ -91,6 +91,8 @@ bool SetTrackCommand::DefineParams( ShuttleParams & S ){
S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), kWaveform, displays ); S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), kWaveform, displays );
S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinear, scales ); S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinear, scales );
S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours ); S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
S.OptionalN( bHasUseSpecPrefs ).Define( bUseSpecPrefs, wxT("SpecPrefs"), false );
S.OptionalN( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true ); S.OptionalN( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
S.OptionalN( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false ); S.OptionalN( bHasGrayScale ).Define( bGrayScale, wxT("GrayScale"), false );
// There is also a select command. This is an alternative. // There is also a select command. This is an alternative.
@ -124,12 +126,13 @@ void SetTrackCommand::PopulateOrExchange(ShuttleGui & S)
S.EndMultiColumn(); S.EndMultiColumn();
S.StartMultiColumn(2, wxALIGN_CENTER); S.StartMultiColumn(2, wxALIGN_CENTER);
{ {
S.Optional( bHasSpectralSelect ).TieCheckBox( _("Spectral Select:"), bSpectralSelect ); S.Optional( bHasUseSpecPrefs ).TieCheckBox( _("Use Spectral Prefs:"), bUseSpecPrefs );
S.Optional( bHasGrayScale ).TieCheckBox( _("Gray Scale:"), bGrayScale ); S.Optional( bHasSpectralSelect ).TieCheckBox( _("Spectral Select:"), bSpectralSelect);
S.Optional( bHasSelected ).TieCheckBox( _("Selected:"), bSelected ); S.Optional( bHasGrayScale ).TieCheckBox( _("Gray Scale:"), bGrayScale );
S.Optional( bHasFocused ).TieCheckBox( _("Focused:"), bFocused); S.Optional( bHasSelected ).TieCheckBox( _("Selected:"), bSelected );
S.Optional( bHasSolo ).TieCheckBox( _("Solo:"), bSolo); S.Optional( bHasFocused ).TieCheckBox( _("Focused:"), bFocused);
S.Optional( bHasMute ).TieCheckBox( _("Mute:"), bMute); S.Optional( bHasSolo ).TieCheckBox( _("Solo:"), bSolo);
S.Optional( bHasMute ).TieCheckBox( _("Mute:"), bMute);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -177,11 +180,14 @@ bool SetTrackCommand::Apply(const CommandContext & context)
(mScaleType==kLinear) ? (mScaleType==kLinear) ?
WaveformSettings::stLinear WaveformSettings::stLinear
: WaveformSettings::stLogarithmic; : WaveformSettings::stLogarithmic;
if( wt && bHasUseSpecPrefs ){
wt->UseSpectralPrefs( bUseSpecPrefs );
}
if( wt && bHasSpectralSelect ) if( wt && bHasSpectralSelect )
wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect; wt->GetSpectrogramSettings().spectralSelection = bSpectralSelect;
if( wt && bHasGrayScale ) if( wt && bHasGrayScale )
wt->GetSpectrogramSettings().isGrayscale = bGrayScale; wt->GetSpectrogramSettings().isGrayscale = bGrayScale;
// These ones don't make sense on the second channel of a stereo track. // These ones don't make sense on the second channel of a stereo track.
if( !bIsSecondChannel ){ if( !bIsSecondChannel ){
if( bHasSelected ) if( bHasSelected )

View File

@ -47,6 +47,7 @@ public:
int mHeight; int mHeight;
int mDisplayType; int mDisplayType;
int mScaleType; int mScaleType;
bool bUseSpecPrefs;
bool bSpectralSelect; bool bSpectralSelect;
bool bGrayScale; bool bGrayScale;
bool bSelected; bool bSelected;
@ -64,6 +65,7 @@ public:
bool bHasHeight; bool bHasHeight;
bool bHasDisplayType; bool bHasDisplayType;
bool bHasScaleType; bool bHasScaleType;
bool bHasUseSpecPrefs;
bool bHasSpectralSelect; bool bHasSpectralSelect;
bool bHasGrayScale; bool bHasGrayScale;
bool bHasSelected; bool bHasSelected;

View File

@ -517,6 +517,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
} }
WaveformSettings::defaults().LoadPrefs(); WaveformSettings::defaults().LoadPrefs();
SpectrogramSettings::defaults().LoadPrefs();
if( IsModal() ) if( IsModal() )
EndModal(true); EndModal(true);