1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-14 15:48:21 +02:00

New attached structure ProjectManager handles project lifetime...

... that is, a factory function, open, close, import, undo/redo/rollback.

Also the callbacks from AudioIO, which need to invoke undo history push when
recording stops.

It is meant as a high-level class using several of the other things attached
to the project, while AudacityProject will be a low level class acting mostly
as just the container of the attached structures.
This commit is contained in:
Paul Licameli 2019-04-29 02:22:08 -04:00
parent c629d44c41
commit 4274d44ab7
50 changed files with 706 additions and 551 deletions

View File

@ -810,9 +810,8 @@ void AudacityApp::MacNewFile()
// This method should only be used on the Mac platform // This method should only be used on the Mac platform
// when no project windows are open. // when no project windows are open.
if (AllProjects{}.empty()) { if (AllProjects{}.empty())
CreateNewAudacityProject(); (void) ProjectManager::New();
}
} }
#endif //__WXMAC__ #endif //__WXMAC__
@ -880,7 +879,7 @@ bool AudacityApp::MRUOpen(const FilePath &fullPathStr) {
// Test here even though AudacityProject::OpenFile() also now checks, because // Test here even though AudacityProject::OpenFile() also now checks, because
// that method does not return the bad result. // that method does not return the bad result.
// That itself may be a FIXME. // That itself may be a FIXME.
if (AudacityProject::IsAlreadyOpen(fullPathStr)) if (ProjectManager::IsAlreadyOpen(fullPathStr))
return false; return false;
// DMM: If the project is dirty, that means it's been touched at // DMM: If the project is dirty, that means it's been touched at
@ -893,12 +892,15 @@ bool AudacityApp::MRUOpen(const FilePath &fullPathStr) {
// there are no tracks, but there's an Undo history, etc, then // there are no tracks, but there's an Undo history, etc, then
// bad things can happen, including data files moving to the NEW // bad things can happen, including data files moving to the NEW
// project directory, etc. // project directory, etc.
if (proj && (proj->GetDirty() || !TrackList::Get( *proj ).empty())) if (proj && (
ProjectManager::Get( *proj ).GetDirty() ||
!TrackList::Get( *proj ).empty()
) )
proj = nullptr; proj = nullptr;
// This project is clean; it's never been touched. Therefore // This project is clean; it's never been touched. Therefore
// all relevant member variables are in their initial state, // all relevant member variables are in their initial state,
// and it's okay to open a NEW project inside this window. // and it's okay to open a NEW project inside this window.
AudacityProject::OpenProject( proj, fullPathStr ); ( void ) ProjectManager::OpenProject( proj, fullPathStr );
} }
else { else {
// File doesn't exist - remove file from history // File doesn't exist - remove file from history
@ -936,7 +938,7 @@ void AudacityApp::OnMRUFile(wxCommandEvent& event) {
// PRL: Don't call SafeMRUOpen // PRL: Don't call SafeMRUOpen
// -- if open fails for some exceptional reason of resource exhaustion that // -- if open fails for some exceptional reason of resource exhaustion that
// the user can correct, leave the file in history. // the user can correct, leave the file in history.
if (!AudacityProject::IsAlreadyOpen(fullPathStr) && !MRUOpen(fullPathStr)) if (!ProjectManager::IsAlreadyOpen(fullPathStr) && !MRUOpen(fullPathStr))
history.RemoveFileFromHistory(n); history.RemoveFileFromHistory(n);
} }
@ -1073,7 +1075,7 @@ bool AudacityApp::OnExceptionInMainLoop()
// Restore the state of the project to what it was before the // Restore the state of the project to what it was before the
// failed operation // failed operation
if (pProject) { if (pProject) {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
// Forget pending changes in the TrackList // Forget pending changes in the TrackList
TrackList::Get( *pProject ).ClearPendingTracks(); TrackList::Get( *pProject ).ClearPendingTracks();
@ -1511,7 +1513,7 @@ bool AudacityApp::OnInit()
// Root cause is problem with wxSplashScreen and other dialogs co-existing, that // Root cause is problem with wxSplashScreen and other dialogs co-existing, that
// seemed to arrive with wx3. // seemed to arrive with wx3.
{ {
project = CreateNewAudacityProject(); project = ProjectManager::New();
mCmdHandler->SetProject(project); mCmdHandler->SetProject(project);
wxWindow * pWnd = MakeHijackPanel(); wxWindow * pWnd = MakeHijackPanel();
if (pWnd) if (pWnd)
@ -2081,7 +2083,7 @@ void AudacityApp::OnMenuNew(wxCommandEvent & event)
// all platforms. // all platforms.
if(AllProjects{}.empty()) if(AllProjects{}.empty())
CreateNewAudacityProject(); (void) ProjectManager::New();
else else
event.Skip(); event.Skip();
} }
@ -2097,7 +2099,7 @@ void AudacityApp::OnMenuOpen(wxCommandEvent & event)
if(AllProjects{}.empty()) if(AllProjects{}.empty())
AudacityProject::OpenFiles(NULL); ProjectManager::OpenFiles(NULL);
else else
event.Skip(); event.Skip();

View File

@ -227,7 +227,7 @@ static bool RecoverAllProjects(AudacityProject** pproj)
// Open project. When an auto-save file has been opened successfully, // Open project. When an auto-save file has been opened successfully,
// the opened auto-save file is automatically deleted and a NEW one // the opened auto-save file is automatically deleted and a NEW one
// is created. // is created.
AudacityProject::OpenProject( proj, files[i], false ); (void) ProjectManager::OpenProject( proj, files[i], false );
} }
return true; return true;

View File

@ -842,7 +842,7 @@ bool MacroCommands::ApplyMacro(
if (!res) { if (!res) {
if(proj) { if(proj) {
// Macro failed or was cancelled; revert to the previous state // Macro failed or was cancelled; revert to the previous state
proj->RollbackState(); ProjectManager::Get( *proj ).RollbackState();
} }
} }
} ); } );
@ -888,7 +888,7 @@ bool MacroCommands::ApplyMacro(
if (!proj) if (!proj)
return false; return false;
if( MacroReentryCount <= 1 ) if( MacroReentryCount <= 1 )
proj->PushState(longDesc, shortDesc); ProjectManager::Get( *proj ).PushState(longDesc, shortDesc);
return true; return true;
} }

View File

