From a33ec61ddf5bcf61804e570b8cc802e8862de328 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 8 Jun 2017 12:47:37 -0400 Subject: [PATCH] Move code for toggling spectral selection (Q key) out of TrackPanel --- src/Menus.cpp | 17 ++++++++++++++++- src/Menus.h | 3 +++ src/Project.cpp | 1 + src/TrackPanel.cpp | 21 --------------------- src/TrackPanel.h | 6 ------ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 0a600b39f..bd04e9b14 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -5516,7 +5516,22 @@ void AudacityProject::OnSelectNone() #ifdef EXPERIMENTAL_SPECTRAL_EDITING void AudacityProject::OnToggleSpectralSelection() { - mTrackPanel->ToggleSpectralSelection(); + SelectedRegion ®ion = mViewInfo.selectedRegion; + const double f0 = region.f0(); + const double f1 = region.f1(); + const bool haveSpectralSelection = + !(f0 == SelectedRegion::UndefinedFrequency && + f1 == SelectedRegion::UndefinedFrequency); + if (haveSpectralSelection) + { + mLastF0 = f0; + mLastF1 = f1; + region.setFrequencies + (SelectedRegion::UndefinedFrequency, SelectedRegion::UndefinedFrequency); + } + else + region.setFrequencies(mLastF0, mLastF1); + mTrackPanel->Refresh(false); ModifyState(false); } diff --git a/src/Menus.h b/src/Menus.h index 3d1911665..6f3d0b221 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -288,6 +288,9 @@ int CountSelectedWaveTracks(); int CountSelectedTracks(); public: #ifdef EXPERIMENTAL_SPECTRAL_EDITING +// For toggling of spectral seletion +double mLastF0; +double mLastF1; void OnToggleSpectralSelection(); void DoNextPeakFrequency(bool up); void OnNextHigherPeakFrequency(); diff --git a/src/Project.cpp b/src/Project.cpp index d64dc623d..a4f520bf5 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1228,6 +1228,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, #ifdef EXPERIMENTAL_DA2 ClearBackground();// For wxGTK. #endif + mLastF0 = mLastF1 = SelectedRegion::UndefinedFrequency; } AudacityProject::~AudacityProject() diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 13710442a..1ce35f368 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -546,8 +546,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, #ifdef EXPERIMENTAL_SPECTRAL_EDITING mFreqSelMode = FREQ_SEL_INVALID; mFrequencySnapper = std::make_unique(); - - mLastF0 = mLastF1 = SelectedRegion::UndefinedFrequency; #endif mSelStartValid = false; @@ -2709,25 +2707,6 @@ void TrackPanel::ExtendFreqSelection(int mouseYCoordinate, int trackTopEdge, } } -void TrackPanel::ToggleSpectralSelection() -{ - SelectedRegion ®ion = mViewInfo->selectedRegion; - const double f0 = region.f0(); - const double f1 = region.f1(); - const bool haveSpectralSelection = - !(f0 == SelectedRegion::UndefinedFrequency && - f1 == SelectedRegion::UndefinedFrequency); - if (haveSpectralSelection) - { - mLastF0 = f0; - mLastF1 = f1; - region.setFrequencies - (SelectedRegion::UndefinedFrequency, SelectedRegion::UndefinedFrequency); - } - else - region.setFrequencies(mLastF0, mLastF1); -} - void TrackPanel::ResetFreqSelectionPin(double hintFrequency, bool logF) { switch (mFreqSelMode) { diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 3cf8aa2b8..3b445c1c2 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -675,12 +675,6 @@ protected: const WaveTrack *mFreqSelTrack = NULL; std::unique_ptr mFrequencySnapper; - // For toggling of spectral seletion - double mLastF0; - double mLastF1; - -public: - void ToggleSpectralSelection(); protected: #endif