From ba883cbcf46242e9ebc6e15b38f60cc7d871947b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 23 May 2016 17:56:06 -0400 Subject: [PATCH] Improve responsiveness of drag seek during click-scrub... .. by refreshing the TrackPanel window less often. --- src/SelectedRegion.h | 18 ++++++++++++++++++ src/TrackPanel.cpp | 9 ++++++++- src/TrackPanel.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/SelectedRegion.h b/src/SelectedRegion.h index 0dcd12441..de49cb2d3 100644 --- a/src/SelectedRegion.h +++ b/src/SelectedRegion.h @@ -256,6 +256,19 @@ private: } #endif + friend inline bool operator == + (const SelectedRegion &lhs, const SelectedRegion &rhs) + { + return + lhs.mT0 == rhs.mT0 + && lhs.mT1 == rhs.mT1 +#ifdef EXPERIMENTAL_SPECTRAL_EDITING + && lhs.mF0 == rhs.mF0 + && lhs.mF1 == rhs.mF1 +#endif + ; + } + double mT0; double mT1; #ifdef EXPERIMENTAL_SPECTRAL_EDITING @@ -265,4 +278,9 @@ private: }; +inline bool operator != (const SelectedRegion &lhs, const SelectedRegion &rhs) +{ + return !(lhs == rhs); +} + #endif diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 83f65cba5..721b74c21 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -944,6 +944,9 @@ void TrackPanel::OnTimer(wxTimerEvent& ) //ANSWER-ME: Was DisplaySelection added to solve a repaint problem? DisplaySelection(); } + if (mLastDrawnSelectedRegion != mViewInfo->selectedRegion) { + UpdateSelectionDisplay(); + } // Notify listeners for timer ticks { @@ -1045,6 +1048,8 @@ double TrackPanel::GetScreenEndTime() const /// completing a repaint operation. void TrackPanel::OnPaint(wxPaintEvent & /* event */) { + mLastDrawnSelectedRegion = mViewInfo->selectedRegion; + #if DEBUG_DRAW_TIMING wxStopWatch sw; #endif @@ -2764,7 +2769,9 @@ void TrackPanel::SelectionHandleDrag(wxMouseEvent & event, Track *clickedTrack) #endif ExtendSelection(x, rect.x, clickedTrack); - UpdateSelectionDisplay(); + // Don't do this at every mouse event, because it slows down seek-scrub. + // Instead, let OnTimer do it, which is often enough. + // UpdateSelectionDisplay(); } #ifdef EXPERIMENTAL_SPECTRAL_EDITING diff --git a/src/TrackPanel.h b/src/TrackPanel.h index c1c427938..125526903 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -790,6 +790,8 @@ protected: // The screenshot class needs to access internals friend class ScreenshotCommand; + SelectedRegion mLastDrawnSelectedRegion {}; + public: wxSize vrulerSize;