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