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:
parent
28e1e6303f
commit
16d33c6005
@ -38,6 +38,8 @@ enum {
|
|||||||
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
|
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
|
||||||
ScrubSpeedStepsPerOctave = 4,
|
ScrubSpeedStepsPerOctave = 4,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ScrubPollInterval_ms = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
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)
|
Scrubber::Scrubber(AudacityProject *project)
|
||||||
: mScrubToken(-1)
|
: mScrubToken(-1)
|
||||||
, mScrubStartClockTimeMillis(-1)
|
, mScrubStartClockTimeMillis(-1)
|
||||||
@ -126,6 +148,7 @@ Scrubber::Scrubber(AudacityProject *project)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
, mProject(project)
|
, mProject(project)
|
||||||
|
, mPoller { std::make_unique<ScrubPoller>(*this) }
|
||||||
{
|
{
|
||||||
if (wxTheApp)
|
if (wxTheApp)
|
||||||
wxTheApp->Connect
|
wxTheApp->Connect
|
||||||
@ -311,6 +334,8 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub);
|
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub);
|
||||||
mScrubHasFocus = true;
|
mScrubHasFocus = true;
|
||||||
mLastScrubPosition = xx;
|
mLastScrubPosition = xx;
|
||||||
|
|
||||||
|
mPoller->Start(ScrubPollInterval_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true whether we started scrub, or are still waiting to decide.
|
// Return true whether we started scrub, or are still waiting to decide.
|
||||||
@ -393,6 +418,8 @@ void Scrubber::ContinueScrubbing()
|
|||||||
|
|
||||||
void Scrubber::StopScrubbing()
|
void Scrubber::StopScrubbing()
|
||||||
{
|
{
|
||||||
|
mPoller->Stop();
|
||||||
|
|
||||||
UncheckAllMenuItems();
|
UncheckAllMenuItems();
|
||||||
|
|
||||||
mScrubStartPosition = -1;
|
mScrubStartPosition = -1;
|
||||||
@ -597,12 +624,6 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
|
|||||||
ruler->ShowQuickPlayIndicator();
|
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()) {
|
if (!scrubber.ShouldDrawScrubSpeed()) {
|
||||||
mNextScrubRect = wxRect();
|
mNextScrubRect = wxRect();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#ifndef __AUDACITY_SCRUBBING__
|
#ifndef __AUDACITY_SCRUBBING__
|
||||||
#define __AUDACITY_SCRUBBING__
|
#define __AUDACITY_SCRUBBING__
|
||||||
|
|
||||||
|
#include "../../MemoryX.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/longlong.h>
|
#include <wx/longlong.h>
|
||||||
@ -125,6 +126,9 @@ private:
|
|||||||
AudacityProject *mProject;
|
AudacityProject *mProject;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
class ScrubPoller;
|
||||||
|
std::unique_ptr<ScrubPoller> mPoller;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specialist in drawing the scrub speed, and listening for certain events
|
// Specialist in drawing the scrub speed, and listening for certain events
|
||||||
|
Loading…
x
Reference in New Issue
Block a user