@ -461,7 +461,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
fileList->EnsureVisible(i); fileList->EnsureVisible(i);
auto success = GuardedCall< bool >( [&] { auto success = GuardedCall< bool >( [&] {
project->Import(files[i]); ProjectManager::Get( *project ).Import(files[i]);
ProjectWindow::Get( *project ).ZoomAfterImport(nullptr); ProjectWindow::Get( *project ).ZoomAfterImport(nullptr);
SelectActions::DoSelectAll(*project); SelectActions::DoSelectAll(*project);
if (!mMacroCommands.ApplyMacro(mCatalog)) if (!mMacroCommands.ApplyMacro(mCatalog))
@ -476,7 +476,7 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
if (!success) if (!success)
break; break;
project->ResetProjectToEmpty(); ProjectManager::Get( *project ).ResetProjectToEmpty();
} }
Show(); Show();

View File

@ -254,7 +254,7 @@ void HistoryWindow::OnDiscard(wxCommandEvent & WXUNUSED(event))
mSelected -= i; mSelected -= i;
mManager->RemoveStates(i); mManager->RemoveStates(i);
mProject->SetStateTo(mSelected + 1); ProjectManager::Get( *mProject ).SetStateTo(mSelected + 1);
while(--i >= 0) while(--i >= 0)
mList->DeleteItem(i); mList->DeleteItem(i);
@ -292,7 +292,7 @@ void HistoryWindow::OnItemSelected(wxListEvent &event)
// entry. Doing so can cause unnecessary delays upon initial load or while // entry. Doing so can cause unnecessary delays upon initial load or while
// clicking the same entry over and over. // clicking the same entry over and over.
if (selected != mSelected) { if (selected != mSelected) {
mProject->SetStateTo(selected + 1); ProjectManager::Get( *mProject ).SetStateTo(selected + 1);
} }
mSelected = selected; mSelected = selected;

View File

@ -1813,7 +1813,7 @@ unsigned LabelTrack::KeyDown(wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *W
// Pass keystroke to labeltrack's handler and add to history if any // Pass keystroke to labeltrack's handler and add to history if any
// updates were done // updates were done
if (OnKeyDown(viewInfo.selectedRegion, event)) { if (OnKeyDown(viewInfo.selectedRegion, event)) {
pProj->PushState(_("Modified Label"), ProjectManager::Get( *pProj ).PushState(_("Modified Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
} }
@ -1845,7 +1845,7 @@ unsigned LabelTrack::Char(wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *)
AudacityProject *const pProj = GetActiveProject(); AudacityProject *const pProj = GetActiveProject();
if (OnChar(viewInfo.selectedRegion, event)) if (OnChar(viewInfo.selectedRegion, event))
pProj->PushState(_("Modified Label"), ProjectManager::Get( *pProj ).PushState(_("Modified Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
@ -2130,13 +2130,13 @@ bool LabelTrack::OnChar(SelectedRegion &WXUNUSED(newSel), wxKeyEvent & event)
} }
SetSelected(true); SetSelected(true);
AddLabel(selectedRegion, title, -2); AddLabel(selectedRegion, title, -2);
p->PushState(_("Added label"), _("Label")); ProjectManager::Get( *p ).PushState(_("Added label"), _("Label"));
return false; return false;
} }
else { else {
SetSelected(true); SetSelected(true);
AddLabel(selectedRegion); AddLabel(selectedRegion);
p->PushState(_("Added label"), _("Label")); ProjectManager::Get( *p ).PushState(_("Added label"), _("Label"));
} }
} }
@ -2230,7 +2230,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
case OnCutSelectedTextID: case OnCutSelectedTextID:
if (CutSelectedText()) if (CutSelectedText())
{ {
p->PushState(_("Modified Label"), ProjectManager::Get( *p ).PushState(_("Modified Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
} }
@ -2245,7 +2245,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
case OnPasteSelectedTextID: case OnPasteSelectedTextID:
if (PasteSelectedText(selectedRegion.t0(), selectedRegion.t1())) if (PasteSelectedText(selectedRegion.t0(), selectedRegion.t1()))
{ {
p->PushState(_("Modified Label"), ProjectManager::Get( *p ).PushState(_("Modified Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
} }
@ -2257,7 +2257,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
if (ndx != -1) if (ndx != -1)
{ {
DeleteLabel(ndx); DeleteLabel(ndx);
p->PushState(_("Deleted Label"), ProjectManager::Get( *p ).PushState(_("Deleted Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
} }
@ -3104,7 +3104,8 @@ void LabelTrack::DoEditLabels
#endif #endif
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
project.PushState(_("Edited labels"), _("Label")); ProjectManager::Get( project )
.PushState(_("Edited labels"), _("Label"));
window.RedrawProject(); window.RedrawProject();
} }
} }

View File

@ -327,7 +327,8 @@ void MenuManager::ModifyUndoMenuItems(AudacityProject &project)
commandManager.Modify(wxT("Undo"), commandManager.Modify(wxT("Undo"),
wxString::Format(_("&Undo %s"), wxString::Format(_("&Undo %s"),
desc)); desc));
commandManager.Enable(wxT("Undo"), project.UndoAvailable()); commandManager.Enable(wxT("Undo"),
ProjectManager::Get( project ).UndoAvailable());
} }
else { else {
commandManager.Modify(wxT("Undo"), commandManager.Modify(wxT("Undo"),
@ -339,7 +340,8 @@ void MenuManager::ModifyUndoMenuItems(AudacityProject &project)
commandManager.Modify(wxT("Redo"), commandManager.Modify(wxT("Redo"),
wxString::Format(_("&Redo %s"), wxString::Format(_("&Redo %s"),
desc)); desc));
commandManager.Enable(wxT("Redo"), project.RedoAvailable()); commandManager.Enable(wxT("Redo"),
ProjectManager::Get( project ).RedoAvailable());
} }
else { else {
commandManager.Modify(wxT("Redo"), commandManager.Modify(wxT("Redo"),
@ -519,10 +521,11 @@ CommandFlag MenuManager::GetUpdateFlags
if (!mLastEffect.empty()) if (!mLastEffect.empty())
flags |= HasLastEffectFlag; flags |= HasLastEffectFlag;
if (project.UndoAvailable()) auto &projectManager = ProjectManager::Get( project );
if (projectManager.UndoAvailable())
flags |= UndoAvailableFlag; flags |= UndoAvailableFlag;
if (project.RedoAvailable()) if (projectManager.RedoAvailable())
flags |= RedoAvailableFlag; flags |= RedoAvailableFlag;
if (ViewInfo::Get( project ).ZoomInAvailable() && (flags & TracksExistFlag)) if (ViewInfo::Get( project ).ZoomInAvailable() && (flags & TracksExistFlag))

View File

@ -412,7 +412,8 @@ void MixerTrackCluster::HandleSliderGain(const bool bWantPushState /*= false*/)
// Update the TrackPanel correspondingly. // Update the TrackPanel correspondingly.
TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get()); TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
if (bWantPushState) if (bWantPushState)
mProject->PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE ); ProjectManager::Get( *mProject )
.PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE );
} }
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
@ -425,7 +426,9 @@ void MixerTrackCluster::HandleSliderVelocity(const bool bWantPushState /*= false
// Update the TrackPanel correspondingly. // Update the TrackPanel correspondingly.
TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get()); TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
if (bWantPushState) if (bWantPushState)
mProject->PushState(_("Moved velocity slider"), _("Velocity"), UndoPush::CONSOLIDATE); ProjectManager::Get( *mProject )
.PushState(_("Moved velocity slider"), _("Velocity"),
UndoPush::CONSOLIDATE);
} }
#endif #endif
@ -441,7 +444,9 @@ void MixerTrackCluster::HandleSliderPan(const bool bWantPushState /*= false*/)
TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get()); TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
if (bWantPushState) if (bWantPushState)
mProject->PushState(_("Moved pan slider"), _("Pan"), UndoPush::CONSOLIDATE ); ProjectManager::Get( *mProject )
.PushState(_("Moved pan slider"), _("Pan"),
UndoPush::CONSOLIDATE );
} }
void MixerTrackCluster::ResetMeter(const bool bResetClipping) void MixerTrackCluster::ResetMeter(const bool bResetClipping)

File diff suppressed because it is too large Load Diff

View File

@ -35,8 +35,6 @@
#include "xml/XMLTagHandler.h" // to inherit #include "xml/XMLTagHandler.h" // to inherit
const int AudacityProjectTimerID = 5200;
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_PROJECT_STATUS_UPDATE, wxCommandEvent); EVT_PROJECT_STATUS_UPDATE, wxCommandEvent);
@ -61,7 +59,6 @@ struct UndoState;
enum class UndoPush : unsigned char; enum class UndoPush : unsigned char;
AudacityProject *CreateNewAudacityProject();
AUDACITY_DLL_API AudacityProject *GetActiveProject(); AUDACITY_DLL_API AudacityProject *GetActiveProject();
void GetDefaultWindowRect(wxRect *defRect); void GetDefaultWindowRect(wxRect *defRect);
@ -165,10 +162,7 @@ using AttachedWindows = ClientData::Site<
using ProjectWindow = AudacityProject; using ProjectWindow = AudacityProject;
class AUDACITY_DLL_API AudacityProject final : public wxFrame, class AUDACITY_DLL_API AudacityProject final : public wxFrame,
public TrackPanelListener, public TrackPanelListener,
public SelectionBarListener,
public SpectralSelectionBarListener,
public XMLTagHandler, public XMLTagHandler,
public AudioIOListener,
private PrefsListener private PrefsListener
, public AttachedObjects , public AttachedObjects
, public AttachedWindows , public AttachedWindows
@ -200,47 +194,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
bool IsActive() override; bool IsActive() override;
// File I/O
/** @brief Show an open dialogue for opening audio files, and possibly other
* sorts of files.
*
* The file type filter will automatically contain:
* - "All files" with any extension or none,
* - "All supported files" based on the file formats supported in this
* build of Audacity,
* - All of the individual formats specified by the importer plug-ins which
* are built into this build of Audacity, each with the relevant file
* extensions for that format.
* The dialogue will start in the DefaultOpenPath directory read from the
* preferences, failing that the working directory. The file format filter
* will be set to the DefaultOpenType from the preferences, failing that
* the first format specified in the dialogue. These two parameters will
* be saved to the preferences once the user has chosen a file to open.
* @param extraformat Specify the name of an additional format to allow
* opening in this dialogue. This string is free-form, but should be short
* enough to fit in the file dialogue filter drop-down. It should be
* translated.
* @param extrafilter Specify the file extension(s) for the additional format
* specified by extraformat. The patterns must include the wildcard (e.g.
* "*.aup" not "aup" or ".aup"), separate multiple patters with a semicolon,
* e.g. "*.aup;*.AUP" because patterns are case-sensitive. Do not add a
* trailing semicolon to the string. This string should not be translated
* @return Array of file paths which the user selected to open (multiple
* selections allowed).
*/
static wxArrayString ShowOpenDialog(const wxString &extraformat = {},
const wxString &extrafilter = {});
static bool IsAlreadyOpen(const FilePath &projPathName);
static void OpenFiles(AudacityProject *proj);
// Return the given project if that is not NULL, else create a project.
// Then open the given project path.
// But if an exception escapes this function, create no NEW project.
static AudacityProject *OpenProject(
AudacityProject *pProject,
const FilePath &fileNameArg, bool addtohistory = true);
struct ReadProjectResults struct ReadProjectResults
{ {
bool decodeError; bool decodeError;
@ -250,26 +203,14 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
}; };
ReadProjectResults ReadProjectFile( const FilePath &fileName ); ReadProjectResults ReadProjectFile( const FilePath &fileName );
void OpenFile(const FilePath &fileName, bool addtohistory = true);
private:
void EnqueueODTasks(); void EnqueueODTasks();
public:
using wxFrame::DetachMenuBar; using wxFrame::DetachMenuBar;
bool WarnOfLegacyFile( ); bool WarnOfLegacyFile( );
// If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks.
bool Import(const FilePath &fileName, WaveTrackArray *pTrackArray = NULL);
void ZoomAfterImport(Track *pTrack); void ZoomAfterImport(Track *pTrack);
// Takes array of unique pointers; returns array of shared
std::vector< std::shared_ptr<Track> >
AddImportedTracks(const FilePath &fileName,
TrackHolders &&newTracks);
void CloseLock(); void CloseLock();
bool Save(); bool Save();
@ -283,7 +224,9 @@ private:
public: public:
const FilePath &GetFileName() { return mFileName; } const FilePath &GetFileName() { return mFileName; }
bool GetDirty() { return mDirty; } void SetFileName( const FilePath &value ) { mFileName = value; }
const FilePath &GetAutoSaveFileName() { return mAutoSaveFileName; }
void SetProjectTitle( int number =-1); void SetProjectTitle( int number =-1);
wxWindow *GetMainPage() { return mMainPage; } wxWindow *GetMainPage() { return mMainPage; }
@ -292,13 +235,8 @@ public:
// Timer Record Auto Save/Export Routines // Timer Record Auto Save/Export Routines
bool SaveFromTimerRecording(wxFileName fnFile); bool SaveFromTimerRecording(wxFileName fnFile);
bool IsProjectSaved(); bool IsProjectSaved();
void ResetProjectToEmpty();
void ResetProjectFileIO();
// Routine to estimate how many minutes of recording time are left on disk void ResetProjectFileIO();
int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
// Converts number of minutes to human readable format
wxString GetHoursMinsString(int iMinutes);
// Message Handlers // Message Handlers
@ -316,10 +254,7 @@ public:
void OnMove(wxMoveEvent & event); void OnMove(wxMoveEvent & event);
void DoScroll(); void DoScroll();
void OnScroll(wxScrollEvent & event); void OnScroll(wxScrollEvent & event);
void OnCloseWindow(wxCloseEvent & event);
void OnTimer(wxTimerEvent & event);
void OnToolBarUpdate(wxCommandEvent & event); void OnToolBarUpdate(wxCommandEvent & event);
void OnOpenAudioFile(wxCommandEvent & event);
void HandleResize(); void HandleResize();
void UpdateLayout(); void UpdateLayout();
@ -369,35 +304,7 @@ public:
const wxString &GetStatus() const { return mLastMainStatusMessage; } const wxString &GetStatus() const { return mLastMainStatusMessage; }
void SetStatus(const wxString &msg); void SetStatus(const wxString &msg);
void OnStatusChange( wxCommandEvent& );
private:
bool SnapSelection();
public: public:
// SelectionBarListener callback methods
double AS_GetRate() override;
void AS_SetRate(double rate) override;
int AS_GetSnapTo() override;
void AS_SetSnapTo(int snap) override;
const NumericFormatSymbol & AS_GetSelectionFormat() override;
void AS_SetSelectionFormat(const NumericFormatSymbol & format) override;
void AS_ModifySelection(double &start, double &end, bool done) override;
// SpectralSelectionBarListener callback methods
double SSBL_GetRate() const override;
const NumericFormatSymbol & SSBL_GetFrequencySelectionFormatName() override;
void SSBL_SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName) override;
const NumericFormatSymbol & SSBL_GetBandwidthSelectionFormatName() override;
void SSBL_SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName) override;
void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) override;
void SetStateTo(unsigned int n);
// XMLTagHandler callback methods // XMLTagHandler callback methods
@ -408,32 +315,13 @@ public:
void WriteXMLHeader(XMLWriter &xmlFile) const; void WriteXMLHeader(XMLWriter &xmlFile) const;
// Audio IO callback methods
void OnAudioIORate(int rate) override;
void OnAudioIOStartRecording() override;
void OnAudioIOStopRecording() override;
void OnAudioIONewBlockFiles(const AutoSaveFile & blockFileLog) override;
bool UndoAvailable();
bool RedoAvailable();
void PushState(const wxString &desc, const wxString &shortDesc); // use UndoPush::AUTOSAVE
void PushState(const wxString &desc, const wxString &shortDesc, UndoPush flags);
void RollbackState();
private: private:
void OnThemeChange(wxCommandEvent & evt); void OnThemeChange(wxCommandEvent & evt);
void InitialState();
public: public:
void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
void PopState(const UndoState &state);
void AutoSave(); void AutoSave();
void DeleteCurrentAutoSaveFile(); void DeleteCurrentAutoSaveFile();
private: private:
@ -448,13 +336,10 @@ public:
std::shared_ptr<TrackList> mLastSavedTracks; std::shared_ptr<TrackList> mLastSavedTracks;
private: private:
bool mDirty{ false };
// Window elements // Window elements
wxString mLastMainStatusMessage; wxString mLastMainStatusMessage;
std::unique_ptr<wxTimer> mTimer;
void RestartTimer();
wxPanel *mTopPanel{}; wxPanel *mTopPanel{};
wxWindow * mMainPage; wxWindow * mMainPage;
@ -481,24 +366,21 @@ private:
void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; } void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; } wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
bool IsTimerRecordCancelled(){return mTimerRecordCanceled;}
void SetTimerRecordCancelled(){mTimerRecordCanceled=true;}
void ResetTimerRecordCancelled(){mTimerRecordCanceled=false;}
private: private:
bool mIsDeleting{ false }; bool mIsDeleting{ false };
public: public:
bool IsBeingDeleted() const { return mIsDeleting; } bool IsBeingDeleted() const { return mIsDeleting; }
void SetIsBeingDeleted() { mIsDeleting = true; } void SetIsBeingDeleted() { mIsDeleting = true; }
bool IsRecovered() const { return mIsRecovered; }
void SetImportedDependencies( bool value ) { mImportedDependencies = value; }
void SetLoadedFromAup( bool value ) { mbLoadedFromAup = value; }
private: private:
bool mLockPlayRegion; bool mLockPlayRegion;
std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
// Last auto-save file name and path (empty if none) // Last auto-save file name and path (empty if none)
wxString mAutoSaveFileName; FilePath mAutoSaveFileName;
// Are we currently auto-saving or not? // Are we currently auto-saving or not?
bool mAutoSaving{ false }; bool mAutoSaving{ false };
@ -509,9 +391,6 @@ private:
// The auto-save data dir the project has been recovered from // The auto-save data dir the project has been recovered from
wxString mRecoveryAutoSaveDataDir; wxString mRecoveryAutoSaveDataDir;
// The handler that handles recovery of <recordingrecovery> tags
std::unique_ptr<RecordingRecoveryHandler> mRecordingRecoveryHandler;
// Dependencies have been imported and a warning should be shown on save // Dependencies have been imported and a warning should be shown on save
bool mImportedDependencies{ false }; bool mImportedDependencies{ false };
@ -519,16 +398,6 @@ private:
wxRect mNormalizedWindowState; wxRect mNormalizedWindowState;
//flag for cancellation of timer record.
bool mTimerRecordCanceled{ false };
// Are we currently closing as the result of a menu command?
bool mMenuClose{ false };
public:
void SetMenuClose(bool value) { mMenuClose = value; }
private:
bool mbInitializingScrollbar{ false }; bool mbInitializingScrollbar{ false };
public: public:
@ -560,14 +429,175 @@ public:
private: private:
std::unique_ptr<PlaybackScroller> mPlaybackScroller; std::unique_ptr<PlaybackScroller> mPlaybackScroller;
public:
PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
DECLARE_EVENT_TABLE()
};
class ProjectManager final
: public wxEvtHandler
, public ClientData::Base
, public AudioIOListener
, private SelectionBarListener
, private SpectralSelectionBarListener
{
public:
static ProjectManager &Get( AudacityProject &project );
static const ProjectManager &Get( const AudacityProject &project );
explicit ProjectManager( AudacityProject &project );
~ProjectManager() override;
// This is the factory for projects:
static AudacityProject *New();
// File I/O
/** @brief Show an open dialogue for opening audio files, and possibly other
* sorts of files.
*
* The file type filter will automatically contain:
* - "All files" with any extension or none,
* - "All supported files" based on the file formats supported in this
* build of Audacity,
* - All of the individual formats specified by the importer plug-ins which
* are built into this build of Audacity, each with the relevant file
* extensions for that format.
* The dialogue will start in the DefaultOpenPath directory read from the
* preferences, failing that the working directory. The file format filter
* will be set to the DefaultOpenType from the preferences, failing that
* the first format specified in the dialogue. These two parameters will
* be saved to the preferences once the user has chosen a file to open.
* @param extraformat Specify the name of an additional format to allow
* opening in this dialogue. This string is free-form, but should be short
* enough to fit in the file dialogue filter drop-down. It should be
* translated.
* @param extrafilter Specify the file extension(s) for the additional format
* specified by extraformat. The patterns must include the wildcard (e.g.
* "*.aup" not "aup" or ".aup"), separate multiple patters with a semicolon,
* e.g. "*.aup;*.AUP" because patterns are case-sensitive. Do not add a
* trailing semicolon to the string. This string should not be translated
* @return Array of file paths which the user selected to open (multiple
* selections allowed).
*/
static wxArrayString ShowOpenDialog(const wxString &extraformat = {},
const wxString &extrafilter = {});
static bool IsAlreadyOpen(const FilePath &projPathName);
// The functions that open and import files can act as factories too, and
// they set projects to initial state.
static void OpenFiles(AudacityProject *proj);
void OpenFile(const FilePath &fileName, bool addtohistory = true);
// Return the given project if that is not NULL, else create a project.
// Then open the given project path.
// But if an exception escapes this function, create no NEW project.
static AudacityProject *OpenProject(
AudacityProject *pProject,
const FilePath &fileNameArg, bool addtohistory = true);
// If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks.
bool Import(const FilePath &fileName, WaveTrackArray *pTrackArray = NULL);
// Takes array of unique pointers; returns array of shared
std::vector< std::shared_ptr<Track> >
AddImportedTracks(const FilePath &fileName,
TrackHolders &&newTracks);
bool GetDirty() { return mDirty; }
void ResetProjectToEmpty();
// Routine to estimate how many minutes of recording time are left on disk
int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
// Converts number of minutes to human readable format
wxString GetHoursMinsString(int iMinutes);
void SetStateTo(unsigned int n);
bool UndoAvailable();
bool RedoAvailable();
void PushState(const wxString &desc, const wxString &shortDesc); // use UndoPush::AUTOSAVE
void PushState(const wxString &desc, const wxString &shortDesc, UndoPush flags);
void RollbackState();
void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file.
// Should set only if you really want the state change restored after
// a crash, as it can take many seconds for large (eg. 10 track-hours)
// projects
void PopState(const UndoState &state);
bool IsTimerRecordCancelled() { return mTimerRecordCanceled; }
void SetTimerRecordCancelled() { mTimerRecordCanceled = true; }
void ResetTimerRecordCancelled() { mTimerRecordCanceled = false; }
void SetMenuClose(bool value) { mMenuClose = value; }
// SelectionBarListener callback methods
double AS_GetRate() override;
void AS_SetRate(double rate) override;
int AS_GetSnapTo() override;
void AS_SetSnapTo(int snap) override;
const NumericFormatSymbol & AS_GetSelectionFormat() override;
void AS_SetSelectionFormat(const NumericFormatSymbol & format) override;
void AS_ModifySelection(double &start, double &end, bool done) override;
// SpectralSelectionBarListener callback methods
double SSBL_GetRate() const override;
const NumericFormatSymbol & SSBL_GetFrequencySelectionFormatName() override;
void SSBL_SetFrequencySelectionFormatName(
const NumericFormatSymbol & formatName) override;
const NumericFormatSymbol & SSBL_GetBandwidthSelectionFormatName() override;
void SSBL_SetBandwidthSelectionFormatName(
const NumericFormatSymbol & formatName) override;
void SSBL_ModifySpectralSelection(
double &bottom, double &top, bool done) override;
private:
void OnCloseWindow(wxCloseEvent & event);
void OnTimer(wxTimerEvent & event);
void OnOpenAudioFile(wxCommandEvent & event);
void OnStatusChange( wxCommandEvent& );
bool SnapSelection();
// Audio IO callback methods
void OnAudioIORate(int rate) override;
void OnAudioIOStartRecording() override;
void OnAudioIOStopRecording() override;
void OnAudioIONewBlockFiles(const AutoSaveFile & blockFileLog) override;
void InitialState();
void RestartTimer();
// Declared in this class so that they can have access to private members // Declared in this class so that they can have access to private members
static XMLTagHandler *RecordingRecoveryFactory( AudacityProject &project ); static XMLTagHandler *RecordingRecoveryFactory( AudacityProject &project );
static ProjectFileIORegistry::Entry sRecoveryFactory; static ProjectFileIORegistry::Entry sRecoveryFactory;
static XMLTagHandler *ImportHandlerFactory( AudacityProject &project ); static XMLTagHandler *ImportHandlerFactory( AudacityProject &project );
static ProjectFileIORegistry::Entry sImportHandlerFactory; static ProjectFileIORegistry::Entry sImportHandlerFactory;
public: // non-static data members
PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; } AudacityProject &mProject;
// The handler that handles recovery of <recordingrecovery> tags
std::unique_ptr<RecordingRecoveryHandler> mRecordingRecoveryHandler;
std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
std::unique_ptr<wxTimer> mTimer;
bool mDirty{ false };
// See explanation in OnCloseWindow
bool mIsBeingDeleted{ false };
// Are we currently closing as the result of a menu command?
bool mMenuClose{ false };
//flag for cancellation of timer record.
bool mTimerRecordCanceled{ false };
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -417,9 +417,10 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
// as its possible that they plan to free up some // as its possible that they plan to free up some
// space before the recording begins // space before the recording begins
AudacityProject* pProject = GetActiveProject(); AudacityProject* pProject = GetActiveProject();
auto &projectManager = ProjectManager::Get( *pProject );
// How many minutes do we have left on the disc? // How many minutes do we have left on the disc?
int iMinsLeft = pProject->GetEstimatedRecordingMinsLeftOnDisk(); int iMinsLeft = projectManager.GetEstimatedRecordingMinsLeftOnDisk();
// How many minutes will this recording require? // How many minutes will this recording require?
int iMinsRecording = m_TimeSpan_Duration.GetMinutes(); int iMinsRecording = m_TimeSpan_Duration.GetMinutes();
@ -429,9 +430,9 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
// Format the strings // Format the strings
wxString sRemainingTime; wxString sRemainingTime;
sRemainingTime = pProject->GetHoursMinsString(iMinsLeft); sRemainingTime = projectManager.GetHoursMinsString(iMinsLeft);
wxString sPlannedTime; wxString sPlannedTime;
sPlannedTime = pProject->GetHoursMinsString(iMinsRecording); sPlannedTime = projectManager.GetHoursMinsString(iMinsRecording);
// Create the message string // Create the message string
wxString sMessage; wxString sMessage;

