1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-22 15:20:15 +02:00

Give the scrubber its own timer separate from TrackPanel's, so that...

... we can experiment with changing the interval.
This commit is contained in:
Paul Licameli 2016-05-13 12:28:00 -04:00
parent 28e1e6303f
commit 16d33c6005
2 changed files with 31 additions and 6 deletions

View File

@ -38,6 +38,8 @@ enum {
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
ScrubSpeedStepsPerOctave = 4,
#endif
ScrubPollInterval_ms = 50,
};
namespace {
@ -112,6 +114,26 @@ namespace {
}
}
class Scrubber::ScrubPoller : public wxTimer
{
public:
ScrubPoller(Scrubber &scrubber) : mScrubber{ scrubber } {}
private:
void Notify() override;
Scrubber &mScrubber;
};
void Scrubber::ScrubPoller::Notify()
{
// Call ContinueScrubbing() here in a timer handler
// rather than in SelectionHandleDrag()
// so that even without drag events, we can instruct the play head to
// keep approaching the mouse cursor, when its maximum speed is limited.
mScrubber.ContinueScrubbing();
}
Scrubber::Scrubber(AudacityProject *project)
: mScrubToken(-1)
, mScrubStartClockTimeMillis(-1)
@ -126,6 +148,7 @@ Scrubber::Scrubber(AudacityProject *project)
#endif
, mProject(project)
, mPoller { std::make_unique<ScrubPoller>(*this) }
{
if (wxTheApp)
wxTheApp->Connect
@ -311,6 +334,8 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub);
mScrubHasFocus = true;
mLastScrubPosition = xx;
mPoller->Start(ScrubPollInterval_ms);
}
// Return true whether we started scrub, or are still waiting to decide.
@ -393,6 +418,8 @@ void Scrubber::ContinueScrubbing()
void Scrubber::StopScrubbing()
{
mPoller->Stop();
UncheckAllMenuItems();
mScrubStartPosition = -1;
@ -597,12 +624,6 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
ruler->ShowQuickPlayIndicator();
}
// Call ContinueScrubbing() here in the timer handler
// rather than in SelectionHandleDrag()
// so that even without drag events, we can instruct the play head to
// keep approaching the mouse cursor, when its maximum speed is limited.
scrubber.ContinueScrubbing();
if (!scrubber.ShouldDrawScrubSpeed()) {
mNextScrubRect = wxRect();
}

View File

@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
#ifndef __AUDACITY_SCRUBBING__
#define __AUDACITY_SCRUBBING__
#include "../../MemoryX.h"
#include <vector>
#include <wx/event.h>
#include <wx/longlong.h>
@ -125,6 +126,9 @@ private:
AudacityProject *mProject;
DECLARE_EVENT_TABLE()
class ScrubPoller;
std::unique_ptr<ScrubPoller> mPoller;
};
// Specialist in drawing the scrub speed, and listening for certain events