mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Allow pausing and unpausing of scrub. Just treat it differently internally.
This commit is contained in:
commit
f93dd21302
@ -92,10 +92,10 @@ enum CommandFlag : unsigned long long
|
||||
IsRealtimeNotActiveFlag= 0x10000000, //lll
|
||||
CaptureNotBusyFlag = 0x20000000,
|
||||
CanStopAudioStreamFlag = 0x40000000,
|
||||
AudioStreamNotScrubbingFlag
|
||||
= 0x80000000ULL, // prl
|
||||
RulerHasFocus
|
||||
= 0x100000000ULL, // prl
|
||||
= 0x80000000ULL, // prl
|
||||
// nextOneHas33BitsWow
|
||||
// = 0x100000000ULL, // prl
|
||||
|
||||
NoFlagsSpecifed = ~0ULL
|
||||
};
|
||||
|
@ -754,9 +754,7 @@ void AudacityProject::CreateMenusAndCommands()
|
||||
// Scrubbing sub-menu
|
||||
GetScrubber().AddMenuItems();
|
||||
|
||||
c->AddItem(wxT("Pause"), _("&Pause"), FN(OnPause), wxT("P"),
|
||||
c->GetDefaultFlags() | AudioStreamNotScrubbingFlag,
|
||||
c->GetDefaultMask() | AudioStreamNotScrubbingFlag);
|
||||
c->AddItem(wxT("Pause"), _("&Pause"), FN(OnPause), wxT("P"));
|
||||
c->AddItem(wxT("SkipStart"), _("S&kip to Start"), FN(OnSkipStart), wxT("Home"),
|
||||
AudioIONotBusyFlag, AudioIONotBusyFlag);
|
||||
c->AddItem(wxT("SkipEnd"), _("Skip to E&nd"), FN(OnSkipEnd), wxT("End"),
|
||||
@ -1776,9 +1774,6 @@ CommandFlag AudacityProject::GetUpdateFlags()
|
||||
if (bar->ControlToolBar::CanStopAudioStream())
|
||||
flags |= CanStopAudioStreamFlag;
|
||||
|
||||
if(!GetScrubber().HasStartedScrubbing())
|
||||
flags |= AudioStreamNotScrubbingFlag;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -431,9 +431,7 @@ void ControlToolBar::EnableDisableButtons()
|
||||
mFF->SetEnabled(tracks && !playing && !recording);
|
||||
|
||||
auto pProject = GetActiveProject();
|
||||
mPause->SetEnabled(CanStopAudioStream() &&
|
||||
!(pProject &&
|
||||
pProject->GetScrubber().HasStartedScrubbing()));
|
||||
mPause->SetEnabled(CanStopAudioStream());
|
||||
}
|
||||
|
||||
void ControlToolBar::SetPlay(bool down, PlayAppearance appearance)
|
||||
@ -479,7 +477,12 @@ void ControlToolBar::SetRecord(bool down, bool append)
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsRecordDown()
|
||||
bool ControlToolBar::IsPauseDown() const
|
||||
{
|
||||
return mPause->IsDown();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsRecordDown() const
|
||||
{
|
||||
return mRecord->IsDown();
|
||||
}
|
||||
@ -1090,12 +1093,6 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
|
||||
if (gAudioIO->IsScrubbing())
|
||||
// Pausing does not make sense. Force the button
|
||||
// to pop up below.
|
||||
mPaused = true;
|
||||
#endif
|
||||
|
||||
if(mPaused)
|
||||
{
|
||||
@ -1108,7 +1105,15 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
mPaused=true;
|
||||
}
|
||||
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
|
||||
if (gAudioIO->IsScrubbing())
|
||||
GetActiveProject()->GetScrubber().Pause(mPaused);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
}
|
||||
|
||||
UpdateStatusBar(GetActiveProject());
|
||||
}
|
||||
|
||||
@ -1190,22 +1195,22 @@ int ControlToolBar::WidthForStatusBar(wxStatusBar* const sb)
|
||||
int xMax = 0;
|
||||
const auto pauseString = wxT(" ") + wxGetTranslation(mStatePause);
|
||||
|
||||
auto update = [&] (const wxString &state, bool pauseToo) {
|
||||
auto update = [&] (const wxString &state) {
|
||||
int x, y;
|
||||
sb->GetTextExtent(
|
||||
wxGetTranslation(state) + ( pauseToo ? pauseString : wxString{} ) + wxT("."),
|
||||
wxGetTranslation(state) + pauseString + wxT("."),
|
||||
&x, &y
|
||||
);
|
||||
xMax = std::max(x, xMax);
|
||||
};
|
||||
|
||||
update(mStatePlay, true);
|
||||
update(mStateStop, true);
|
||||
update(mStateRecord, true);
|
||||
update(mStatePlay);
|
||||
update(mStateStop);
|
||||
update(mStateRecord);
|
||||
|
||||
// Note that Scrubbing + Paused is not allowed.
|
||||
for(const auto &state : Scrubber::GetAllUntranslatedStatusStrings())
|
||||
update(state, false);
|
||||
update(state);
|
||||
|
||||
return xMax + 30; // added constant needed because xMax isn't large enough for some reason, plus some space.
|
||||
}
|
||||
|
@ -70,7 +70,8 @@ class ControlToolBar final : public ToolBar {
|
||||
void SetStop(bool down);
|
||||
void SetRecord(bool down, bool append=false);
|
||||
|
||||
bool IsRecordDown();
|
||||
bool IsPauseDown() const;
|
||||
bool IsRecordDown() const;
|
||||
|
||||
// A project is only allowed to stop an audio stream that it owns.
|
||||
bool CanStopAudioStream ();
|
||||
|
@ -210,9 +210,6 @@ void Scrubber::MarkScrubStart(
|
||||
|
||||
ctb->SetPlay(true, ControlToolBar::PlayAppearance::Scrub);
|
||||
|
||||
// This disables the pause button.
|
||||
ctb->EnableDisableButtons();
|
||||
|
||||
ctb->UpdateStatusBar(mProject);
|
||||
|
||||
mScrubStartPosition = xx;
|
||||
@ -469,12 +466,17 @@ void Scrubber::HandleScrollWheel(int steps)
|
||||
}
|
||||
}
|
||||
|
||||
void Scrubber::Pause( bool paused )
|
||||
{
|
||||
mScrubHasFocus = !paused;
|
||||
}
|
||||
|
||||
void Scrubber::OnActivateOrDeactivateApp(wxActivateEvent &event)
|
||||
{
|
||||
if (event.GetActive())
|
||||
mScrubHasFocus = IsScrubbing();
|
||||
Pause(!IsScrubbing() || mProject->GetControlToolBar()->IsPauseDown());
|
||||
else
|
||||
mScrubHasFocus = false;
|
||||
Pause(true);
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ public:
|
||||
// All possible status strings.
|
||||
static std::vector<wxString> GetAllUntranslatedStatusStrings();
|
||||
|
||||
void Pause(bool paused);
|
||||
|
||||
private:
|
||||
void DoScrub(bool scroll, bool seek);
|
||||
void OnActivateOrDeactivateApp(wxActivateEvent & event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user