mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 08:38:39 +02:00
Transport status message, buttons, scrolling update in idle time...
... so the functions that start and stop streams don't really need the ControlToolBar object. This also makes the intended momentary push-down of the Stop button visible, as was apparently intended, when playback stops for other reasons than a click on that button.
This commit is contained in:
commit
73fb2a2a82
@ -192,6 +192,27 @@ void ProjectAudioManager::OnSoundActivationThreshold()
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectAudioManager::Playing() const
|
||||
{
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
return
|
||||
gAudioIO->IsBusy() &&
|
||||
ControlToolBar::Get( mProject ).CanStopAudioStream() &&
|
||||
// ... and not merely monitoring
|
||||
!gAudioIO->IsMonitoring() &&
|
||||
// ... and not punch-and-roll recording
|
||||
gAudioIO->GetNumCaptureChannels() == 0;
|
||||
}
|
||||
|
||||
bool ProjectAudioManager::Recording() const
|
||||
{
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
return
|
||||
gAudioIO->IsBusy() &&
|
||||
ControlToolBar::Get( mProject).CanStopAudioStream() &&
|
||||
gAudioIO->GetNumCaptureChannels() > 0;
|
||||
}
|
||||
|
||||
AudioIOStartStreamOptions
|
||||
DefaultPlayOptions( AudacityProject &project )
|
||||
{
|
||||
@ -256,8 +277,7 @@ bool DoPlayStopSelect
|
||||
//If busy, stop playing, make sure everything is unpaused.
|
||||
if (scrubber.HasMark() ||
|
||||
gAudioIO->IsStreamActive(token)) {
|
||||
toolbar.SetPlay(false); //Pops
|
||||
toolbar.SetStop(true); //Pushes stop down
|
||||
toolbar.SetStop(); //Pushes stop down
|
||||
|
||||
// change the selection
|
||||
auto time = gAudioIO->GetStreamTime();
|
||||
@ -312,8 +332,6 @@ void DoPlayStopSelect(AudacityProject &project)
|
||||
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);
|
||||
@ -330,11 +348,8 @@ void DoPause( AudacityProject &project )
|
||||
|
||||
void DoRecord( AudacityProject &project )
|
||||
{
|
||||
wxCommandEvent evt;
|
||||
evt.SetInt(2); // 0 is default, use 1 to set shift on, 2 to clear it
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
controlToolBar.OnRecord(evt);
|
||||
controlToolBar.OnRecord(false);
|
||||
}
|
||||
|
||||
void DoLockPlayRegion( AudacityProject &project )
|
||||
@ -369,11 +384,6 @@ void DoTogglePinnedHead( AudacityProject &project )
|
||||
TracksPrefs::SetPinnedHeadPreference(value, true);
|
||||
MenuManager::ModifyAllProjectToolbarMenus();
|
||||
|
||||
// Change what happens in case transport is in progress right now
|
||||
auto ctb = ControlToolBar::Find( *GetActiveProject() );
|
||||
if (ctb)
|
||||
ctb->StartScrollingIfPreferred();
|
||||
|
||||
auto &ruler = AdornedRulerPanel::Get( project );
|
||||
// Update button image
|
||||
ruler.UpdateButtonStates();
|
||||
|
@ -35,6 +35,27 @@ public:
|
||||
void SetTimerRecordCancelled() { mTimerRecordCanceled = true; }
|
||||
void ResetTimerRecordCancelled() { mTimerRecordCanceled = false; }
|
||||
|
||||
bool Paused() const { return mPaused; }
|
||||
|
||||
bool Playing() const;
|
||||
|
||||
// Whether recording into this project (not just into some project) is
|
||||
// active
|
||||
bool Recording() const;
|
||||
|
||||
bool Stopping() const { return mStopping; }
|
||||
|
||||
// Whether the last attempt to start recording requested appending to tracks
|
||||
bool Appending() const { return mAppending; }
|
||||
bool Looping() const { return mLooping; }
|
||||
bool Cutting() const { return mCutting; }
|
||||
|
||||
void SetPaused( bool value ) { mPaused = value; }
|
||||
void SetAppending( bool value ) { mAppending = value; }
|
||||
void SetLooping( bool value ) { mLooping = value; }
|
||||
void SetCutting( bool value ) { mCutting = value; }
|
||||
void SetStopping( bool value ) { mStopping = value; }
|
||||
|
||||
private:
|
||||
// Audio IO callback methods
|
||||
void OnAudioIORate(int rate) override;
|
||||
@ -48,6 +69,12 @@ private:
|
||||
|
||||
//flag for cancellation of timer record.
|
||||
bool mTimerRecordCanceled{ false };
|
||||
|
||||
bool mPaused{ false };
|
||||
bool mAppending{ false };
|
||||
bool mLooping{ false };
|
||||
bool mCutting{ false };
|
||||
bool mStopping{ false };
|
||||
};
|
||||
|
||||
AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project );
|
||||
|
@ -822,7 +822,6 @@ void ProjectWindow::Init()
|
||||
wxString msg = wxString::Format(_("Welcome to Audacity version %s"),
|
||||
AUDACITY_VERSION_STRING);
|
||||
statusBar->SetStatusText(msg, mainStatusBarField);
|
||||
ControlToolBar::Get( project ).UpdateStatusBar( &project );
|
||||
|
||||
wxTheApp->Bind(EVT_THEME_CHANGE, &ProjectWindow::OnThemeChange, this);
|
||||
|
||||
|
@ -42,8 +42,7 @@ namespace {
|
||||
/// and pops the play button up. Then, if nothing is now
|
||||
/// playing, it pushes the play button down and enables
|
||||
/// the stop button.
|
||||
bool MakeReadyToPlay(AudacityProject &project,
|
||||
bool loop = false, bool cutpreview = false)
|
||||
bool MakeReadyToPlay(AudacityProject &project)
|
||||
{
|
||||
auto &toolbar = ControlToolBar::Get( project );
|
||||
wxCommandEvent evt;
|
||||
@ -53,8 +52,9 @@ bool MakeReadyToPlay(AudacityProject &project,
|
||||
if (gAudioIO->IsStreamActive(
|
||||
ProjectAudioIO::Get( project ).GetAudioIOToken()
|
||||
)) {
|
||||
// Make momentary changes of button appearances
|
||||
toolbar.SetPlay(false); //Pops
|
||||
toolbar.SetStop(true); //Pushes stop down
|
||||
toolbar.SetStop(); //Pushes stop down
|
||||
toolbar.OnStop(evt);
|
||||
|
||||
::wxMilliSleep(100);
|
||||
@ -65,13 +65,6 @@ bool MakeReadyToPlay(AudacityProject &project,
|
||||
if (gAudioIO->IsBusy())
|
||||
return false;
|
||||
|
||||
ControlToolBar::PlayAppearance appearance =
|
||||
cutpreview ? ControlToolBar::PlayAppearance::CutPreview
|
||||
: loop ? ControlToolBar::PlayAppearance::Looped
|
||||
: ControlToolBar::PlayAppearance::Straight;
|
||||
toolbar.SetPlay(true, appearance);
|
||||
toolbar.SetStop(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,8 +90,7 @@ void DoPlayStop(const CommandContext &context)
|
||||
//If this project is playing, stop playing, make sure everything is unpaused.
|
||||
auto gAudioIO = AudioIOBase::Get();
|
||||
if (gAudioIO->IsStreamActive(token)) {
|
||||
toolbar.SetPlay(false); //Pops
|
||||
toolbar.SetStop(true); //Pushes stop down
|
||||
toolbar.SetStop(); //Pushes stop down
|
||||
toolbar.StopPlaying();
|
||||
}
|
||||
else if (gAudioIO->IsStreamActive()) {
|
||||
@ -116,8 +108,7 @@ void DoPlayStop(const CommandContext &context)
|
||||
if(iter != finish) {
|
||||
auto otherProject = *iter;
|
||||
auto &otherToolbar = ControlToolBar::Get( *otherProject );
|
||||
otherToolbar.SetPlay(false); //Pops
|
||||
otherToolbar.SetStop(true); //Pushes stop down
|
||||
otherToolbar.SetStop(); //Pushes stop down
|
||||
otherToolbar.StopPlaying();
|
||||
}
|
||||
|
||||
@ -126,8 +117,6 @@ void DoPlayStop(const CommandContext &context)
|
||||
//update the playing area
|
||||
window.TP_DisplaySelection();
|
||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||
//toolbar->SetPlay(true); // Not needed as done in PlayPlayRegion.
|
||||
toolbar.SetStop(false);
|
||||
|
||||
// Will automatically set mLastPlayMode
|
||||
toolbar.PlayCurrentRegion(false);
|
||||
@ -135,8 +124,6 @@ void DoPlayStop(const CommandContext &context)
|
||||
}
|
||||
else if (!gAudioIO->IsBusy()) {
|
||||
//Otherwise, start playing (assuming audio I/O isn't busy)
|
||||
//toolbar->SetPlay(true); // Not needed as done in PlayPlayRegion.
|
||||
toolbar.SetStop(false);
|
||||
|
||||
// Will automatically set mLastPlayMode
|
||||
toolbar.PlayCurrentRegion(false);
|
||||
@ -223,7 +210,7 @@ void OnPlayLooped(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
|
||||
if( !MakeReadyToPlay(project, true) )
|
||||
if( !MakeReadyToPlay(project) )
|
||||
return;
|
||||
|
||||
// Now play in a loop
|
||||
@ -247,11 +234,8 @@ void OnRecord(const CommandContext &context)
|
||||
void OnRecord2ndChoice(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
wxCommandEvent evt;
|
||||
evt.SetInt(1); // 0 is default, use 1 to set shift on, 2 to clear it
|
||||
|
||||
auto &controlToolBar = ControlToolBar::Get( project );
|
||||
controlToolBar.OnRecord(evt);
|
||||
controlToolBar.OnRecord(true);
|
||||
}
|
||||
|
||||
void OnTimerRecord(const CommandContext &context)
|
||||
@ -793,7 +777,7 @@ void OnPlayCutPreview(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
|
||||
if ( !MakeReadyToPlay(project, false, true) )
|
||||
if ( !MakeReadyToPlay(project) )
|
||||
return;
|
||||
|
||||
// Play with cut preview
|
||||
|
@ -99,6 +99,7 @@ BEGIN_EVENT_TABLE(ControlToolBar, ToolBar)
|
||||
EVT_BUTTON(ID_REW_BUTTON, ControlToolBar::OnRewind)
|
||||
EVT_BUTTON(ID_FF_BUTTON, ControlToolBar::OnFF)
|
||||
EVT_BUTTON(ID_PAUSE_BUTTON, ControlToolBar::OnPause)
|
||||
EVT_IDLE(ControlToolBar::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
//Standard constructor
|
||||
@ -109,8 +110,6 @@ END_EVENT_TABLE()
|
||||
ControlToolBar::ControlToolBar( AudacityProject &project )
|
||||
: ToolBar(project, TransportBarID, _("Transport"), wxT("Control"))
|
||||
{
|
||||
mPaused = false;
|
||||
|
||||
gPrefs->Read(wxT("/GUI/ErgonomicTransportButtons"), &mErgonomicTransportButtons, true);
|
||||
mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
|
||||
|
||||
@ -456,7 +455,8 @@ void ControlToolBar::ReCreateButtons()
|
||||
|
||||
if (recordDown)
|
||||
{
|
||||
SetRecord(recordDown, recordShift);
|
||||
mRecord->SetAlternateIdx(recordShift ? 1 : 0);
|
||||
mRecord->PushDown();
|
||||
}
|
||||
|
||||
EnableDisableButtons();
|
||||
@ -495,8 +495,8 @@ void ControlToolBar::EnableDisableButtons()
|
||||
!(playing && !paused)
|
||||
);
|
||||
mStop->SetEnabled(CanStopAudioStream() && (playing || recording));
|
||||
mRewind->SetEnabled(IsPauseDown() || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (IsPauseDown() || (!playing && !recording)));
|
||||
mRewind->SetEnabled(paused || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (paused || (!playing && !recording)));
|
||||
|
||||
mPause->SetEnabled(CanStopAudioStream());
|
||||
}
|
||||
@ -514,46 +514,14 @@ void ControlToolBar::SetPlay(bool down, PlayAppearance appearance)
|
||||
mPlay->SetAlternateIdx(0);
|
||||
}
|
||||
EnableDisableButtons();
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
|
||||
void ControlToolBar::SetStop(bool down)
|
||||
void ControlToolBar::SetStop()
|
||||
{
|
||||
if (down)
|
||||
mStop->PushDown();
|
||||
else {
|
||||
if(FindFocus() == mStop)
|
||||
mPlay->SetFocus();
|
||||
mStop->PopUp();
|
||||
}
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
void ControlToolBar::SetRecord(bool down, bool altAppearance)
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
mRecord->SetAlternateIdx(altAppearance ? 1 : 0);
|
||||
mRecord->PushDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
mRecord->SetAlternateIdx(0);
|
||||
mRecord->PopUp();
|
||||
}
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsPauseDown() const
|
||||
{
|
||||
return mPause->IsDown();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsRecordDown() const
|
||||
{
|
||||
return mRecord->IsDown();
|
||||
}
|
||||
|
||||
int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
const AudioIOStartStreamOptions &options,
|
||||
PlayMode mode,
|
||||
@ -561,6 +529,8 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
bool playWhiteSpace /* = false */)
|
||||
// STRONG-GUARANTEE (for state of mCutPreviewTracks)
|
||||
{
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
if (!CanStopAudioStream())
|
||||
return -1;
|
||||
|
||||
@ -582,27 +552,10 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
if (backwards)
|
||||
std::swap(t0, t1);
|
||||
|
||||
{
|
||||
PlayAppearance appearance;
|
||||
switch( mode ) {
|
||||
case PlayMode::cutPreviewPlay:
|
||||
appearance = PlayAppearance::CutPreview; break;
|
||||
case PlayMode::loopedPlay:
|
||||
appearance = PlayAppearance::Looped; break;
|
||||
default:
|
||||
appearance = PlayAppearance::Straight; break;
|
||||
}
|
||||
SetPlay(true, appearance);
|
||||
}
|
||||
projectAudioManager.SetLooping( mode == PlayMode::loopedPlay );
|
||||
projectAudioManager.SetCutting( mode == PlayMode::cutPreviewPlay );
|
||||
|
||||
bool success = false;
|
||||
auto cleanup = finally( [&] {
|
||||
if (!success) {
|
||||
SetPlay(false);
|
||||
SetStop(false);
|
||||
SetRecord(false);
|
||||
}
|
||||
} );
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
if (gAudioIO->IsBusy())
|
||||
@ -738,8 +691,6 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
|
||||
if (!success)
|
||||
return -1;
|
||||
|
||||
StartScrollingIfPreferred();
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
@ -771,26 +722,28 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
|
||||
|
||||
void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
|
||||
{
|
||||
// PRL: is this handler really ever reached? Is the ControlToolBar ever
|
||||
// focused? Isn't there a global event filter that interprets the spacebar
|
||||
// key (or other key chosen in preferences) and dispatches to DoPlayStop,
|
||||
// according to CommandManager's table, before we come to this redundant
|
||||
// function?
|
||||
|
||||
if (event.ControlDown() || event.AltDown()) {
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
auto gAudioIO = AudioIOBase::Get();
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
// Does not appear to be needed on Linux. Perhaps on some other platform?
|
||||
// If so, "!CanStopAudioStream()" should probably apply.
|
||||
if (event.GetKeyCode() == WXK_SPACE) {
|
||||
if (gAudioIO->IsStreamActive(
|
||||
ProjectAudioIO::Get( mProject ).GetAudioIOToken()
|
||||
)) {
|
||||
SetPlay(false);
|
||||
SetStop(true);
|
||||
if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
|
||||
SetStop();
|
||||
StopPlaying();
|
||||
}
|
||||
else if (!gAudioIO->IsBusy()) {
|
||||
//SetPlay(true);// Not needed as done in PlayPlayRegion
|
||||
SetStop(false);
|
||||
PlayCurrentRegion();
|
||||
}
|
||||
return;
|
||||
@ -810,7 +763,6 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
|
||||
if (p)
|
||||
ProjectWindow::Get( *p ).TP_DisplaySelection();
|
||||
|
||||
auto cleanup = finally( [&]{ UpdateStatusBar(p); } );
|
||||
PlayDefault();
|
||||
}
|
||||
|
||||
@ -818,7 +770,6 @@ void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
if (CanStopAudioStream()) {
|
||||
StopPlaying();
|
||||
UpdateStatusBar( &mProject );
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,9 +792,8 @@ void ControlToolBar::PlayDefault()
|
||||
|
||||
void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
||||
{
|
||||
StopScrolling();
|
||||
|
||||
AudacityProject *project = &mProject;
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
if(project) {
|
||||
// Let scrubbing code do some appearance change
|
||||
@ -854,24 +804,33 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
||||
if (!CanStopAudioStream())
|
||||
return;
|
||||
|
||||
mStop->PushDown();
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
|
||||
SetStop(false);
|
||||
auto cleanup = finally( [&]{
|
||||
projectAudioManager.SetStopping( false );
|
||||
} );
|
||||
|
||||
if (stopStream && gAudioIO->IsBusy()) {
|
||||
// flag that we are stopping
|
||||
projectAudioManager.SetStopping( true );
|
||||
// Allow UI to update for that
|
||||
while( wxTheApp->ProcessIdle() )
|
||||
;
|
||||
}
|
||||
|
||||
if(stopStream)
|
||||
gAudioIO->StopStream();
|
||||
SetPlay(false);
|
||||
SetRecord(false);
|
||||
|
||||
projectAudioManager.SetLooping( false );
|
||||
projectAudioManager.SetCutting( false );
|
||||
|
||||
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
|
||||
gAudioIO->AILADisable();
|
||||
#endif
|
||||
|
||||
mPause->PopUp();
|
||||
mPaused=false;
|
||||
projectAudioManager.SetPaused( false );
|
||||
//Make sure you tell gAudioIO to unpause
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
gAudioIO->SetPaused( false );
|
||||
|
||||
ClearCutPreviewTracks();
|
||||
|
||||
@ -987,19 +946,20 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
// Here instead we reduplicate some logic (from CommandHandler) because it isn't
|
||||
// normally used for buttons.
|
||||
|
||||
// Code from CommandHandler start...
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
bool altAppearance = mRecord->WasShiftDown();
|
||||
if (evt.GetInt() == 1) // used when called by keyboard shortcut. Default (0) ignored.
|
||||
altAppearance = true;
|
||||
if (evt.GetInt() == 2)
|
||||
altAppearance = false;
|
||||
OnRecord( altAppearance );
|
||||
}
|
||||
|
||||
void ControlToolBar::OnRecord(bool altAppearance)
|
||||
// STRONG-GUARANTEE (for state of current project's tracks)
|
||||
{
|
||||
bool bPreferNewTrack;
|
||||
gPrefs->Read("/GUI/PreferNewTrackRecord", &bPreferNewTrack, false);
|
||||
const bool appendRecord = (altAppearance == bPreferNewTrack);
|
||||
|
||||
// Code from CommandHandler start...
|
||||
AudacityProject *p = &mProject;
|
||||
|
||||
if (p) {
|
||||
const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
|
||||
double t0 = selectedRegion.t0();
|
||||
@ -1075,6 +1035,8 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
bool altAppearance,
|
||||
const AudioIOStartStreamOptions &options)
|
||||
{
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
|
||||
|
||||
// NB: The call may have the side effect of changing flags.
|
||||
@ -1087,27 +1049,12 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
// ...end of code from CommandHandler.
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
if (gAudioIO->IsBusy()) {
|
||||
if (!CanStopAudioStream() || 0 == gAudioIO->GetNumCaptureChannels())
|
||||
mRecord->PopUp();
|
||||
else
|
||||
mRecord->PushDown();
|
||||
if (gAudioIO->IsBusy())
|
||||
return false;
|
||||
}
|
||||
|
||||
SetRecord(true, altAppearance);
|
||||
projectAudioManager.SetAppending( !altAppearance );
|
||||
|
||||
bool success = false;
|
||||
auto cleanup = finally([&] {
|
||||
if (!success) {
|
||||
SetPlay(false);
|
||||
SetStop(false);
|
||||
SetRecord(false);
|
||||
}
|
||||
|
||||
// Success or not:
|
||||
UpdateStatusBar( &mProject );
|
||||
});
|
||||
|
||||
auto transportTracks = tracks;
|
||||
|
||||
@ -1259,8 +1206,6 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
if (success) {
|
||||
ProjectAudioIO::Get( *p ).SetAudioIOToken(token);
|
||||
mBusyProject = p;
|
||||
|
||||
StartScrollingIfPreferred();
|
||||
}
|
||||
else {
|
||||
CancelRecording();
|
||||
@ -1277,21 +1222,14 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
||||
|
||||
void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
if (!CanStopAudioStream()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(mPaused)
|
||||
{
|
||||
mPause->PopUp();
|
||||
mPaused=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPause->PushDown();
|
||||
mPaused=true;
|
||||
}
|
||||
bool paused = !projectAudioManager.Paused();
|
||||
projectAudioManager.SetPaused( paused );
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
|
||||
@ -1302,7 +1240,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
|
||||
// Bug 1494 - Pausing a seek or scrub should just STOP as
|
||||
// it is confusing to be in a paused scrub state.
|
||||
bool bStopInstead = mPaused &&
|
||||
bool bStopInstead = paused &&
|
||||
gAudioIO->IsScrubbing() &&
|
||||
!scrubber.IsSpeedPlaying();
|
||||
|
||||
@ -1313,14 +1251,69 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
}
|
||||
|
||||
if (gAudioIO->IsScrubbing())
|
||||
scrubber.Pause(mPaused);
|
||||
scrubber.Pause(paused);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
gAudioIO->SetPaused(paused);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlToolBar::OnIdle(wxIdleEvent & event)
|
||||
{
|
||||
event.Skip();
|
||||
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
if ( projectAudioManager.Paused() )
|
||||
mPause->PushDown();
|
||||
else
|
||||
mPause->PopUp();
|
||||
|
||||
bool recording = projectAudioManager.Recording();
|
||||
if (!recording) {
|
||||
mRecord->PopUp();
|
||||
mRecord->SetAlternateIdx( wxGetKeyState(WXK_SHIFT) ? 1 : 0 );
|
||||
}
|
||||
else {
|
||||
mRecord->PushDown();
|
||||
mRecord->SetAlternateIdx( projectAudioManager.Appending() ? 0 : 1 );
|
||||
}
|
||||
|
||||
UpdateStatusBar( &mProject );
|
||||
bool playing = projectAudioManager.Playing();
|
||||
if ( !(playing || Scrubber::Get(mProject).HasMark()) ) {
|
||||
mPlay->PopUp();
|
||||
mPlay->SetAlternateIdx(
|
||||
wxGetKeyState(WXK_CONTROL)
|
||||
? 2
|
||||
: wxGetKeyState(WXK_SHIFT)
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
else {
|
||||
mPlay->PushDown();
|
||||
mPlay->SetAlternateIdx(
|
||||
projectAudioManager.Cutting()
|
||||
? 2
|
||||
: projectAudioManager.Looping()
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
if ( recording || playing )
|
||||
StartScrollingIfPreferred();
|
||||
else
|
||||
StopScrolling();
|
||||
|
||||
if ( projectAudioManager.Stopping() )
|
||||
mStop->PushDown();
|
||||
else
|
||||
// push-downs of the stop button are only momentary and always pop up now
|
||||
mStop->PopUp();
|
||||
|
||||
UpdateStatusBar();
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||
@ -1409,6 +1402,7 @@ int ControlToolBar::WidthForStatusBar(wxStatusBar* const sb)
|
||||
wxString ControlToolBar::StateForStatusBar()
|
||||
{
|
||||
wxString state;
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
auto pProject = &mProject;
|
||||
auto scrubState = pProject
|
||||
@ -1418,7 +1412,7 @@ wxString ControlToolBar::StateForStatusBar()
|
||||
state = wxGetTranslation(scrubState);
|
||||
else if (mPlay->IsDown())
|
||||
state = wxGetTranslation(mStatePlay);
|
||||
else if (mRecord->IsDown())
|
||||
else if (projectAudioManager.Recording())
|
||||
state = wxGetTranslation(mStateRecord);
|
||||
else
|
||||
state = wxGetTranslation(mStateStop);
|
||||
@ -1434,9 +1428,9 @@ wxString ControlToolBar::StateForStatusBar()
|
||||
return state;
|
||||
}
|
||||
|
||||
void ControlToolBar::UpdateStatusBar(AudacityProject *pProject)
|
||||
void ControlToolBar::UpdateStatusBar()
|
||||
{
|
||||
GetProjectFrame( *pProject )
|
||||
GetProjectFrame( mProject )
|
||||
.GetStatusBar()->SetStatusText(StateForStatusBar(), stateStatusBarField);
|
||||
}
|
||||
|
||||
@ -1474,12 +1468,12 @@ void ControlToolBar::StartScrolling()
|
||||
using Mode = ProjectWindow::PlaybackScroller::Mode;
|
||||
const auto project = &mProject;
|
||||
if (project) {
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
auto mode = Mode::Pinned;
|
||||
|
||||
#if 0
|
||||
// Enable these lines to pin the playhead right instead of center,
|
||||
// when recording but not overdubbing.
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
if (gAudioIO->GetNumCaptureChannels() > 0) {
|
||||
// recording
|
||||
|
||||
|
@ -77,6 +77,7 @@ class ControlToolBar final : public ToolBar {
|
||||
void OnPlay(wxCommandEvent & evt);
|
||||
void OnStop(wxCommandEvent & evt);
|
||||
void OnRecord(wxCommandEvent & evt);
|
||||
void OnRecord(bool altAppearance);
|
||||
bool DoRecord(AudacityProject &project,
|
||||
const TransportTracks &transportTracks, // If captureTracks is empty, then tracks are created
|
||||
double t0, double t1,
|
||||
@ -84,6 +85,7 @@ class ControlToolBar final : public ToolBar {
|
||||
const AudioIOStartStreamOptions &options);
|
||||
void OnFF(wxCommandEvent & evt);
|
||||
void OnPause(wxCommandEvent & evt);
|
||||
void OnIdle(wxIdleEvent & event);
|
||||
|
||||
// Choice among the appearances of the play button:
|
||||
enum class PlayAppearance {
|
||||
@ -92,11 +94,7 @@ class ControlToolBar final : public ToolBar {
|
||||
|
||||
//These allow buttons to be controlled externally:
|
||||
void SetPlay(bool down, PlayAppearance appearance = PlayAppearance::Straight);
|
||||
void SetStop(bool down);
|
||||
void SetRecord(bool down, bool altAppearance = false);
|
||||
|
||||
bool IsPauseDown() const;
|
||||
bool IsRecordDown() const;
|
||||
void SetStop();
|
||||
|
||||
// A project is only allowed to stop an audio stream that it owns.
|
||||
bool CanStopAudioStream () const;
|
||||
@ -128,7 +126,6 @@ class ControlToolBar final : public ToolBar {
|
||||
void RegenerateTooltips() override;
|
||||
|
||||
int WidthForStatusBar(wxStatusBar* const);
|
||||
void UpdateStatusBar(AudacityProject *pProject);
|
||||
|
||||
// Starting and stopping of scrolling display
|
||||
void StartScrollingIfPreferred();
|
||||
@ -141,6 +138,7 @@ class ControlToolBar final : public ToolBar {
|
||||
PlayMode GetLastPlayMode() const { return mLastPlayMode; }
|
||||
|
||||
private:
|
||||
void UpdateStatusBar();
|
||||
|
||||
static AButton *MakeButton(
|
||||
ControlToolBar *pBar,
|
||||
@ -181,9 +179,6 @@ class ControlToolBar final : public ToolBar {
|
||||
|
||||
static AudacityProject *mBusyProject;
|
||||
|
||||
// Maybe button state values shouldn't be duplicated in this toolbar?
|
||||
bool mPaused; //Play or record is paused or not paused?
|
||||
|
||||
// Activate ergonomic order for transport buttons
|
||||
bool mErgonomicTransportButtons;
|
||||
|
||||
|
@ -330,14 +330,12 @@ void Scrubber::MarkScrubStart(
|
||||
mSeeking = seek;
|
||||
CheckMenuItems();
|
||||
|
||||
ctb.SetPlay(true, ControlToolBar::PlayAppearance::Straight );
|
||||
// Commented out for Bug 1421
|
||||
// mSeeking
|
||||
// ? ControlToolBar::PlayAppearance::Seek
|
||||
// : ControlToolBar::PlayAppearance::Scrub);
|
||||
|
||||
mScrubStartPosition = xx;
|
||||
ctb.UpdateStatusBar(mProject);
|
||||
mCancelled = false;
|
||||
}
|
||||
|
||||
@ -674,8 +672,6 @@ void Scrubber::ContinueScrubbingUI()
|
||||
// Show the correct status for seeking.
|
||||
bool backup = mSeeking;
|
||||
mSeeking = seek;
|
||||
auto &ctb = ControlToolBar::Get( *mProject );
|
||||
ctb.UpdateStatusBar(mProject);
|
||||
mSeeking = backup;
|
||||
}
|
||||
|
||||
@ -735,14 +731,6 @@ void Scrubber::StopScrubbing()
|
||||
mDragging = false;
|
||||
mSeeking = false;
|
||||
|
||||
if (!IsScrubbing())
|
||||
{
|
||||
// Marked scrub start, but
|
||||
// didn't really play, but did change button apperance
|
||||
auto &ctb = ControlToolBar::Get( *mProject );
|
||||
ctb.SetPlay(false, ControlToolBar::PlayAppearance::Straight);
|
||||
}
|
||||
|
||||
AdornedRulerPanel::Get( *mProject ).DrawBothOverlays();
|
||||
CheckMenuItems();
|
||||
}
|
||||
@ -872,9 +860,7 @@ void Scrubber::OnActivateOrDeactivateApp(wxActivateEvent &event)
|
||||
// Pause if Pause down, or not scrubbing.
|
||||
if (!mProject)
|
||||
Pause(true);
|
||||
else if ( !ControlToolBar::Find( *mProject ) )
|
||||
Pause( true );
|
||||
else if (ControlToolBar::Get( *mProject ).IsPauseDown())
|
||||
else if (ProjectAudioManager::Get( *mProject ).Paused())
|
||||
Pause( true );
|
||||
else if (!IsScrubbing())
|
||||
Pause( true );
|
||||
@ -1107,12 +1093,6 @@ void Scrubber::OnScrubOrSeek(bool seek)
|
||||
{
|
||||
DoScrub(seek);
|
||||
|
||||
if (HasMark()) {
|
||||
// Show the correct status.
|
||||
auto &ctb = ControlToolBar::Get( *mProject );
|
||||
ctb.UpdateStatusBar(mProject);
|
||||
}
|
||||
|
||||
mSeeking = seek;
|
||||
CheckMenuItems();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user