View File

@ -610,7 +610,7 @@ void TrackPanel::OnPaint(wxPaintEvent & /* event */)
void TrackPanel::MakeParentModifyState(bool bWantsAutoSave) void TrackPanel::MakeParentModifyState(bool bWantsAutoSave)
{ {
GetProject()->ModifyState(bWantsAutoSave); ProjectManager::Get( *GetProject() ).ModifyState(bWantsAutoSave);
} }
void TrackPanel::MakeParentRedrawScrollbars() void TrackPanel::MakeParentRedrawScrollbars()

View File

@ -219,7 +219,7 @@ UIHandle::Result TrackPanelResizeHandle::Release
/// We also modify the undo state (the action doesn't become /// We also modify the undo state (the action doesn't become
/// undo-able, but it gets merged with the previous undo-able /// undo-able, but it gets merged with the previous undo-able
/// event). /// event).
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
return RefreshCode::FixScrollbars; return RefreshCode::FixScrollbars;
} }

View File

@ -41,7 +41,7 @@ void ImportCommand::PopulateOrExchange(ShuttleGui & S)
} }
bool ImportCommand::Apply(const CommandContext & context){ bool ImportCommand::Apply(const CommandContext & context){
return context.project.Import(mFileName); return ProjectManager::Get( context.project ).Import(mFileName);
} }

View File

@ -48,11 +48,12 @@ bool OpenProjectCommand::Apply(const CommandContext & context){
if(mFileName.empty()) if(mFileName.empty())
{ {
auto project = &context.project; auto project = &context.project;
AudacityProject::OpenFiles(project); ProjectManager::OpenFiles(project);
} }
else else
{ {
context.project.OpenFile(mFileName, mbAddToHistory); ProjectManager::Get( context.project )
.OpenFile(mFileName, mbAddToHistory);
} }
const auto &newFileName = context.project.GetFileName(); const auto &newFileName = context.project.GetFileName();

View File

@ -165,7 +165,7 @@ bool SelectFrequenciesCommand::Apply(const CommandContext & context){
if( !bHasBottom ) if( !bHasBottom )
mBottom = 0.0; mBottom = 0.0;
context.project.SSBL_ModifySpectralSelection( ProjectManager::Get( context.project ).SSBL_ModifySpectralSelection(
mBottom, mTop, false);// false for not done. mBottom, mTop, false);// false for not done.
return true; return true;
} }

View File

@ -297,7 +297,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
auto state = UndoManager::Get( *project ).GetCurrentState(); auto state = UndoManager::Get( *project ).GetCurrentState();
auto cleanup = finally( [&] { auto cleanup = finally( [&] {
if(!success) if(!success)
project->SetStateTo(state); ProjectManager::Get( *project ).SetStateTo( state );
} ); } );
for (size_t i = 0, cnt = mEffects.size(); i < cnt; i++) for (size_t i = 0, cnt = mEffects.size(); i < cnt; i++)

View File

@ -385,7 +385,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln)
* audio file. TODO: Some sort of message here? */ * audio file. TODO: Some sort of message here? */
#endif // USE_MIDI #endif // USE_MIDI
mProject = AudacityProject::OpenProject( mProject, targetfile ); mProject = ProjectManager::OpenProject( mProject, targetfile );
// Set tok to right after filename // Set tok to right after filename
temptok2.SetString(targettoken); temptok2.SetString(targettoken);
@ -440,7 +440,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln)
} }
// Amend the undo transaction made by import // Amend the undo transaction made by import
mProject->ModifyState(false); ProjectManager::Get( *mProject ).ModifyState(false);
} // end of converting "offset" argument } // end of converting "offset" argument
else else
{ {
@ -484,7 +484,7 @@ void LOFImportFileHandle::doDurationAndScrollOffset()
if (doSomething) if (doSomething)
// Amend last undo state // Amend last undo state
mProject->ModifyState(false); ProjectManager::Get( *mProject ).ModifyState(false);
} }
LOFImportFileHandle::~LOFImportFileHandle() LOFImportFileHandle::~LOFImportFileHandle()

View File

@ -389,7 +389,7 @@ void DoSelectClipBoundary(AudacityProject &project, bool next)
else else
selectedRegion.setT0(results[0].time); selectedRegion.setT0(results[0].time);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
wxString message = ClipBoundaryMessage(results); wxString message = ClipBoundaryMessage(results);
@ -572,7 +572,7 @@ void DoSelectClip(AudacityProject &project, bool next)
double t0 = results[0].startTime; double t0 = results[0].startTime;
double t1 = results[0].endTime; double t1 = results[0].endTime;
selectedRegion.setTimes(t0, t1); selectedRegion.setTimes(t0, t1);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0()); trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -618,7 +618,7 @@ void DoCursorClipBoundary
// value. // value.
double time = results[0].time; double time = results[0].time;
selectedRegion.setTimes(time, time); selectedRegion.setTimes(time, time);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0()); trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -720,7 +720,8 @@ void DoClipLeftOrRight
// keypress (keydown, then keyup), and holding down a key // keypress (keydown, then keyup), and holding down a key
// (multiple keydowns followed by a keyup) result in a single // (multiple keydowns followed by a keyup) result in a single
// entry in Audacity's history dialog. // entry in Audacity's history dialog.
project.PushState(message, _("Time-Shift"), UndoPush::CONSOLIDATE); ProjectManager::Get( project )
.PushState(message, _("Time-Shift"), UndoPush::CONSOLIDATE);
} }
if ( amount == 0.0 ) if ( amount == 0.0 )

View File

