mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-15 15:50:54 +02:00
Set selection whenever scrub/seek stops by any means besides ESC key
This commit is contained in:
commit
5006969e3f
@ -1529,10 +1529,14 @@ void AudacityApp::OnKeyDown(wxKeyEvent &event)
|
||||
// Stop play, including scrub, but not record
|
||||
auto project = ::GetActiveProject();
|
||||
auto token = project->GetAudioIOToken();
|
||||
auto &scrubber = project->GetScrubber();
|
||||
auto scrubbing = scrubber.HasStartedScrubbing();
|
||||
if (scrubbing)
|
||||
scrubber.Cancel();
|
||||
if((token > 0 &&
|
||||
gAudioIO->IsAudioTokenActive(token) &&
|
||||
gAudioIO->GetNumCaptureChannels() == 0) ||
|
||||
project->GetScrubber().HasStartedScrubbing())
|
||||
scrubbing)
|
||||
// ESC out of other play (but not record)
|
||||
project->OnStop();
|
||||
else
|
||||
|
@ -2295,19 +2295,30 @@ void AudacityProject::OnRecordAppend()
|
||||
GetControlToolBar()->OnRecord(evt);
|
||||
}
|
||||
|
||||
// The code for "OnPlayStopSelect" is simply the code of "OnPlayStop" and "OnStopSelect" merged.
|
||||
void AudacityProject::OnPlayStopSelect()
|
||||
{
|
||||
DoPlayStopSelect(false, false);
|
||||
ControlToolBar *toolbar = GetControlToolBar();
|
||||
wxCommandEvent evt;
|
||||
if (DoPlayStopSelect(false, false))
|
||||
toolbar->OnStop(evt);
|
||||
else if (!gAudioIO->IsBusy()) {
|
||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||
//toolbar->SetPlay(true); // Not needed as set in PlayPlayRegion()
|
||||
toolbar->SetStop(false);
|
||||
|
||||
// Will automatically set mLastPlayMode
|
||||
toolbar->PlayCurrentRegion(false);
|
||||
}
|
||||
}
|
||||
|
||||
// The code for "OnPlayStopSelect" is simply the code of "OnPlayStop" and "OnStopSelect" merged.
|
||||
void AudacityProject::DoPlayStopSelect(bool click, bool shift)
|
||||
bool AudacityProject::DoPlayStopSelect(bool click, bool shift)
|
||||
{
|
||||
wxCommandEvent evt;
|
||||
ControlToolBar *toolbar = GetControlToolBar();
|
||||
|
||||
//If busy, stop playing, make sure everything is unpaused.
|
||||
if (gAudioIO->IsStreamActive(GetAudioIOToken())) {
|
||||
if (GetScrubber().HasStartedScrubbing() ||
|
||||
gAudioIO->IsStreamActive(GetAudioIOToken())) {
|
||||
toolbar->SetPlay(false); //Pops
|
||||
toolbar->SetStop(true); //Pushes stop down
|
||||
|
||||
@ -2341,16 +2352,9 @@ void AudacityProject::DoPlayStopSelect(bool click, bool shift)
|
||||
selection.setT0(time, false);
|
||||
|
||||
ModifyState(false); // without bWantsAutoSave
|
||||
toolbar->OnStop(evt);
|
||||
}
|
||||
else if (!gAudioIO->IsBusy()) {
|
||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||
//toolbar->SetPlay(true); // Not needed as set in PlayPlayRegion()
|
||||
toolbar->SetStop(false);
|
||||
|
||||
// Will automatically set mLastPlayMode
|
||||
toolbar->PlayCurrentRegion(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AudacityProject::OnStopSelect()
|
||||
|
@ -80,7 +80,7 @@ void OnSeekRightLong();
|
||||
|
||||
bool MakeReadyToPlay(bool loop = false, bool cutpreview = false); // Helper function that sets button states etc.
|
||||
void OnPlayStop();
|
||||
void DoPlayStopSelect(bool click, bool shift);
|
||||
bool DoPlayStopSelect(bool click, bool shift);
|
||||
void OnPlayStopSelect();
|
||||
void OnPlayOneSecond();
|
||||
void OnPlayToSelection();
|
||||
|
@ -163,7 +163,7 @@ private:
|
||||
|
||||
void Scrubber::ScrubPoller::Notify()
|
||||
{
|
||||
// Call ContinueScrubbing() here in a timer handler
|
||||
// Call Continue functions 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.
|
||||
@ -276,6 +276,8 @@ void Scrubber::MarkScrubStart(
|
||||
mScrubStartPosition = xx;
|
||||
ctb->UpdateStatusBar(mProject);
|
||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||
|
||||
mCancelled = false;
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
|
||||
@ -453,6 +455,8 @@ void Scrubber::ContinueScrubbingUI()
|
||||
if (mDragging && !state.LeftIsDown()) {
|
||||
// Stop and set cursor
|
||||
mProject->DoPlayStopSelect(true, state.ShiftDown());
|
||||
wxCommandEvent evt;
|
||||
mProject->GetControlToolBar()->OnStop(evt);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -490,6 +494,12 @@ void Scrubber::StopScrubbing()
|
||||
|
||||
mPoller->Stop();
|
||||
|
||||
if (!mCancelled) {
|
||||
const wxMouseState state(::wxGetMouseState());
|
||||
// Stop and set cursor
|
||||
mProject->DoPlayStopSelect(true, state.ShiftDown());
|
||||
}
|
||||
|
||||
mScrubStartPosition = -1;
|
||||
mDragging = false;
|
||||
|
||||
|
@ -103,6 +103,9 @@ public:
|
||||
bool Scrubs() const
|
||||
{ return mScrubbing; }
|
||||
|
||||
void Cancel()
|
||||
{ mCancelled = true; }
|
||||
|
||||
bool ShouldDrawScrubSpeed();
|
||||
double FindScrubSpeed(bool seeking, double time) const;
|
||||
double GetMaxScrubSpeed() const { return mOptions.maxSpeed; }
|
||||
@ -164,6 +167,8 @@ private:
|
||||
|
||||
bool mDragging {};
|
||||
|
||||
bool mCancelled {};
|
||||
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
|
||||
int mLogMaxScrubSpeed;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user