1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-27 17:48:38 +02:00

Better implementation of switch from scrub to quick play; ...

This commit is contained in:
Paul Licameli 2016-05-18 12:00:06 -04:00
commit 54c6493df6
3 changed files with 39 additions and 37 deletions

View File

@ -501,6 +501,11 @@ void Scrubber::Pause( bool paused )
mScrubHasFocus = !paused; mScrubHasFocus = !paused;
} }
bool Scrubber::IsPaused() const
{
return !mScrubHasFocus;
}
void Scrubber::OnActivateOrDeactivateApp(wxActivateEvent &event) void Scrubber::OnActivateOrDeactivateApp(wxActivateEvent &event)
{ {
if (event.GetActive()) if (event.GetActive())

View File

@ -87,6 +87,7 @@ public:
static std::vector<wxString> GetAllUntranslatedStatusStrings(); static std::vector<wxString> GetAllUntranslatedStatusStrings();
void Pause(bool paused); void Pause(bool paused);
bool IsPaused() const;
private: private:
void DoScrub(bool scroll, bool seek); void DoScrub(bool scroll, bool seek);

View File

@ -1814,8 +1814,9 @@ void QuickPlayRulerOverlay::Draw(OverlayPanel &panel, wxDC &dc)
if (mOldQPIndicatorPos >= 0) { if (mOldQPIndicatorPos >= 0) {
auto ruler = GetRuler(); auto ruler = GetRuler();
auto scrub = auto scrub =
ruler->mPrevZone == AdornedRulerPanel::StatusChoice::EnteringScrubZone || ruler->mMouseEventState == AdornedRulerPanel::mesNone &&
mPartner.mProject->GetScrubber().HasStartedScrubbing(); (ruler->mPrevZone == AdornedRulerPanel::StatusChoice::EnteringScrubZone ||
(mPartner.mProject->GetScrubber().HasStartedScrubbing()));
auto width = scrub ? IndicatorBigWidth() : IndicatorSmallWidth; auto width = scrub ? IndicatorBigWidth() : IndicatorSmallWidth;
ruler->DoDrawIndicator(&dc, mOldQPIndicatorPos, true, width, scrub); ruler->DoDrawIndicator(&dc, mOldQPIndicatorPos, true, width, scrub);
} }
@ -2402,22 +2403,16 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
if (IsButton(zone) || evt.RightDown()) if (IsButton(zone) || evt.RightDown())
// Fall through to pushbutton handling // Fall through to pushbutton handling
; ;
else if (zone == StatusChoice::EnteringQP && else {
mQuickPlayEnabled && bool switchToQP = (zone == StatusChoice::EnteringQP && mQuickPlayEnabled);
evt.LeftUp()) { if (switchToQP && evt.LeftDown()) {
// Stop scrubbing // We can't stop scrubbing yet (see comments in Bug 1391), but we can pause it.
if (HasCapture()) mProject->OnPause();
ReleaseMouse(); // Don't return, fall through
mProject->OnStop();
// Simulate a new click in the same place
evt.SetEventType(wxEVT_LEFT_DOWN);
this->AddPendingEvent(evt);
evt.SetEventType(wxEVT_LEFT_UP);
this->AddPendingEvent(evt);
return;
} }
else if (scrubber.IsPaused())
// Just fall through
;
else { else {
// If already clicked for scrub, preempt the usual event handling, // If already clicked for scrub, preempt the usual event handling,
// no matter what the y coordinate. // no matter what the y coordinate.
@ -2444,6 +2439,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
return; return;
} }
} }
}
// Store the initial play region state // Store the initial play region state
if(mMouseEventState == mesNone) { if(mMouseEventState == mesNone) {