@ -49,7 +49,8 @@ bool DoPasteText(AudacityProject &project)
if (pLabelTrack->PasteSelectedText(selectedRegion.t0(), if (pLabelTrack->PasteSelectedText(selectedRegion.t0(),
selectedRegion.t1())) selectedRegion.t1()))
{ {
project.PushState(_("Pasted text from the clipboard"), _("Paste")); ProjectManager::Get( project )
.PushState(_("Pasted text from the clipboard"), _("Paste"));
// Make sure caret is in view // Make sure caret is in view
int x; int x;
@ -148,7 +149,8 @@ bool DoPasteNothingSelected(AudacityProject &project)
// half a sample earlier // half a sample earlier
quantT1 - quantT0); quantT1 - quantT0);
project.PushState(_("Pasted from the clipboard"), _("Paste")); ProjectManager::Get( project )
.PushState(_("Pasted from the clipboard"), _("Paste"));
window.RedrawProject(); window.RedrawProject();
@ -216,7 +218,7 @@ bool DoEditMetadata
if (tags != *newTags) { if (tags != *newTags) {
// Commit the change to project state only now. // Commit the change to project state only now.
Tags::Set( project, newTags ); Tags::Set( project, newTags );
project.PushState(title, shortUndoDescription); ProjectManager::Get( project ).PushState(title, shortUndoDescription);
} }
bool bShowInFuture; bool bShowInFuture;
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true);
@ -233,7 +235,7 @@ void DoUndo(AudacityProject &project)
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project ); auto &window = ProjectWindow::Get( project );
if (!project.UndoAvailable()) { if (!ProjectManager::Get( project ).UndoAvailable()) {
AudacityMessageBox(_("Nothing to undo")); AudacityMessageBox(_("Nothing to undo"));
return; return;
} }
@ -244,7 +246,8 @@ void DoUndo(AudacityProject &project)
} }
undoManager.Undo( undoManager.Undo(
[&]( const UndoState &state ){ project.PopState( state ); } ); [&]( const UndoState &state ){
ProjectManager::Get( project ).PopState( state ); } );
trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack()); trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack());
@ -269,7 +272,7 @@ void OnRedo(const CommandContext &context)
auto &undoManager = UndoManager::Get( project ); auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project ); auto &window = ProjectWindow::Get( project );
if (!project.RedoAvailable()) { if (!ProjectManager::Get( project ).RedoAvailable()) {
AudacityMessageBox(_("Nothing to redo")); AudacityMessageBox(_("Nothing to redo"));
return; return;
} }
@ -279,7 +282,8 @@ void OnRedo(const CommandContext &context)
} }
undoManager.Redo( undoManager.Redo(
[&]( const UndoState &state ){ project.PopState( state ); } ); [&]( const UndoState &state ){
ProjectManager::Get( project ).PopState( state ); } );
trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack()); trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack());
@ -366,7 +370,7 @@ void OnCut(const CommandContext &context)
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
project.PushState(_("Cut to the clipboard"), _("Cut")); ProjectManager::Get( project ).PushState(_("Cut to the clipboard"), _("Cut"));
// Bug 1663 // Bug 1663
//mRuler->ClearPlayRegion(); //mRuler->ClearPlayRegion();
@ -392,7 +396,7 @@ void OnDelete(const CommandContext &context)
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
project.PushState(wxString::Format(_("Deleted %.2f seconds at t=%.2f"), ProjectManager::Get( project ).PushState(wxString::Format(_("Deleted %.2f seconds at t=%.2f"),
seconds, seconds,
selectedRegion.t0()), selectedRegion.t0()),
_("Delete")); _("Delete"));
@ -692,7 +696,8 @@ void OnPaste(const CommandContext &context)
{ {
selectedRegion.setT1( t0 + clipboard.Duration() ); selectedRegion.setT1( t0 + clipboard.Duration() );
project.PushState(_("Pasted from the clipboard"), _("Paste")); ProjectManager::Get( project )
.PushState(_("Pasted from the clipboard"), _("Paste"));
window.RedrawProject(); window.RedrawProject();
@ -724,7 +729,7 @@ void OnDuplicate(const CommandContext &context)
break; break;
} }
project.PushState(_("Duplicated"), _("Duplicate")); ProjectManager::Get( project ).PushState(_("Duplicated"), _("Duplicate"));
window.RedrawProject(); window.RedrawProject();
} }
@ -766,7 +771,7 @@ void OnSplitCut(const CommandContext &context)
clipboard.Assign( std::move( newClipboard ), clipboard.Assign( std::move( newClipboard ),
selectedRegion.t0(), selectedRegion.t1(), &project ); selectedRegion.t0(), selectedRegion.t1(), &project );
project.PushState(_("Split-cut to the clipboard"), _("Split Cut")); ProjectManager::Get( project ).PushState(_("Split-cut to the clipboard"), _("Split Cut"));
window.RedrawProject(); window.RedrawProject();
} }
@ -789,7 +794,7 @@ void OnSplitDelete(const CommandContext &context)
} }
); );
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format(_("Split-deleted %.2f seconds at t=%.2f"), wxString::Format(_("Split-deleted %.2f seconds at t=%.2f"),
selectedRegion.duration(), selectedRegion.duration(),
selectedRegion.t0()), selectedRegion.t0()),
@ -808,7 +813,7 @@ void OnSilence(const CommandContext &context)
for ( auto n : tracks.Selected< AudioTrack >() ) for ( auto n : tracks.Selected< AudioTrack >() )
n->Silence(selectedRegion.t0(), selectedRegion.t1()); n->Silence(selectedRegion.t0(), selectedRegion.t1());
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format(_("Silenced selected tracks for %.2f seconds at %.2f"), wxString::Format(_("Silenced selected tracks for %.2f seconds at %.2f"),
selectedRegion.duration(), selectedRegion.duration(),
selectedRegion.t0()), selectedRegion.t0()),
@ -841,7 +846,7 @@ void OnTrim(const CommandContext &context)
} }
); );
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format( wxString::Format(
_("Trim selected audio tracks from %.2f seconds to %.2f seconds"), _("Trim selected audio tracks from %.2f seconds to %.2f seconds"),
selectedRegion.t0(), selectedRegion.t1()), selectedRegion.t0(), selectedRegion.t1()),
@ -863,7 +868,7 @@ void OnSplit(const CommandContext &context)
for (auto wt : tracks.Selected< WaveTrack >()) for (auto wt : tracks.Selected< WaveTrack >())
wt->Split( sel0, sel1 ); wt->Split( sel0, sel1 );
project.PushState(_("Split"), _("Split")); ProjectManager::Get( project ).PushState(_("Split"), _("Split"));
trackPanel.Refresh(false); trackPanel.Refresh(false);
#if 0 #if 0
//ANSWER-ME: Do we need to keep this commented out OnSplit() code? //ANSWER-ME: Do we need to keep this commented out OnSplit() code?
@ -963,7 +968,8 @@ void OnSplitNew(const CommandContext &context)
break; break;
} }
project.PushState(_("Split to new track"), _("Split New")); ProjectManager::Get( project )
.PushState(_("Split to new track"), _("Split New"));
window.RedrawProject(); window.RedrawProject();
} }
@ -979,7 +985,7 @@ void OnJoin(const CommandContext &context)
wt->Join(selectedRegion.t0(), wt->Join(selectedRegion.t0(),
selectedRegion.t1()); selectedRegion.t1());
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format(_("Joined %.2f seconds at t=%.2f"), wxString::Format(_("Joined %.2f seconds at t=%.2f"),
selectedRegion.duration(), selectedRegion.duration(),
selectedRegion.t0()), selectedRegion.t0()),
@ -999,7 +1005,7 @@ void OnDisjoin(const CommandContext &context)
wt->Disjoin(selectedRegion.t0(), wt->Disjoin(selectedRegion.t0(),
selectedRegion.t1()); selectedRegion.t1());
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format(_("Detached %.2f seconds at t=%.2f"), wxString::Format(_("Detached %.2f seconds at t=%.2f"),
selectedRegion.duration(), selectedRegion.duration(),
selectedRegion.t0()), selectedRegion.t0()),

View File

@ -116,7 +116,7 @@ AudacityProject *DoImportMIDI(
AudacityProject *pNewProject {}; AudacityProject *pNewProject {};
if ( !pProject ) if ( !pProject )
pProject = pNewProject = CreateNewAudacityProject(); pProject = pNewProject = ProjectManager::New();
auto cleanup = finally( [&] auto cleanup = finally( [&]
{ if ( pNewProject ) GetProjectFrame( *pNewProject ).Close(true); } ); { if ( pNewProject ) GetProjectFrame( *pNewProject ).Close(true); } );
@ -128,7 +128,8 @@ AudacityProject *DoImportMIDI(
auto pTrack = tracks.Add( newTrack ); auto pTrack = tracks.Add( newTrack );
pTrack->SetSelected(true); pTrack->SetSelected(true);
pProject->PushState(wxString::Format(_("Imported MIDI from '%s'"), ProjectManager::Get( *pProject )
.PushState(wxString::Format(_("Imported MIDI from '%s'"),
fileName), _("Import MIDI")); fileName), _("Import MIDI"));
ProjectWindow::Get( *pProject ).ZoomAfterImport(pTrack); ProjectWindow::Get( *pProject ).ZoomAfterImport(pTrack);
@ -151,13 +152,13 @@ struct Handler : CommandHandlerObject {
void OnNew(const CommandContext & ) void OnNew(const CommandContext & )
{ {
CreateNewAudacityProject(); ( void ) ProjectManager::New();
} }
void OnOpen(const CommandContext &context ) void OnOpen(const CommandContext &context )
{ {
auto &project = context.project; auto &project = context.project;
AudacityProject::OpenFiles(&project); ProjectManager::OpenFiles(&project);
} }
// JKC: This is like OnClose, except it emptys the project in place, // JKC: This is like OnClose, except it emptys the project in place,
@ -168,14 +169,14 @@ void OnOpen(const CommandContext &context )
void OnProjectReset(const CommandContext &context) void OnProjectReset(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.ResetProjectToEmpty(); ProjectManager::Get( project ).ResetProjectToEmpty();
} }
void OnClose(const CommandContext &context ) void OnClose(const CommandContext &context )
{ {
auto &project = context.project; auto &project = context.project;
auto &window = GetProjectFrame( project ); auto &window = ProjectWindow::Get( project );
project.SetMenuClose(true); ProjectManager::Get( project ).SetMenuClose(true);
window.Close(); window.Close();
} }
@ -405,7 +406,7 @@ void OnImport(const CommandContext &context)
// this serves to track the file if the users zooms in and such. // this serves to track the file if the users zooms in and such.
MissingAliasFilesDialog::SetShouldShow(true); MissingAliasFilesDialog::SetShouldShow(true);
wxArrayString selectedFiles = project.ShowOpenDialog(wxT("")); wxArrayString selectedFiles = ProjectManager::ShowOpenDialog(wxT(""));
if (selectedFiles.size() == 0) { if (selectedFiles.size() == 0) {
gPrefs->Write(wxT("/LastOpenType"),wxT("")); gPrefs->Write(wxT("/LastOpenType"),wxT(""));
gPrefs->Flush(); gPrefs->Flush();
@ -435,7 +436,7 @@ void OnImport(const CommandContext &context)
FileNames::UpdateDefaultPath(FileNames::Operation::Open, fileName); FileNames::UpdateDefaultPath(FileNames::Operation::Open, fileName);
project.Import(fileName); ProjectManager::Get( project ).Import(fileName);
} }
window.ZoomAfterImport(nullptr); window.ZoomAfterImport(nullptr);
@ -479,8 +480,8 @@ void OnImportLabels(const CommandContext &context)
newTrack->SetSelected(true); newTrack->SetSelected(true);
tracks.Add( newTrack ); tracks.Add( newTrack );
project.PushState(wxString:: ProjectManager::Get( project ).PushState(
Format(_("Imported labels from '%s'"), fileName), wxString::Format(_("Imported labels from '%s'"), fileName),
_("Import Labels")); _("Import Labels"));
window.ZoomAfterImport(nullptr); window.ZoomAfterImport(nullptr);
@ -532,7 +533,7 @@ void OnImportRaw(const CommandContext &context)
if (newTracks.size() <= 0) if (newTracks.size() <= 0)
return; return;
project.AddImportedTracks(fileName, std::move(newTracks)); ProjectManager::Get( project ).AddImportedTracks(fileName, std::move(newTracks));
window.HandleResize(); // Adjust scrollers for NEW track sizes. window.HandleResize(); // Adjust scrollers for NEW track sizes.
} }

View File

