diff --git a/src/ProjectAudioManager.cpp b/src/ProjectAudioManager.cpp index b974e7af0..d927e900f 100644 --- a/src/ProjectAudioManager.cpp +++ b/src/ProjectAudioManager.cpp @@ -30,10 +30,8 @@ Paul Licameli split from ProjectManager.cpp #include "ProjectStatus.h" #include "TimeTrack.h" #include "TrackPanel.h" -#include "UndoManager.h" #include "ViewInfo.h" #include "WaveTrack.h" -#include "toolbars/ControlToolBar.h" #include "toolbars/ToolManager.h" #include "prefs/TracksPrefs.h" #include "tracks/ui/Scrubbing.h" @@ -1018,14 +1016,9 @@ void ProjectAudioManager::StopIfPaused() #include "widgets/AudacityMessageBox.h" -namespace TransportActions { - -// exported helper functions - -bool DoPlayStopSelect -(AudacityProject &project, bool click, bool shift) +bool ProjectAudioManager::DoPlayStopSelect( bool click, bool shift ) { - auto &toolbar = ControlToolBar::Get( project ); + auto &project = mProject; auto &scrubber = Scrubber::Get( project ); auto token = ProjectAudioIO::Get( project ).GetAudioIOToken(); auto &viewInfo = ViewInfo::Get( project ); @@ -1035,8 +1028,6 @@ bool DoPlayStopSelect //If busy, stop playing, make sure everything is unpaused. if (scrubber.HasMark() || gAudioIO->IsStreamActive(token)) { - toolbar.SetStop(); //Pushes stop down - // change the selection auto time = gAudioIO->GetStreamTime(); // Test WasSpeedPlaying(), not IsSpeedPlaying() @@ -1081,22 +1072,19 @@ bool DoPlayStopSelect // The code for "OnPlayStopSelect" is simply the code of "OnPlayStop" and // "OnStopSelect" merged. -void DoPlayStopSelect(AudacityProject &project) +void ProjectAudioManager::DoPlayStopSelect() { - auto &projectAudioManager = ProjectAudioManager::Get( project ); auto gAudioIO = AudioIO::Get(); - if (DoPlayStopSelect(project, false, false)) - projectAudioManager.Stop(); + if (DoPlayStopSelect(false, false)) + Stop(); else if (!gAudioIO->IsBusy()) { //Otherwise, start playing (assuming audio I/O isn't busy) // Will automatically set mLastPlayMode - projectAudioManager.PlayCurrentRegion(false); + PlayCurrentRegion(false); } } -} - #include "CommonCommandFlags.h" static RegisteredMenuItemEnabler stopIfPaused{{ diff --git a/src/ProjectAudioManager.h b/src/ProjectAudioManager.h index a450af063..e62539034 100644 --- a/src/ProjectAudioManager.h +++ b/src/ProjectAudioManager.h @@ -110,6 +110,9 @@ public: void StopIfPaused(); + bool DoPlayStopSelect( bool click, bool shift ); + void DoPlayStopSelect( ); + PlayMode GetLastPlayMode() const { return mLastPlayMode; } private: @@ -163,10 +166,4 @@ AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project ); extern const ReservedCommandFlag CanStopAudioStreamFlag; -/// Namespace for functions for Transport menu -namespace TransportActions { -bool DoPlayStopSelect( AudacityProject &project, bool click, bool shift ); -void DoPlayStopSelect( AudacityProject &project ); -} - #endif diff --git a/src/menus/TransportMenus.cpp b/src/menus/TransportMenus.cpp index 762747c91..38d3a99c3 100644 --- a/src/menus/TransportMenus.cpp +++ b/src/menus/TransportMenus.cpp @@ -207,7 +207,7 @@ void OnPlayStop(const CommandContext &context) void OnPlayStopSelect(const CommandContext &context) { - DoPlayStopSelect( context.project ); + ProjectAudioManager::Get( context.project ).DoPlayStopSelect(); } void OnPlayLooped(const CommandContext &context) diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index 0be956e50..6d236b3e7 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -661,8 +661,9 @@ void Scrubber::ContinueScrubbingUI() // Dragging scrub can stop with mouse up // Stop and set cursor bool bShift = state.ShiftDown(); - TransportActions::DoPlayStopSelect(*mProject, true, bShift); - ProjectAudioManager::Get( *mProject ).Stop(); + auto &projectAudioManager = ProjectAudioManager::Get( *mProject ); + projectAudioManager.DoPlayStopSelect( true, bShift ); + projectAudioManager.Stop(); return; } @@ -724,7 +725,8 @@ void Scrubber::StopScrubbing() const wxMouseState state(::wxGetMouseState()); // Stop and set cursor bool bShift = state.ShiftDown(); - TransportActions::DoPlayStopSelect(*mProject, true, bShift); + auto &projectAudioManager = ProjectAudioManager::Get( *mProject ); + projectAudioManager.DoPlayStopSelect(true, bShift); } mScrubStartPosition = -1;