mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-30 15:39:27 +02:00
Improve scrubbing speed control (2 finger swipe) on Mac
This commit is contained in:
parent
af7a92c2ab
commit
e4fadf4aaf
@ -5378,8 +5378,18 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
// Let other listeners get the notification
|
||||
event.Skip();
|
||||
|
||||
if (mMode != Mode::Off && mProject->IsAudioActive())
|
||||
{
|
||||
if(!mProject->IsAudioActive())
|
||||
return;
|
||||
else if (mMode == Mode::Refresh) {
|
||||
// PRL: see comments in Scrubbing.cpp for why this is sometimes needed.
|
||||
// These unnecessary refreshes cause wheel rotation events to be delivered more uniformly
|
||||
// to the application, so scrub speed control is smoother.
|
||||
// (So I see at least with OS 10.10 and wxWidgets 3.0.2.)
|
||||
// Is there another way to ensure that than by refreshing?
|
||||
const auto trackPanel = mProject->GetTrackPanel();
|
||||
trackPanel->Refresh(false);
|
||||
}
|
||||
else if (mMode != Mode::Off) {
|
||||
// Pan the view, so that we center the play indicator.
|
||||
|
||||
ViewInfo &viewInfo = mProject->GetViewInfo();
|
||||
|
@ -730,6 +730,7 @@ public:
|
||||
|
||||
enum class Mode {
|
||||
Off,
|
||||
Refresh,
|
||||
Centered,
|
||||
Right,
|
||||
};
|
||||
|
@ -5626,6 +5626,7 @@ void TrackPanel::HandleWheelRotation(wxMouseEvent & event)
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
|
||||
if (GetProject()->GetScrubber().IsScrubbing()) {
|
||||
GetProject()->GetScrubber().HandleScrollWheel(steps);
|
||||
event.Skip(false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -381,9 +381,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||
|
||||
if (IsScrubbing()) {
|
||||
using Mode = AudacityProject::PlaybackScroller::Mode;
|
||||
mProject->GetPlaybackScroller().Activate
|
||||
(mSmoothScrollingScrub ? Mode::Centered : Mode::Off);
|
||||
ActivateScroller();
|
||||
mPaused = false;
|
||||
mLastScrubPosition = xx;
|
||||
|
||||
@ -561,6 +559,9 @@ void Scrubber::HandleScrollWheel(int steps)
|
||||
// Not likely you would spin it with the left button down, but...
|
||||
return;
|
||||
|
||||
if (steps == 0)
|
||||
return;
|
||||
|
||||
const int newLogMaxScrubSpeed = mLogMaxScrubSpeed + steps;
|
||||
static const double maxScrubSpeedBase =
|
||||
pow(2.0, 1.0 / ScrubSpeedStepsPerOctave);
|
||||
@ -775,6 +776,24 @@ bool Scrubber::PollIsSeeking()
|
||||
return mDragging || (mAlwaysSeeking || ::wxGetMouseState().LeftIsDown());
|
||||
}
|
||||
|
||||
void Scrubber::ActivateScroller()
|
||||
{
|
||||
using Mode = AudacityProject::PlaybackScroller::Mode;
|
||||
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub
|
||||
? Mode::Centered
|
||||
:
|
||||
#ifdef __WXMAC__
|
||||
// PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
|
||||
// doing this causes wheel rotation events (mapped from the double finger vertical
|
||||
// swipe) to be delivered more uniformly to the application, so that spped control
|
||||
// works better.
|
||||
Mode::Refresh
|
||||
#else
|
||||
Mode::Off
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
void Scrubber::DoScrub(bool scroll, bool seek)
|
||||
{
|
||||
const bool wasScrubbing = IsScrubbing();
|
||||
@ -793,9 +812,7 @@ void Scrubber::DoScrub(bool scroll, bool seek)
|
||||
}
|
||||
else if(!match) {
|
||||
mSmoothScrollingScrub = scroll;
|
||||
using Mode = AudacityProject::PlaybackScroller::Mode;
|
||||
mProject->GetPlaybackScroller().Activate
|
||||
(scroll ? Mode::Centered : Mode::Off);
|
||||
ActivateScroller();
|
||||
mAlwaysSeeking = seek;
|
||||
UncheckAllMenuItems();
|
||||
CheckMenuItem();
|
||||
|
@ -128,6 +128,7 @@ public:
|
||||
bool IsPaused() const;
|
||||
|
||||
private:
|
||||
void ActivateScroller();
|
||||
void DoScrub(bool scroll, bool seek);
|
||||
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
||||
void UncheckAllMenuItems();
|
||||
|
Loading…
x
Reference in New Issue
Block a user