@ -251,7 +251,7 @@ void QuickFixDialog::OnFix(wxCommandEvent &event)
// preference dialogs. // preference dialogs.
if( Str == "/SnapTo" ) if( Str == "/SnapTo" )
{ {
pProject->AS_SetSnapTo( 0 ); ProjectManager::Get( *pProject ).AS_SetSnapTo( 0 );
} }
else else
{ {

View File

@ -71,7 +71,7 @@ int DoAddLabel(
int index = lt->AddLabel(region, title, focusTrackNumber); int index = lt->AddLabel(region, title, focusTrackNumber);
project.PushState(_("Added label"), _("Label")); ProjectManager::Get( project ).PushState(_("Added label"), _("Label"));
window.RedrawProject(); window.RedrawProject();
if (!useDialog) { if (!useDialog) {
@ -336,7 +336,7 @@ void OnPasteNewLabel(const CommandContext &context)
} }
if (bPastedSomething) { if (bPastedSomething) {
project.PushState( ProjectManager::Get( project ).PushState(
_("Pasted from the clipboard"), _("Paste Text to New Label")); _("Pasted from the clipboard"), _("Paste Text to New Label"));
// Is this necessary? (carried over from former logic in OnPaste()) // Is this necessary? (carried over from former logic in OnPaste())
@ -376,7 +376,7 @@ void OnCutLabels(const CommandContext &context)
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) past tense. Audacity has just cut the labeled audio /* i18n-hint: (verb) past tense. Audacity has just cut the labeled audio
regions.*/ regions.*/
_( "Cut labeled audio regions to clipboard" ), _( "Cut labeled audio regions to clipboard" ),
@ -400,7 +400,7 @@ void OnDeleteLabels(const CommandContext &context)
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) Audacity has just deleted the labeled audio regions*/ /* i18n-hint: (verb) Audacity has just deleted the labeled audio regions*/
_( "Deleted labeled audio regions" ), _( "Deleted labeled audio regions" ),
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
@ -422,7 +422,7 @@ void OnSplitCutLabels(const CommandContext &context)
EditClipboardByLabel( project, EditClipboardByLabel( project,
tracks, selectedRegion, &WaveTrack::SplitCut ); tracks, selectedRegion, &WaveTrack::SplitCut );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) Audacity has just split cut the labeled audio /* i18n-hint: (verb) Audacity has just split cut the labeled audio
regions*/ regions*/
_( "Split Cut labeled audio regions to clipboard" ), _( "Split Cut labeled audio regions to clipboard" ),
@ -444,7 +444,7 @@ void OnSplitDeleteLabels(const CommandContext &context)
EditByLabel( tracks, selectedRegion, &WaveTrack::SplitDelete, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::SplitDelete, false );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) Audacity has just done a special kind of DELETE on /* i18n-hint: (verb) Audacity has just done a special kind of DELETE on
the labeled audio regions */ the labeled audio regions */
_( "Split Deleted labeled audio regions" ), _( "Split Deleted labeled audio regions" ),
@ -467,7 +467,7 @@ void OnSilenceLabels(const CommandContext &context)
EditByLabel( tracks, selectedRegion, &WaveTrack::Silence, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::Silence, false );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Silenced labeled audio regions" ), _( "Silenced labeled audio regions" ),
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
@ -489,7 +489,7 @@ void OnCopyLabels(const CommandContext &context)
EditClipboardByLabel( project, EditClipboardByLabel( project,
tracks, selectedRegion, &WaveTrack::CopyNonconst ); tracks, selectedRegion, &WaveTrack::CopyNonconst );
project.PushState( _( "Copied labeled audio regions to clipboard" ), ProjectManager::Get( project ).PushState( _( "Copied labeled audio regions to clipboard" ),
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
_( "Copy Labeled Audio" ) ); _( "Copy Labeled Audio" ) );
@ -505,7 +505,7 @@ void OnSplitLabels(const CommandContext &context)
EditByLabel( tracks, selectedRegion, &WaveTrack::Split, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::Split, false );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) past tense. Audacity has just split the labeled /* i18n-hint: (verb) past tense. Audacity has just split the labeled
audio (a point or a region)*/ audio (a point or a region)*/
_( "Split labeled audio (points or regions)" ), _( "Split labeled audio (points or regions)" ),
@ -527,7 +527,7 @@ void OnJoinLabels(const CommandContext &context)
EditByLabel( tracks, selectedRegion, &WaveTrack::Join, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::Join, false );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) Audacity has just joined the labeled audio (points or /* i18n-hint: (verb) Audacity has just joined the labeled audio (points or
regions) */ regions) */
_( "Joined labeled audio (points or regions)" ), _( "Joined labeled audio (points or regions)" ),
@ -549,7 +549,7 @@ void OnDisjoinLabels(const CommandContext &context)
EditByLabel( tracks, selectedRegion, &WaveTrack::Disjoin, false ); EditByLabel( tracks, selectedRegion, &WaveTrack::Disjoin, false );
project.PushState( ProjectManager::Get( project ).PushState(
/* i18n-hint: (verb) Audacity has just detached the labeled audio regions. /* i18n-hint: (verb) Audacity has just detached the labeled audio regions.
This message appears in history and tells you about something This message appears in history and tells you about something
Audacity has done.*/ Audacity has done.*/

View File

@ -84,6 +84,7 @@ void NextOrPrevFrame(AudacityProject &project, bool forward)
void DoPrevTrack( void DoPrevTrack(
AudacityProject &project, bool shift, bool circularTrackNavigation ) AudacityProject &project, bool shift, bool circularTrackNavigation )
{ {
auto &projectManager = ProjectManager::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectionState = SelectionState::Get( project ); auto &selectionState = SelectionState::Get( project );
@ -94,7 +95,7 @@ void DoPrevTrack(
t = *tracks.Any().rbegin(); t = *tracks.Any().rbegin();
trackPanel.SetFocusedTrack( t ); trackPanel.SetFocusedTrack( t );
trackPanel.EnsureVisible( t ); trackPanel.EnsureVisible( t );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
@ -126,7 +127,7 @@ void DoPrevTrack(
( *t, false, false ); ( *t, false, false );
trackPanel.SetFocusedTrack( p ); // move focus to next track up trackPanel.SetFocusedTrack( p ); // move focus to next track up
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( tSelected && !pSelected ) if( tSelected && !pSelected )
@ -135,7 +136,7 @@ void DoPrevTrack(
( *p, true, false ); ( *p, true, false );
trackPanel.SetFocusedTrack( p ); // move focus to next track up trackPanel.SetFocusedTrack( p ); // move focus to next track up
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( !tSelected && pSelected ) if( !tSelected && pSelected )
@ -144,7 +145,7 @@ void DoPrevTrack(
( *p, false, false ); ( *p, false, false );
trackPanel.SetFocusedTrack( p ); // move focus to next track up trackPanel.SetFocusedTrack( p ); // move focus to next track up
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( !tSelected && !pSelected ) if( !tSelected && !pSelected )
@ -153,7 +154,7 @@ void DoPrevTrack(
( *t, true, false ); ( *t, true, false );
trackPanel.SetFocusedTrack( p ); // move focus to next track up trackPanel.SetFocusedTrack( p ); // move focus to next track up
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
} }
@ -169,7 +170,7 @@ void DoPrevTrack(
p = * range.rbegin(); // null if range is empty p = * range.rbegin(); // null if range is empty
trackPanel.SetFocusedTrack( p ); // Wrap to the last track trackPanel.SetFocusedTrack( p ); // Wrap to the last track
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
else else
@ -182,7 +183,7 @@ void DoPrevTrack(
{ {
trackPanel.SetFocusedTrack( p ); // move focus to next track up trackPanel.SetFocusedTrack( p ); // move focus to next track up
trackPanel.EnsureVisible( p ); trackPanel.EnsureVisible( p );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
} }
@ -194,6 +195,7 @@ void DoPrevTrack(
void DoNextTrack( void DoNextTrack(
AudacityProject &project, bool shift, bool circularTrackNavigation ) AudacityProject &project, bool shift, bool circularTrackNavigation )
{ {
auto &projectManager = ProjectManager::Get( project );
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
auto &tracks = TrackList::Get( project ); auto &tracks = TrackList::Get( project );
auto &selectionState = SelectionState::Get( project ); auto &selectionState = SelectionState::Get( project );
@ -204,7 +206,7 @@ void DoNextTrack(
t = *tracks.Any().begin(); t = *tracks.Any().begin();
trackPanel.SetFocusedTrack( t ); trackPanel.SetFocusedTrack( t );
trackPanel.EnsureVisible( t ); trackPanel.EnsureVisible( t );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
@ -230,7 +232,7 @@ void DoNextTrack(
( *t, false, false ); ( *t, false, false );
trackPanel.SetFocusedTrack( n ); // move focus to next track down trackPanel.SetFocusedTrack( n ); // move focus to next track down
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( tSelected && !nSelected ) if( tSelected && !nSelected )
@ -239,7 +241,7 @@ void DoNextTrack(
( *n, true, false ); ( *n, true, false );
trackPanel.SetFocusedTrack( n ); // move focus to next track down trackPanel.SetFocusedTrack( n ); // move focus to next track down
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( !tSelected && nSelected ) if( !tSelected && nSelected )
@ -248,7 +250,7 @@ void DoNextTrack(
( *n, false, false ); ( *n, false, false );
trackPanel.SetFocusedTrack( n ); // move focus to next track down trackPanel.SetFocusedTrack( n ); // move focus to next track down
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
if( !tSelected && !nSelected ) if( !tSelected && !nSelected )
@ -257,7 +259,7 @@ void DoNextTrack(
( *t, true, false ); ( *t, true, false );
trackPanel.SetFocusedTrack( n ); // move focus to next track down trackPanel.SetFocusedTrack( n ); // move focus to next track down
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
} }
@ -272,7 +274,7 @@ void DoNextTrack(
n = *tracks.Any().begin(); n = *tracks.Any().begin();
trackPanel.SetFocusedTrack( n ); // Wrap to the first track trackPanel.SetFocusedTrack( n ); // Wrap to the first track
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
else else
@ -285,7 +287,7 @@ void DoNextTrack(
{ {
trackPanel.SetFocusedTrack( n ); // move focus to next track down trackPanel.SetFocusedTrack( n ); // move focus to next track down
trackPanel.EnsureVisible( n ); trackPanel.EnsureVisible( n );
project.ModifyState(false); projectManager.ModifyState(false);
return; return;
} }
} }
@ -470,7 +472,7 @@ void OnFirstTrack(const CommandContext &context)
if (t != f) if (t != f)
{ {
trackPanel.SetFocusedTrack(f); trackPanel.SetFocusedTrack(f);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
trackPanel.EnsureVisible(f); trackPanel.EnsureVisible(f);
} }
@ -489,7 +491,7 @@ void OnLastTrack(const CommandContext &context)
if (t != l) if (t != l)
{ {
trackPanel.SetFocusedTrack(l); trackPanel.SetFocusedTrack(l);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
trackPanel.EnsureVisible(l); trackPanel.EnsureVisible(l);
} }
@ -521,7 +523,7 @@ void OnToggle(const CommandContext &context)
selectionState.SelectTrack selectionState.SelectTrack
( *t, !t->GetSelected(), true ); ( *t, !t->GetSelected(), true );
trackPanel.EnsureVisible( t ); trackPanel.EnsureVisible( t );
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.GetAx().Updated(); trackPanel.GetAx().Updated();

View File

@ -493,7 +493,7 @@ bool DoEffect(
{ {
wxString shortDesc = em.GetCommandName(ID); wxString shortDesc = em.GetCommandName(ID);
wxString longDesc = em.GetCommandDescription(ID); wxString longDesc = em.GetCommandDescription(ID);
project.PushState(longDesc, shortDesc); ProjectManager::Get( project ).PushState(longDesc, shortDesc);
} }
if (!(flags & kDontRepeatLast)) if (!(flags & kDontRepeatLast))

View File

@ -38,7 +38,7 @@ void DoSelectTimeAndTracks
for (auto t : tracks.Any()) for (auto t : tracks.Any())
t->SetSelected(true); t->SetSelected(true);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
} }
@ -63,7 +63,7 @@ void DoSelectTimeAndAudioTracks
for (auto t : tracks.Any<WaveTrack>()) for (auto t : tracks.Any<WaveTrack>())
t->SetSelected(true); t->SetSelected(true);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
} }
@ -88,7 +88,7 @@ void DoNextPeakFrequency(AudacityProject &project, bool up)
SpectrumAnalyst analyst; SpectrumAnalyst analyst;
SelectHandle::SnapCenterOnce(analyst, viewInfo, pTrack, up); SelectHandle::SnapCenterOnce(analyst, viewInfo, pTrack, up);
trackPanel.Refresh(false); trackPanel.Refresh(false);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
} }
@ -179,7 +179,7 @@ bool OnlyHandleKeyUp( const CommandContext &context )
if( !bKeyUp ) if( !bKeyUp )
return false; return false;
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
return true; return true;
} }
@ -420,7 +420,7 @@ void DoCursorMove(
MoveWhenAudioInactive(project, seekStep, TIME_UNIT_SECONDS); MoveWhenAudioInactive(project, seekStep, TIME_UNIT_SECONDS);
} }
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info) void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info)
@ -454,7 +454,7 @@ void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info)
else else
viewInfo.selectedRegion.setT1(indicator); viewInfo.selectedRegion.setT1(indicator);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
return; return;
} }
@ -483,7 +483,7 @@ void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info)
trackPanel.ScrollIntoView(newT); trackPanel.ScrollIntoView(newT);
trackPanel.Refresh(false); trackPanel.Refresh(false);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
} }
@ -533,7 +533,7 @@ void DoListSelection
trackPanel.SetFocusedTrack(t); trackPanel.SetFocusedTrack(t);
window.Refresh(false); window.Refresh(false);
if (modifyState) if (modifyState)
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
} }
void DoSelectAll(AudacityProject &project) void DoSelectAll(AudacityProject &project)
@ -583,7 +583,7 @@ void OnSelectNone(const CommandContext &context)
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
SelectNone( project ); SelectNone( project );
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void OnSelectAllTracks(const CommandContext &context) void OnSelectAllTracks(const CommandContext &context)
@ -606,7 +606,7 @@ void OnSelectSyncLockSel(const CommandContext &context)
} }
if (selected) if (selected)
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -649,7 +649,7 @@ void OnSetLeftSelection(const CommandContext &context)
if (bSelChanged) if (bSelChanged)
{ {
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
} }
@ -689,7 +689,7 @@ void OnSetRightSelection(const CommandContext &context)
if (bSelChanged) if (bSelChanged)
{ {
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
} }
@ -715,7 +715,7 @@ void OnSelectStartCursor(const CommandContext &context)
selectedRegion.setT0(minOffset); selectedRegion.setT0(minOffset);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -741,7 +741,7 @@ void OnSelectCursorEnd(const CommandContext &context)
selectedRegion.setT1(maxEndOffset); selectedRegion.setT1(maxEndOffset);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -761,7 +761,7 @@ void OnSelectTrackStartToEnd(const CommandContext &context)
return; return;
viewInfo.selectedRegion.setTimes( minOffset, maxEndOffset ); viewInfo.selectedRegion.setTimes( minOffset, maxEndOffset );
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -789,7 +789,7 @@ void OnSelectionRestore(const CommandContext &context)
selectedRegion = mRegionSave; selectedRegion = mRegionSave;
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -822,7 +822,7 @@ void OnToggleSpectralSelection(const CommandContext &context)
selectedRegion.setFrequencies(mLastF0, mLastF1); selectedRegion.setFrequencies(mLastF0, mLastF1);
trackPanel.Refresh(false); trackPanel.Refresh(false);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void OnNextHigherPeakFrequency(const CommandContext &context) void OnNextHigherPeakFrequency(const CommandContext &context)
@ -857,7 +857,7 @@ void OnSelectCursorStoredCursor(const CommandContext &context)
std::min(cursorPositionCurrent, mCursorPositionStored), std::min(cursorPositionCurrent, mCursorPositionStored),
std::max(cursorPositionCurrent, mCursorPositionStored)); std::max(cursorPositionCurrent, mCursorPositionStored));
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
} }
@ -890,7 +890,7 @@ void OnZeroCrossing(const CommandContext &context)
selectedRegion.setTimes(t0, t1); selectedRegion.setTimes(t0, t1);
} }
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -898,19 +898,19 @@ void OnZeroCrossing(const CommandContext &context)
void OnSnapToOff(const CommandContext &context) void OnSnapToOff(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.AS_SetSnapTo(SNAP_OFF); ProjectManager::Get( project ).AS_SetSnapTo(SNAP_OFF);
} }
void OnSnapToNearest(const CommandContext &context) void OnSnapToNearest(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.AS_SetSnapTo(SNAP_NEAREST); ProjectManager::Get( project ).AS_SetSnapTo(SNAP_NEAREST);
} }
void OnSnapToPrior(const CommandContext &context) void OnSnapToPrior(const CommandContext &context)
{ {
auto &project = context.project; auto &project = context.project;
project.AS_SetSnapTo(SNAP_PRIOR); ProjectManager::Get( project ).AS_SetSnapTo(SNAP_PRIOR);
} }
void OnSelToStart(const CommandContext &context) void OnSelToStart(const CommandContext &context)
@ -918,7 +918,7 @@ void OnSelToStart(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project ); auto &window = ProjectWindow::Get( project );
window.Rewind(true); window.Rewind(true);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void OnSelToEnd(const CommandContext &context) void OnSelToEnd(const CommandContext &context)
@ -926,7 +926,7 @@ void OnSelToEnd(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
auto &window = ProjectWindow::Get( project ); auto &window = ProjectWindow::Get( project );
window.SkipEnd(true); window.SkipEnd(true);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
// Handler state: // Handler state:
@ -977,7 +977,7 @@ void OnCursorSelStart(const CommandContext &context)
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
selectedRegion.collapseToT0(); selectedRegion.collapseToT0();
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0()); trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -989,7 +989,7 @@ void OnCursorSelEnd(const CommandContext &context)
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
selectedRegion.collapseToT1(); selectedRegion.collapseToT1();
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t1()); trackPanel.ScrollIntoView(selectedRegion.t1());
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -1016,7 +1016,7 @@ void OnCursorTrackStart(const CommandContext &context)
return; return;
selectedRegion.setTimes(minOffset, minOffset); selectedRegion.setTimes(minOffset, minOffset);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0()); trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -1043,7 +1043,7 @@ void OnCursorTrackEnd(const CommandContext &context)
return; return;
selectedRegion.setTimes(maxEndOffset, maxEndOffset); selectedRegion.setTimes(maxEndOffset, maxEndOffset);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t1()); trackPanel.ScrollIntoView(selectedRegion.t1());
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -1055,7 +1055,7 @@ void OnSkipStart(const CommandContext &context)
auto &controlToolBar = ControlToolBar::Get( project ); auto &controlToolBar = ControlToolBar::Get( project );
controlToolBar.OnRewind(evt); controlToolBar.OnRewind(evt);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void OnSkipEnd(const CommandContext &context) void OnSkipEnd(const CommandContext &context)
@ -1065,7 +1065,7 @@ void OnSkipEnd(const CommandContext &context)
auto &controlToolBar = ControlToolBar::Get( project ); auto &controlToolBar = ControlToolBar::Get( project );
controlToolBar.OnFF(evt); controlToolBar.OnFF(evt);
project.ModifyState(false); ProjectManager::Get( project ).ModifyState(false);
} }
void OnCursorLeft(const CommandContext &context) void OnCursorLeft(const CommandContext &context)

