1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

WaveTrackView::BuildSubViews can be simplified...

... The setting of scale type now happens in the default constructor of
WaveformSettings, which calls LoadPrefs.

Since creation of WaveformSettings is always forced, we don't need the
distinction between WaveTrack::GetWaveformSettings and
WaveTrack::GetIndependentWaveformSettings.

That distinction was more analogy with the handling of SpectrogramSettings that
we don't need now.
This commit is contained in:
Paul Licameli 2020-10-10 11:14:20 -04:00
parent 046548ad2b
commit 9d6cfcc746
7 changed files with 8 additions and 26 deletions

View File

@ -704,22 +704,13 @@ void WaveTrack::UseSpectralPrefs( bool bUse )
const WaveformSettings &WaveTrack::GetWaveformSettings() const
{
if (mpWaveformSettings)
return *mpWaveformSettings;
else
return WaveformSettings::defaults();
// Create on demand
return const_cast<WaveTrack*>(this)->GetWaveformSettings();
}
WaveformSettings &WaveTrack::GetWaveformSettings()
{
if (mpWaveformSettings)
return *mpWaveformSettings;
else
return WaveformSettings::defaults();
}
WaveformSettings &WaveTrack::GetIndependentWaveformSettings()
{
// Create on demand
if (!mpWaveformSettings)
mpWaveformSettings = std::make_unique<WaveformSettings>(WaveformSettings::defaults());
return *mpWaveformSettings;

View File

@ -156,7 +156,6 @@ private:
const WaveformSettings &GetWaveformSettings() const;
WaveformSettings &GetWaveformSettings();
WaveformSettings &GetIndependentWaveformSettings();
void SetWaveformSettings(std::unique_ptr<WaveformSettings> &&pSettings);
void UseSpectralPrefs( bool bUse=true );
//

View File

@ -387,7 +387,7 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
}
}
if( wt && bHasScaleType )
wt->GetIndependentWaveformSettings().scaleType =
wt->GetWaveformSettings().scaleType =
(mScaleType==kLinear) ?
WaveformSettings::stLinear
: WaveformSettings::stLogarithmic;

View File

@ -171,7 +171,7 @@ bool WaveformPrefs::Commit()
channel->SetWaveformSettings({});
else {
WaveformSettings &settings =
channel->GetIndependentWaveformSettings();
channel->GetWaveformSettings();
settings = mTempSettings;
}
}

View File

@ -1280,14 +1280,6 @@ void WaveTrackView::BuildSubViews() const
pThis->SetMultiView( true );
display = WaveTrackSubViewType::Default();
}
// Force creation always:
WaveformSettings &settings = static_cast< WaveTrack* >( pTrack.get() )
->GetIndependentWaveformSettings();
// Set the default scale type to linear or log, even if we are showing
// spectrogram
settings.scaleType = TracksPrefs::WaveformScaleChoice();
pThis->DoSetDisplay( display, !multi );
}

View File

@ -84,11 +84,11 @@ unsigned WaveformVRulerControls::DoHandleWheelRotation(
return RefreshNone;
WaveformSettings &settings =
wt->GetIndependentWaveformSettings();
wt->GetWaveformSettings();
float olddBRange = settings.dBRange;
for (auto channel : TrackList::Channels(wt)) {
WaveformSettings &channelSettings =
channel->GetIndependentWaveformSettings();
channel->GetWaveformSettings();
if (steps < 0)
// Zoom out
channelSettings.NextLowerDBRange();

View File

@ -329,7 +329,7 @@ void WaveformVRulerMenuTable::OnWaveformScaleType(wxCommandEvent &evt)
if (wt->GetWaveformSettings().scaleType != newScaleType) {
for (auto channel : TrackList::Channels(wt)) {
channel->GetIndependentWaveformSettings().scaleType = newScaleType;
channel->GetWaveformSettings().scaleType = newScaleType;
}
AudacityProject *const project = &mpData->project;