View File

@ -91,7 +91,7 @@ void DoMixAndRender
msg.Printf(_("Rendered all audio in track '%s'"), firstName); msg.Printf(_("Rendered all audio in track '%s'"), firstName);
/* i18n-hint: Convert the audio into a more usable form, so apply /* i18n-hint: Convert the audio into a more usable form, so apply
* panning and amplification and write to some external file.*/ * panning and amplification and write to some external file.*/
project.PushState(msg, _("Render")); ProjectManager::Get( project ).PushState(msg, _("Render"));
} }
else { else {
wxString msg; wxString msg;
@ -103,7 +103,7 @@ void DoMixAndRender
msg.Printf( msg.Printf(
_("Mixed and rendered %d tracks into one new mono track"), _("Mixed and rendered %d tracks into one new mono track"),
(int)selectedCount); (int)selectedCount);
project.PushState(msg, _("Mix and Render")); ProjectManager::Get( project ).PushState(msg, _("Mix and Render"));
} }
trackPanel.SetFocus(); trackPanel.SetFocus();
@ -131,7 +131,8 @@ void DoPanTracks(AudacityProject &project, float PanValue)
auto flags = UndoPush::AUTOSAVE; auto flags = UndoPush::AUTOSAVE;
/*i18n-hint: One or more audio tracks have been panned*/ /*i18n-hint: One or more audio tracks have been panned*/
project.PushState(_("Panned audio track(s)"), _("Pan Track"), flags); ProjectManager::Get( project )
.PushState(_("Panned audio track(s)"), _("Pan Track"), flags);
flags = flags | UndoPush::CONSOLIDATE; flags = flags | UndoPush::CONSOLIDATE;
} }
@ -292,7 +293,7 @@ void DoAlign
if (moveSel) if (moveSel)
selectedRegion.move(delta); selectedRegion.move(delta);
project.PushState(action, shortAction); ProjectManager::Get( project ).PushState(action, shortAction);
window.RedrawProject(); window.RedrawProject();
} }
@ -537,7 +538,8 @@ void SetTrackGain(AudacityProject &project, WaveTrack * wt, LWSlider * slider)
for (auto channel : TrackList::Channels(wt)) for (auto channel : TrackList::Channels(wt))
channel->SetGain(newValue); channel->SetGain(newValue);
project.PushState(_("Adjusted gain"), _("Gain"), UndoPush::CONSOLIDATE); ProjectManager::Get( project )
.PushState(_("Adjusted gain"), _("Gain"), UndoPush::CONSOLIDATE);
TrackPanel::Get( project ).RefreshTrack(wt); TrackPanel::Get( project ).RefreshTrack(wt);
} }
@ -550,7 +552,8 @@ void SetTrackPan(AudacityProject &project, WaveTrack * wt, LWSlider * slider)
for (auto channel : TrackList::Channels(wt)) for (auto channel : TrackList::Channels(wt))
channel->SetPan(newValue); channel->SetPan(newValue);
project.PushState(_("Adjusted Pan"), _("Pan"), UndoPush::CONSOLIDATE); ProjectManager::Get( project )
.PushState(_("Adjusted Pan"), _("Pan"), UndoPush::CONSOLIDATE);
TrackPanel::Get( project ).RefreshTrack(wt); TrackPanel::Get( project ).RefreshTrack(wt);
} }
@ -595,7 +598,8 @@ void DoRemoveTracks( AudacityProject &project )
if (f) if (f)
trackPanel.EnsureVisible(f); trackPanel.EnsureVisible(f);
project.PushState(_("Removed audio track(s)"), _("Remove Track")); ProjectManager::Get( project )
.PushState(_("Removed audio track(s)"), _("Remove Track"));
trackPanel.UpdateViewIfNoTracks(); trackPanel.UpdateViewIfNoTracks();
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -645,7 +649,7 @@ void DoTrackMute(AudacityProject &project, Track *t, bool exclusive)
track->SetSolo( (nPlaying==1) && (nPlayableTracks > 1 ) && !track->GetMute() ); track->SetSolo( (nPlaying==1) && (nPlayableTracks > 1 ) && !track->GetMute() );
} }
} }
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
trackPanel.UpdateAccessibility(); trackPanel.UpdateAccessibility();
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -698,7 +702,7 @@ void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive)
} }
} }
} }
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
trackPanel.UpdateAccessibility(); trackPanel.UpdateAccessibility();
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -734,7 +738,7 @@ void DoRemoveTrack(AudacityProject &project, Track * toRemove)
if (toRemoveWasFocused) if (toRemoveWasFocused)
trackPanel.SetFocusedTrack(newFocus); trackPanel.SetFocusedTrack(newFocus);
project.PushState( ProjectManager::Get( project ).PushState(
wxString::Format(_("Removed track '%s.'"), wxString::Format(_("Removed track '%s.'"),
name), name),
_("Track Remove")); _("Track Remove"));
@ -793,7 +797,7 @@ void DoMoveTrack
longDesc = longDesc.Format(target->GetName()); longDesc = longDesc.Format(target->GetName());
project.PushState(longDesc, shortDesc); ProjectManager::Get( project ).PushState(longDesc, shortDesc);
trackPanel.Refresh(false); trackPanel.Refresh(false);
} }
@ -818,7 +822,8 @@ void OnNewWaveTrack(const CommandContext &context)
t->SetSelected(true); t->SetSelected(true);
project.PushState(_("Created new audio track"), _("New Track")); ProjectManager::Get( project )
.PushState(_("Created new audio track"), _("New Track"));
window.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
@ -846,7 +851,8 @@ void OnNewStereoTrack(const CommandContext &context)
tracks.GroupChannels(*left, 2); tracks.GroupChannels(*left, 2);
project.PushState(_("Created new stereo audio track"), _("New Track")); ProjectManager::Get( project )
.PushState(_("Created new stereo audio track"), _("New Track"));
window.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(left); trackPanel.EnsureVisible(left);
@ -866,7 +872,8 @@ void OnNewLabelTrack(const CommandContext &context)
t->SetSelected(true); t->SetSelected(true);
project.PushState(_("Created new label track"), _("New Track")); ProjectManager::Get( project )
.PushState(_("Created new label track"), _("New Track"));
window.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
@ -891,7 +898,8 @@ void OnNewTimeTrack(const CommandContext &context)
t->SetSelected(true); t->SetSelected(true);
project.PushState(_("Created new time track"), _("New Track")); ProjectManager::Get( project )
.PushState(_("Created new time track"), _("New Track"));
window.RedrawProject(); window.RedrawProject();
trackPanel.EnsureVisible(t); trackPanel.EnsureVisible(t);
@ -1013,7 +1021,7 @@ void OnResample(const CommandContext &context)
// commit that to the undo stack. The second and later times, // commit that to the undo stack. The second and later times,
// consolidate. // consolidate.
project.PushState( ProjectManager::Get( project ).PushState(
_("Resampled audio track(s)"), _("Resample Track"), flags); _("Resampled audio track(s)"), _("Resample Track"), flags);
flags = flags | UndoPush::CONSOLIDATE; flags = flags | UndoPush::CONSOLIDATE;
} }
@ -1047,7 +1055,7 @@ void OnMuteAllTracks(const CommandContext &context)
pt->SetSolo(false); pt->SetSolo(false);
} }
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
window.RedrawProject(); window.RedrawProject();
} }
@ -1068,7 +1076,7 @@ void OnUnmuteAllTracks(const CommandContext &context)
pt->SetSolo(false); pt->SetSolo(false);
} }
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
window.RedrawProject(); window.RedrawProject();
} }
@ -1252,7 +1260,8 @@ void OnSortTime(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
DoSortTracks(project, kAudacitySortByTime); DoSortTracks(project, kAudacitySortByTime);
project.PushState(_("Tracks sorted by time"), _("Sort by Time")); ProjectManager::Get( project )
.PushState(_("Tracks sorted by time"), _("Sort by Time"));
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
trackPanel.Refresh(false); trackPanel.Refresh(false);
@ -1263,7 +1272,8 @@ void OnSortName(const CommandContext &context)
auto &project = context.project; auto &project = context.project;
DoSortTracks(project, kAudacitySortByName); DoSortTracks(project, kAudacitySortByName);
project.PushState(_("Tracks sorted by name"), _("Sort by Name")); ProjectManager::Get( project )
.PushState(_("Tracks sorted by name"), _("Sort by Name"));
auto &trackPanel = TrackPanel::Get( project ); auto &trackPanel = TrackPanel::Get( project );
trackPanel.Refresh(false); trackPanel.Refresh(false);

View File

@ -258,7 +258,7 @@ bool DoPlayStopSelect
// -- change t0, collapsing to point only if t1 was greater // -- change t0, collapsing to point only if t1 was greater
selection.setT0(time, false); selection.setT0(time, false);
project.ModifyState(false); // without bWantsAutoSave ProjectManager::Get( project ).ModifyState(false); // without bWantsAutoSave
return true; return true;
} }
return false; return false;
@ -459,7 +459,7 @@ void OnTimerRecord(const CommandContext &context)
switch (iTimerRecordingOutcome) { switch (iTimerRecordingOutcome) {
case POST_TIMER_RECORD_CANCEL_WAIT: case POST_TIMER_RECORD_CANCEL_WAIT:
// Canceled on the wait dialog // Canceled on the wait dialog
project.RollbackState(); ProjectManager::Get( project ).RollbackState();
break; break;
case POST_TIMER_RECORD_CANCEL: case POST_TIMER_RECORD_CANCEL:
// RunWaitDialog() shows the "wait for start" as well as "recording" // RunWaitDialog() shows the "wait for start" as well as "recording"
@ -468,7 +468,7 @@ void OnTimerRecord(const CommandContext &context)
// However, we can't undo it here because the PushState() is called in TrackPanel::OnTimer(), // However, we can't undo it here because the PushState() is called in TrackPanel::OnTimer(),
// which is blocked by this function. // which is blocked by this function.
// so instead we mark a flag to undo it there. // so instead we mark a flag to undo it there.
project.SetTimerRecordCancelled(); ProjectManager::Get( project ).SetTimerRecordCancelled();
break; break;
case POST_TIMER_RECORD_NOTHING: case POST_TIMER_RECORD_NOTHING:
// No action required // No action required
@ -624,7 +624,7 @@ void OnPunchAndRoll(const CommandContext &context)
; ;
else else
// Roll back the deletions // Roll back the deletions
project.RollbackState(); ProjectManager::Get( project ).RollbackState();
} }
#endif #endif

View File

@ -280,7 +280,7 @@ void OnZoomFitV(const CommandContext &context)
window.GetVerticalScrollBar().SetThumbPosition(0); window.GetVerticalScrollBar().SetThumbPosition(0);
window.RedrawProject(); window.RedrawProject();
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
} }
void OnAdvancedVZoom(const CommandContext &context) void OnAdvancedVZoom(const CommandContext &context)
@ -304,7 +304,7 @@ void OnCollapseAllTracks(const CommandContext &context)
for (auto t : tracks.Any()) for (auto t : tracks.Any())
t->SetMinimized(true); t->SetMinimized(true);
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
window.RedrawProject(); window.RedrawProject();
} }
@ -317,7 +317,7 @@ void OnExpandAllTracks(const CommandContext &context)
for (auto t : tracks.Any()) for (auto t : tracks.Any())
t->SetMinimized(false); t->SetMinimized(false);
project.ModifyState(true); ProjectManager::Get( project ).ModifyState(true);
window.RedrawProject(); window.RedrawProject();
} }

View File

@ -141,7 +141,7 @@ UIHandle::Result LabelGlyphHandle::Release
auto &viewInfo = ViewInfo::Get( *pProject ); auto &viewInfo = ViewInfo::Get( *pProject );
if (mpLT->HandleGlyphDragRelease if (mpLT->HandleGlyphDragRelease
(mHit, event, mRect, viewInfo, &viewInfo.selectedRegion)) { (mHit, event, mRect, viewInfo, &viewInfo.selectedRegion)) {
pProject->PushState(_("Modified Label"), ProjectManager::Get( *pProject ).PushState(_("Modified Label"),
_("Label Edit"), _("Label Edit"),
UndoPush::CONSOLIDATE); UndoPush::CONSOLIDATE);
} }
@ -152,7 +152,7 @@ UIHandle::Result LabelGlyphHandle::Release
UIHandle::Result LabelGlyphHandle::Cancel(AudacityProject *pProject) UIHandle::Result LabelGlyphHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
auto result = LabelDefaultClickHandle::Cancel( pProject ); auto result = LabelDefaultClickHandle::Cancel( pProject );
return result | RefreshCode::RefreshAll; return result | RefreshCode::RefreshAll;
} }

View File

@ -110,7 +110,7 @@ UIHandle::Result LabelTextHandle::Click
// PRL: bug1659 -- make selection change undo correctly // PRL: bug1659 -- make selection change undo correctly
const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive(); const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
if (!unsafe) if (!unsafe)
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
return result | RefreshCode::RefreshCell | RefreshCode::UpdateSelection; return result | RefreshCode::RefreshCell | RefreshCode::UpdateSelection;
} }

View File

@ -102,7 +102,7 @@ UIHandle::Result NoteTrackButtonHandle::Release
if (pTrack->LabelClick(mRect, event.m_x, event.m_y, if (pTrack->LabelClick(mRect, event.m_x, event.m_y,
event.Button(wxMOUSE_BTN_RIGHT))) { event.Button(wxMOUSE_BTN_RIGHT))) {
// No undo items needed?? // No undo items needed??
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
return RefreshAll; return RefreshAll;
} }
return RefreshNone; return RefreshNone;

View File

@ -116,7 +116,8 @@ void NoteTrackMenuTable::OnChangeOctave(wxCommandEvent &event)
pTrack->ShiftNoteRange((bDown) ? -12 : 12); pTrack->ShiftNoteRange((bDown) ? -12 : 12);
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->ModifyState(false); ProjectManager::Get( *project )
.ModifyState(false);
mpData->result = RefreshCode::RefreshAll; mpData->result = RefreshCode::RefreshAll;
} }

View File

@ -60,7 +60,9 @@ UIHandle::Result VelocitySliderHandle::SetValue
UIHandle::Result VelocitySliderHandle::CommitChanges UIHandle::Result VelocitySliderHandle::CommitChanges
(const wxMouseEvent &, AudacityProject *pProject) (const wxMouseEvent &, AudacityProject *pProject)
{ {
pProject->PushState(_("Moved velocity slider"), _("Velocity"), UndoPush::CONSOLIDATE); ProjectManager::Get( *pProject )
.PushState(_("Moved velocity slider"), _("Velocity"),
UndoPush::CONSOLIDATE);
return RefreshCode::RefreshCell; return RefreshCode::RefreshCell;
} }

View File

@ -81,7 +81,7 @@ unsigned NoteTrackVRulerControls::HandleWheelRotation
return RefreshNone; return RefreshNone;
} }
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
return RefreshCell | UpdateVRuler; return RefreshCell | UpdateVRuler;
} }

View File

@ -240,7 +240,7 @@ void NoteTrackVRulerMenuTable::OnZoom( int iZoomCode ){
mpData->pTrack->ShiftNoteRange(-12); mpData->pTrack->ShiftNoteRange(-12);
break; break;
} }
GetActiveProject()->ModifyState(false); ProjectManager::Get( *GetActiveProject() ).ModifyState(false);
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = UpdateVRuler | RefreshAll; mpData->result = UpdateVRuler | RefreshAll;
} }
@ -341,7 +341,7 @@ UIHandle::Result NoteTrackVZoomHandle::Release
} }
mZoomEnd = mZoomStart = 0; mZoomEnd = mZoomStart = 0;
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
return RefreshAll; return RefreshAll;
} }

View File

@ -252,7 +252,7 @@ UIHandle::Result StretchHandle::Release
/* i18n-hint: (noun) The track that is used for MIDI notes which can be /* i18n-hint: (noun) The track that is used for MIDI notes which can be
dragged to change their duration.*/ dragged to change their duration.*/
pProject->PushState(_("Stretch Note Track"), ProjectManager::Get( *pProject ).PushState(_("Stretch Note Track"),
/* i18n-hint: In the history list, indicates a MIDI note has /* i18n-hint: In the history list, indicates a MIDI note has
been dragged to change its duration (stretch it). Using either past been dragged to change its duration (stretch it). Using either past
or present tense is fine here. If unsure, go for whichever is or present tense is fine here. If unsure, go for whichever is
@ -264,7 +264,7 @@ UIHandle::Result StretchHandle::Release
UIHandle::Result StretchHandle::Cancel(AudacityProject *pProject) UIHandle::Result StretchHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
return RefreshCode::RefreshNone; return RefreshCode::RefreshNone;
} }

View File

@ -220,19 +220,21 @@ UIHandle::Result CutlineHandle::Release
UIHandle::Result result = RefreshCode::RefreshNone; UIHandle::Result result = RefreshCode::RefreshNone;
// Only now commit the result to the undo stack // Only now commit the result to the undo stack
AudacityProject *const project = pProject;
switch (mOperation) { switch (mOperation) {
default: default:
wxASSERT(false); wxASSERT(false);
case Merge: case Merge:
project->PushState(_("Merged Clips"), _("Merge"), UndoPush::CONSOLIDATE); ProjectManager::Get( *pProject )
.PushState(_("Merged Clips"), _("Merge"), UndoPush::CONSOLIDATE);
break; break;
case Expand: case Expand:
project->PushState(_("Expanded Cut Line"), _("Expand")); ProjectManager::Get( *pProject )
.PushState(_("Expanded Cut Line"), _("Expand"));
result |= RefreshCode::UpdateSelection; result |= RefreshCode::UpdateSelection;
break; break;
case Remove: case Remove:
project->PushState(_("Removed Cut Line"), _("Remove")); ProjectManager::Get( *pProject )
.PushState(_("Removed Cut Line"), _("Remove"));
break; break;
} }
@ -244,7 +246,7 @@ UIHandle::Result CutlineHandle::Cancel(AudacityProject *pProject)
{ {
using namespace RefreshCode; using namespace RefreshCode;
UIHandle::Result result = RefreshCell; UIHandle::Result result = RefreshCell;
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
if (mOperation == Expand) { if (mOperation == Expand) {
AudacityProject &project = *pProject; AudacityProject &project = *pProject;
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;

View File

@ -434,7 +434,7 @@ UIHandle::Result SampleHandle::Release
//************************************************* //*************************************************
//On up-click, send the state to the undo stack //On up-click, send the state to the undo stack
mClickedTrack.reset(); //Set this to NULL so it will catch improper drag events. mClickedTrack.reset(); //Set this to NULL so it will catch improper drag events.
pProject->PushState(_("Moved Samples"), ProjectManager::Get( *pProject ).PushState(_("Moved Samples"),
_("Sample Edit"), _("Sample Edit"),
UndoPush::CONSOLIDATE | UndoPush::AUTOSAVE); UndoPush::CONSOLIDATE | UndoPush::AUTOSAVE);
@ -444,7 +444,7 @@ UIHandle::Result SampleHandle::Release
UIHandle::Result SampleHandle::Cancel(AudacityProject *pProject) UIHandle::Result SampleHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
mClickedTrack.reset(); mClickedTrack.reset();
return RefreshCode::RefreshCell; return RefreshCode::RefreshCell;
} }

View File

@ -219,7 +219,8 @@ void WaveColorMenuTable::OnWaveColorChange(wxCommandEvent & event)
for (auto channel : TrackList::Channels(pTrack)) for (auto channel : TrackList::Channels(pTrack))
channel->SetWaveColorIndex(newWaveColor); channel->SetWaveColorIndex(newWaveColor);
project->PushState(wxString::Format(_("Changed '%s' to %s"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Changed '%s' to %s"),
pTrack->GetName(), pTrack->GetName(),
GetWaveColorStr(newWaveColor)), GetWaveColorStr(newWaveColor)),
_("WaveColor Change")); _("WaveColor Change"));
@ -337,7 +338,8 @@ void FormatMenuTable::OnFormatChange(wxCommandEvent & event)
channel->ConvertToSampleFormat(newFormat); channel->ConvertToSampleFormat(newFormat);
/* i18n-hint: The strings name a track and a format */ /* i18n-hint: The strings name a track and a format */
project->PushState(wxString::Format(_("Changed '%s' to %s"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Changed '%s' to %s"),
pTrack->GetName(), pTrack->GetName(),
GetSampleFormatStr(newFormat)), GetSampleFormatStr(newFormat)),
_("Format Change")); _("Format Change"));
@ -438,7 +440,8 @@ void RateMenuTable::SetRate(WaveTrack * pTrack, double rate)
// Separate conversion of "rate" enables changing the decimals without affecting i18n // Separate conversion of "rate" enables changing the decimals without affecting i18n
wxString rateString = wxString::Format(wxT("%.3f"), rate); wxString rateString = wxString::Format(wxT("%.3f"), rate);
/* i18n-hint: The string names a track */ /* i18n-hint: The string names a track */
project->PushState(wxString::Format(_("Changed '%s' to %s Hz"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Changed '%s' to %s Hz"),
pTrack->GetName(), rateString), pTrack->GetName(), rateString),
_("Rate Change")); _("Rate Change"));
} }
@ -739,7 +742,7 @@ void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event)
} }
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->ModifyState(true); ProjectManager::Get( *project ).ModifyState(true);
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = RefreshAll | UpdateVRuler; mpData->result = RefreshAll | UpdateVRuler;
@ -794,7 +797,7 @@ void WaveTrackMenuTable::OnSpectrogramSettings(wxCommandEvent &)
if (0 != dialog.ShowModal()) { if (0 != dialog.ShowModal()) {
// Redraw // Redraw
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->ModifyState(true); ProjectManager::Get( *project ).ModifyState(true);
//Bug 1725 Toolbar was left greyed out. //Bug 1725 Toolbar was left greyed out.
//This solution is overkill, but does fix the problem and is what the //This solution is overkill, but does fix the problem and is what the
//prefs dialog normally does. //prefs dialog normally does.
@ -880,7 +883,8 @@ void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &)
} }
/* i18n-hint: The string names a track */ /* i18n-hint: The string names a track */
project->PushState(wxString::Format(_("Made '%s' a stereo track"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Made '%s' a stereo track"),
pTrack->GetName()), pTrack->GetName()),
_("Make Stereo")); _("Make Stereo"));
@ -948,7 +952,8 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &)
trackPanel.SetFocusedTrack(partner); trackPanel.SetFocusedTrack(partner);
/* i18n-hint: The string names a track */ /* i18n-hint: The string names a track */
project->PushState(wxString::Format(_("Swapped Channels in '%s'"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Swapped Channels in '%s'"),
pTrack->GetName()), pTrack->GetName()),
_("Swap Channels")); _("Swap Channels"));
@ -962,7 +967,8 @@ void WaveTrackMenuTable::OnSplitStereo(wxCommandEvent &)
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack); WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
/* i18n-hint: The string names a track */ /* i18n-hint: The string names a track */
project->PushState(wxString::Format(_("Split stereo track '%s'"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Split stereo track '%s'"),
pTrack->GetName()), pTrack->GetName()),
_("Split")); _("Split"));
@ -977,7 +983,8 @@ void WaveTrackMenuTable::OnSplitStereoMono(wxCommandEvent &)
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack); WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
/* i18n-hint: The string names a track */ /* i18n-hint: The string names a track */
project->PushState(wxString::Format(_("Split Stereo to Mono '%s'"), ProjectManager::Get( *project ).
PushState(wxString::Format(_("Split Stereo to Mono '%s'"),
pTrack->GetName()), pTrack->GetName()),
_("Split to Mono")); _("Split to Mono"));

View File

@ -57,7 +57,8 @@ UIHandle::Result GainSliderHandle::SetValue
UIHandle::Result GainSliderHandle::CommitChanges UIHandle::Result GainSliderHandle::CommitChanges
(const wxMouseEvent &, AudacityProject *pProject) (const wxMouseEvent &, AudacityProject *pProject)
{ {
pProject->PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE); ProjectManager::Get( *pProject )
.PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE);
return RefreshCode::RefreshCell; return RefreshCode::RefreshCell;
} }
@ -135,7 +136,8 @@ UIHandle::Result PanSliderHandle::SetValue(AudacityProject *pProject, float newV
UIHandle::Result PanSliderHandle::CommitChanges UIHandle::Result PanSliderHandle::CommitChanges
(const wxMouseEvent &, AudacityProject *pProject) (const wxMouseEvent &, AudacityProject *pProject)
{ {
pProject->PushState(_("Moved pan slider"), _("Pan"), UndoPush::CONSOLIDATE); ProjectManager::Get( *pProject )
.PushState(_("Moved pan slider"), _("Pan"), UndoPush::CONSOLIDATE);
return RefreshCode::RefreshCell; return RefreshCode::RefreshCell;
} }

View File

@ -186,7 +186,7 @@ unsigned WaveTrackVRulerControls::HandleWheelRotation
else else
return RefreshNone; return RefreshNone;
pProject->ModifyState(true); ProjectManager::Get( *pProject ).ModifyState(true);
return RefreshCell | UpdateVRuler; return RefreshCell | UpdateVRuler;
} }

View File

@ -332,7 +332,7 @@ void WaveTrackVZoomHandle::DoZoom
zoomEnd = zoomStart = 0; zoomEnd = zoomStart = 0;
if( pProject ) if( pProject )
pProject->ModifyState(true); ProjectManager::Get( *pProject ).ModifyState(true);
} }
enum { enum {
@ -478,7 +478,7 @@ void WaveformVRulerMenuTable::OnWaveformScaleType(wxCommandEvent &evt)
channel->GetIndependentWaveformSettings().scaleType = newScaleType; channel->GetIndependentWaveformSettings().scaleType = newScaleType;
} }
::GetActiveProject()->ModifyState(true); ProjectManager::Get( *::GetActiveProject() ).ModifyState(true);
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = UpdateVRuler | RefreshAll; mpData->result = UpdateVRuler | RefreshAll;
@ -550,7 +550,7 @@ void SpectrumVRulerMenuTable::OnSpectrumScaleType(wxCommandEvent &evt)
for (auto channel : TrackList::Channels(wt)) for (auto channel : TrackList::Channels(wt))
channel->GetIndependentSpectrogramSettings().scaleType = newScaleType; channel->GetIndependentSpectrogramSettings().scaleType = newScaleType;
::GetActiveProject()->ModifyState(true); ProjectManager::Get( *::GetActiveProject() ).ModifyState(true);
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = UpdateVRuler | RefreshAll; mpData->result = UpdateVRuler | RefreshAll;

View File

@ -104,7 +104,8 @@ void TimeTrackMenuTable::OnSetTimeTrackRange(wxCommandEvent & /*event*/)
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
pTrack->SetRangeLower((double)lower / 100.0); pTrack->SetRangeLower((double)lower / 100.0);
pTrack->SetRangeUpper((double)upper / 100.0); pTrack->SetRangeUpper((double)upper / 100.0);
project->PushState(wxString::Format(_("Set range to '%ld' - '%ld'"), ProjectManager::Get( *project )
.PushState(wxString::Format(_("Set range to '%ld' - '%ld'"),
lower, lower,
upper), upper),
/* i18n-hint: (verb)*/ /* i18n-hint: (verb)*/
@ -119,7 +120,8 @@ void TimeTrackMenuTable::OnTimeTrackLin(wxCommandEvent & /*event*/)
TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack); TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack);
pTrack->SetDisplayLog(false); pTrack->SetDisplayLog(false);
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->PushState(_("Set time track display to linear"), _("Set Display")); ProjectManager::Get( *project )
.PushState(_("Set time track display to linear"), _("Set Display"));
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = RefreshAll | UpdateVRuler; mpData->result = RefreshAll | UpdateVRuler;
@ -130,7 +132,8 @@ void TimeTrackMenuTable::OnTimeTrackLog(wxCommandEvent & /*event*/)
TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack); TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack);
pTrack->SetDisplayLog(true); pTrack->SetDisplayLog(true);
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->PushState(_("Set time track display to logarithmic"), _("Set Display")); ProjectManager::Get( *project )
.PushState(_("Set time track display to logarithmic"), _("Set Display"));
using namespace RefreshCode; using namespace RefreshCode;
mpData->result = RefreshAll | UpdateVRuler; mpData->result = RefreshAll | UpdateVRuler;
@ -142,11 +145,13 @@ void TimeTrackMenuTable::OnTimeTrackLogInt(wxCommandEvent & /*event*/)
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
if (pTrack->GetInterpolateLog()) { if (pTrack->GetInterpolateLog()) {
pTrack->SetInterpolateLog(false); pTrack->SetInterpolateLog(false);
project->PushState(_("Set time track interpolation to linear"), _("Set Interpolation")); ProjectManager::Get( *project )
.PushState(_("Set time track interpolation to linear"), _("Set Interpolation"));
} }
else { else {
pTrack->SetInterpolateLog(true); pTrack->SetInterpolateLog(true);
project->PushState(_("Set time track interpolation to logarithmic"), _("Set Interpolation")); ProjectManager::Get( *project ).
PushState(_("Set time track interpolation to logarithmic"), _("Set Interpolation"));
} }
mpData->result = RefreshCode::RefreshAll; mpData->result = RefreshCode::RefreshAll;
} }

View File

@ -287,7 +287,7 @@ UIHandle::Result EnvelopeHandle::Release
const bool needUpdate = ForwardEventToEnvelopes(event, viewInfo); const bool needUpdate = ForwardEventToEnvelopes(event, viewInfo);
pProject->PushState( ProjectManager::Get( *pProject ).PushState(
/* i18n-hint: (verb) Audacity has just adjusted the envelope .*/ /* i18n-hint: (verb) Audacity has just adjusted the envelope .*/
_("Adjusted envelope."), _("Adjusted envelope."),
/* i18n-hint: The envelope is a curve that controls the audio loudness.*/ /* i18n-hint: The envelope is a curve that controls the audio loudness.*/
@ -302,7 +302,7 @@ UIHandle::Result EnvelopeHandle::Release
UIHandle::Result EnvelopeHandle::Cancel(AudacityProject *pProject) UIHandle::Result EnvelopeHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
mEnvelopeEditors.clear(); mEnvelopeEditors.clear();
return RefreshCode::RefreshCell; return RefreshCode::RefreshCell;
} }

View File

@ -579,7 +579,7 @@ UIHandle::Result SelectHandle::Click
} }
} ); } );
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
// Do not start a drag // Do not start a drag
return RefreshAll | UpdateSelection | Cancelled; return RefreshAll | UpdateSelection | Cancelled;
@ -664,7 +664,7 @@ UIHandle::Result SelectHandle::Click
}; };
// For persistence of the selection change: // For persistence of the selection change:
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
// Get timer events so we can auto-scroll // Get timer events so we can auto-scroll
Connect(pProject); Connect(pProject);
@ -702,7 +702,7 @@ UIHandle::Result SelectHandle::Click
static_cast<WaveTrack*>(pTrack), static_cast<WaveTrack*>(pTrack),
viewInfo, event.m_y, mRect.y, mRect.height); viewInfo, event.m_y, mRect.y, mRect.height);
// For persistence of the selection change: // For persistence of the selection change:
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
mSelectionBoundary = SBWidth; mSelectionBoundary = SBWidth;
return UpdateSelection; return UpdateSelection;
} }
@ -986,7 +986,7 @@ UIHandle::Result SelectHandle::Release
wxWindow *) wxWindow *)
{ {
using namespace RefreshCode; using namespace RefreshCode;
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
mFrequencySnapper.reset(); mFrequencySnapper.reset();
mSnapManager.reset(); mSnapManager.reset();
if (mSelectionStateChanger) { if (mSelectionStateChanger) {
@ -1126,7 +1126,7 @@ void SelectHandle::StartSelection( AudacityProject *pProject )
// PRL: commented out the Sonify stuff with the TrackPanel refactor. // PRL: commented out the Sonify stuff with the TrackPanel refactor.
// It was no-op anyway. // It was no-op anyway.
//SonifyBeginModifyState(); //SonifyBeginModifyState();
pProject->ModifyState(false); ProjectManager::Get( *pProject ).ModifyState(false);
//SonifyEndModifyState(); //SonifyEndModifyState();
} }

View File

@ -835,7 +835,7 @@ UIHandle::Result TimeShiftHandle::Release
fabs( mClipMoveState.hSlideAmount ) ); fabs( mClipMoveState.hSlideAmount ) );
consolidate = true; consolidate = true;
} }
pProject->PushState(msg, _("Time-Shift"), ProjectManager::Get( *pProject ).PushState(msg, _("Time-Shift"),
consolidate ? (UndoPush::CONSOLIDATE) : (UndoPush::AUTOSAVE)); consolidate ? (UndoPush::CONSOLIDATE) : (UndoPush::AUTOSAVE));
return result | FixScrollbars; return result | FixScrollbars;
@ -843,7 +843,7 @@ UIHandle::Result TimeShiftHandle::Release
UIHandle::Result TimeShiftHandle::Cancel(AudacityProject *pProject) UIHandle::Result TimeShiftHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
return RefreshCode::RefreshAll; return RefreshCode::RefreshAll;
} }

View File

@ -39,7 +39,7 @@ UIHandle::Result MinimizeButtonHandle::CommitChanges
bool wasMinimized = pTrack->GetMinimized(); bool wasMinimized = pTrack->GetMinimized();
for (auto channel : TrackList::Channels(pTrack.get())) for (auto channel : TrackList::Channels(pTrack.get()))
channel->SetMinimized(!wasMinimized); channel->SetMinimized(!wasMinimized);
pProject->ModifyState(true); ProjectManager::Get( *pProject ).ModifyState(true);
// Redraw all tracks when any one of them expands or contracts // Redraw all tracks when any one of them expands or contracts
// (Could we invent a return code that draws only those at or below // (Could we invent a return code that draws only those at or below

View File

@ -221,7 +221,8 @@ void TrackMenuTable::OnSetName(wxCommandEvent &)
for (auto channel : TrackList::Channels(pTrack)) for (auto channel : TrackList::Channels(pTrack))
channel->SetName(newName); channel->SetName(newName);
proj->PushState(wxString::Format(_("Renamed '%s' to '%s'"), ProjectManager::Get( *proj )
.PushState(wxString::Format(_("Renamed '%s' to '%s'"),
oldName, oldName,
newName), newName),
_("Name Change")); _("Name Change"));

View File

@ -180,7 +180,7 @@ UIHandle::Result TrackSelectHandle::Release
wxASSERT( mpTrack ); wxASSERT( mpTrack );
if (mRearrangeCount != 0) { if (mRearrangeCount != 0) {
AudacityProject *const project = ::GetActiveProject(); AudacityProject *const project = ::GetActiveProject();
project->PushState( ProjectManager::Get( *project ).PushState(
wxString::Format( wxString::Format(
/* i18n-hint: will substitute name of track for %s */ /* i18n-hint: will substitute name of track for %s */
( mRearrangeCount < 0 ? _("Moved '%s' up") : _("Moved '%s' down") ), ( mRearrangeCount < 0 ? _("Moved '%s' up") : _("Moved '%s' down") ),
@ -199,7 +199,7 @@ UIHandle::Result TrackSelectHandle::Release
UIHandle::Result TrackSelectHandle::Cancel(AudacityProject *pProject) UIHandle::Result TrackSelectHandle::Cancel(AudacityProject *pProject)
{ {
pProject->RollbackState(); ProjectManager::Get( *pProject ).RollbackState();
// Bug 1677 // Bug 1677
mpTrack.reset(); mpTrack.reset();
return RefreshCode::RefreshAll; return RefreshCode::RefreshAll;