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

View File

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

View File

@ -842,7 +842,7 @@ bool MacroCommands::ApplyMacro(
if (!res) {
if(proj) {
// 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)
return false;
if( MacroReentryCount <= 1 )
proj->PushState(longDesc, shortDesc);
ProjectManager::Get( *proj ).PushState(longDesc, shortDesc);
return true;
}

View File

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

View File

@ -254,7 +254,7 @@ void HistoryWindow::OnDiscard(wxCommandEvent & WXUNUSED(event))
mSelected -= i;
mManager->RemoveStates(i);
mProject->SetStateTo(mSelected + 1);
ProjectManager::Get( *mProject ).SetStateTo(mSelected + 1);
while(--i >= 0)
mList->DeleteItem(i);
@ -292,7 +292,7 @@ void HistoryWindow::OnItemSelected(wxListEvent &event)
// entry. Doing so can cause unnecessary delays upon initial load or while
// clicking the same entry over and over.
if (selected != mSelected) {
mProject->SetStateTo(selected + 1);
ProjectManager::Get( *mProject ).SetStateTo(selected + 1);
}
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
// updates were done
if (OnKeyDown(viewInfo.selectedRegion, event)) {
pProj->PushState(_("Modified Label"),
ProjectManager::Get( *pProj ).PushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
}
@ -1845,7 +1845,7 @@ unsigned LabelTrack::Char(wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *)
AudacityProject *const pProj = GetActiveProject();
if (OnChar(viewInfo.selectedRegion, event))
pProj->PushState(_("Modified Label"),
ProjectManager::Get( *pProj ).PushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
@ -2130,13 +2130,13 @@ bool LabelTrack::OnChar(SelectedRegion &WXUNUSED(newSel), wxKeyEvent & event)
}
SetSelected(true);
AddLabel(selectedRegion, title, -2);
p->PushState(_("Added label"), _("Label"));
ProjectManager::Get( *p ).PushState(_("Added label"), _("Label"));
return false;
}
else {
SetSelected(true);
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:
if (CutSelectedText())
{
p->PushState(_("Modified Label"),
ProjectManager::Get( *p ).PushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
}
@ -2245,7 +2245,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
case OnPasteSelectedTextID:
if (PasteSelectedText(selectedRegion.t0(), selectedRegion.t1()))
{
p->PushState(_("Modified Label"),
ProjectManager::Get( *p ).PushState(_("Modified Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
}
@ -2257,7 +2257,7 @@ void LabelTrack::OnContextMenu(wxCommandEvent & evt)
if (ndx != -1)
{
DeleteLabel(ndx);
p->PushState(_("Deleted Label"),
ProjectManager::Get( *p ).PushState(_("Deleted Label"),
_("Label Edit"),
UndoPush::CONSOLIDATE);
}
@ -3104,7 +3104,8 @@ void LabelTrack::DoEditLabels
#endif
if (dlg.ShowModal() == wxID_OK) {
project.PushState(_("Edited labels"), _("Label"));
ProjectManager::Get( project )
.PushState(_("Edited labels"), _("Label"));
window.RedrawProject();
}
}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -35,8 +35,6 @@
#include "xml/XMLTagHandler.h" // to inherit
const int AudacityProjectTimerID = 5200;
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
EVT_PROJECT_STATUS_UPDATE, wxCommandEvent);
@ -61,7 +59,6 @@ struct UndoState;
enum class UndoPush : unsigned char;
AudacityProject *CreateNewAudacityProject();
AUDACITY_DLL_API AudacityProject *GetActiveProject();
void GetDefaultWindowRect(wxRect *defRect);
@ -165,10 +162,7 @@ using AttachedWindows = ClientData::Site<
using ProjectWindow = AudacityProject;
class AUDACITY_DLL_API AudacityProject final : public wxFrame,
public TrackPanelListener,
public SelectionBarListener,
public SpectralSelectionBarListener,
public XMLTagHandler,
public AudioIOListener,
private PrefsListener
, public AttachedObjects
, public AttachedWindows
@ -200,47 +194,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
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
{
bool decodeError;
@ -250,26 +203,14 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
};
ReadProjectResults ReadProjectFile( const FilePath &fileName );
void OpenFile(const FilePath &fileName, bool addtohistory = true);
private:
void EnqueueODTasks();
public:
using wxFrame::DetachMenuBar;
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);
// Takes array of unique pointers; returns array of shared
std::vector< std::shared_ptr<Track> >
AddImportedTracks(const FilePath &fileName,
TrackHolders &&newTracks);
void CloseLock();
bool Save();
@ -283,7 +224,9 @@ private:
public:
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);
wxWindow *GetMainPage() { return mMainPage; }
@ -292,13 +235,8 @@ public:
// Timer Record Auto Save/Export Routines
bool SaveFromTimerRecording(wxFileName fnFile);
bool IsProjectSaved();
void ResetProjectToEmpty();
void ResetProjectFileIO();
// 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 ResetProjectFileIO();
// Message Handlers
@ -316,10 +254,7 @@ public:
void OnMove(wxMoveEvent & event);
void DoScroll();
void OnScroll(wxScrollEvent & event);
void OnCloseWindow(wxCloseEvent & event);
void OnTimer(wxTimerEvent & event);
void OnToolBarUpdate(wxCommandEvent & event);
void OnOpenAudioFile(wxCommandEvent & event);
void HandleResize();
void UpdateLayout();
@ -369,35 +304,7 @@ public:
const wxString &GetStatus() const { return mLastMainStatusMessage; }
void SetStatus(const wxString &msg);
void OnStatusChange( wxCommandEvent& );
private:
bool SnapSelection();
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
@ -408,32 +315,13 @@ public:
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:
void OnThemeChange(wxCommandEvent & evt);
void InitialState();
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 DeleteCurrentAutoSaveFile();
private:
@ -448,13 +336,10 @@ public:
std::shared_ptr<TrackList> mLastSavedTracks;
private:
bool mDirty{ false };
// Window elements
wxString mLastMainStatusMessage;
std::unique_ptr<wxTimer> mTimer;
void RestartTimer();
wxPanel *mTopPanel{};
wxWindow * mMainPage;
@ -481,24 +366,21 @@ private:
void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
bool IsTimerRecordCancelled(){return mTimerRecordCanceled;}
void SetTimerRecordCancelled(){mTimerRecordCanceled=true;}
void ResetTimerRecordCancelled(){mTimerRecordCanceled=false;}
private:
bool mIsDeleting{ false };
public:
bool IsBeingDeleted() const { return mIsDeleting; }
void SetIsBeingDeleted() { mIsDeleting = true; }
bool IsRecovered() const { return mIsRecovered; }
void SetImportedDependencies( bool value ) { mImportedDependencies = value; }
void SetLoadedFromAup( bool value ) { mbLoadedFromAup = value; }
private:
bool mLockPlayRegion;
std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
// Last auto-save file name and path (empty if none)
wxString mAutoSaveFileName;
FilePath mAutoSaveFileName;
// Are we currently auto-saving or not?
bool mAutoSaving{ false };
@ -509,9 +391,6 @@ private:
// The auto-save data dir the project has been recovered from
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
bool mImportedDependencies{ false };
@ -519,16 +398,6 @@ private:
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 };
public:
@ -560,14 +429,175 @@ public:
private:
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
static XMLTagHandler *RecordingRecoveryFactory( AudacityProject &project );
static ProjectFileIORegistry::Entry sRecoveryFactory;
static XMLTagHandler *ImportHandlerFactory( AudacityProject &project );
static ProjectFileIORegistry::Entry sImportHandlerFactory;
public:
PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
// non-static data members
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()
};

View File

@ -417,9 +417,10 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
// as its possible that they plan to free up some
// space before the recording begins
AudacityProject* pProject = GetActiveProject();
auto &projectManager = ProjectManager::Get( *pProject );
// 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?
int iMinsRecording = m_TimeSpan_Duration.GetMinutes();
@ -429,9 +430,9 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
// Format the strings
wxString sRemainingTime;
sRemainingTime = pProject->GetHoursMinsString(iMinsLeft);
sRemainingTime = projectManager.GetHoursMinsString(iMinsLeft);
wxString sPlannedTime;
sPlannedTime = pProject->GetHoursMinsString(iMinsRecording);
sPlannedTime = projectManager.GetHoursMinsString(iMinsRecording);
// Create the message string
wxString sMessage;

View File

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

View File

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

View File

@ -41,7 +41,7 @@ void ImportCommand::PopulateOrExchange(ShuttleGui & S)
}
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())
{
auto project = &context.project;
AudacityProject::OpenFiles(project);
ProjectManager::OpenFiles(project);
}
else
{
context.project.OpenFile(mFileName, mbAddToHistory);
ProjectManager::Get( context.project )
.OpenFile(mFileName, mbAddToHistory);
}
const auto &newFileName = context.project.GetFileName();

View File

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

View File

@ -297,7 +297,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
auto state = UndoManager::Get( *project ).GetCurrentState();
auto cleanup = finally( [&] {
if(!success)
project->SetStateTo(state);
ProjectManager::Get( *project ).SetStateTo( state );
} );
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? */
#endif // USE_MIDI
mProject = AudacityProject::OpenProject( mProject, targetfile );
mProject = ProjectManager::OpenProject( mProject, targetfile );
// Set tok to right after filename
temptok2.SetString(targettoken);
@ -440,7 +440,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln)
}
// Amend the undo transaction made by import
mProject->ModifyState(false);
ProjectManager::Get( *mProject ).ModifyState(false);
} // end of converting "offset" argument
else
{
@ -484,7 +484,7 @@ void LOFImportFileHandle::doDurationAndScrollOffset()
if (doSomething)
// Amend last undo state
mProject->ModifyState(false);
ProjectManager::Get( *mProject ).ModifyState(false);
}
LOFImportFileHandle::~LOFImportFileHandle()

View File

@ -389,7 +389,7 @@ void DoSelectClipBoundary(AudacityProject &project, bool next)
else
selectedRegion.setT0(results[0].time);
project.ModifyState(false);
ProjectManager::Get( project ).ModifyState(false);
trackPanel.Refresh(false);
wxString message = ClipBoundaryMessage(results);
@ -572,7 +572,7 @@ void DoSelectClip(AudacityProject &project, bool next)
double t0 = results[0].startTime;
double t1 = results[0].endTime;
selectedRegion.setTimes(t0, t1);
project.ModifyState(false);
ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false);
@ -618,7 +618,7 @@ void DoCursorClipBoundary
// value.
double time = results[0].time;
selectedRegion.setTimes(time, time);
project.ModifyState(false);
ProjectManager::Get( project ).ModifyState(false);
trackPanel.ScrollIntoView(selectedRegion.t0());
trackPanel.Refresh(false);
@ -720,7 +720,8 @@ void DoClipLeftOrRight
// keypress (keydown, then keyup), and holding down a key
// (multiple keydowns followed by a keyup) result in a single
// 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 )

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -258,7 +258,7 @@ bool DoPlayStopSelect
// -- change t0, collapsing to point only if t1 was greater
selection.setT0(time, false);
project.ModifyState(false); // without bWantsAutoSave
ProjectManager::Get( project ).ModifyState(false); // without bWantsAutoSave
return true;
}
return false;
@ -459,7 +459,7 @@ void OnTimerRecord(const CommandContext &context)
switch (iTimerRecordingOutcome) {
case POST_TIMER_RECORD_CANCEL_WAIT:
// Canceled on the wait dialog
project.RollbackState();
ProjectManager::Get( project ).RollbackState();
break;
case POST_TIMER_RECORD_CANCEL:
// 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(),
// which is blocked by this function.
// so instead we mark a flag to undo it there.
project.SetTimerRecordCancelled();
ProjectManager::Get( project ).SetTimerRecordCancelled();
break;
case POST_TIMER_RECORD_NOTHING:
// No action required
@ -624,7 +624,7 @@ void OnPunchAndRoll(const CommandContext &context)
;
else
// Roll back the deletions
project.RollbackState();
ProjectManager::Get( project ).RollbackState();
}
#endif

View File

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

View File

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

View File

@ -110,7 +110,7 @@ UIHandle::Result LabelTextHandle::Click
// PRL: bug1659 -- make selection change undo correctly
const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
if (!unsafe)
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
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,
event.Button(wxMOUSE_BTN_RIGHT))) {
// No undo items needed??
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
return RefreshAll;
}
return RefreshNone;

View File

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

View File

@ -60,7 +60,9 @@ UIHandle::Result VelocitySliderHandle::SetValue
UIHandle::Result VelocitySliderHandle::CommitChanges
(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;
}

View File

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

View File

@ -240,7 +240,7 @@ void NoteTrackVRulerMenuTable::OnZoom( int iZoomCode ){
mpData->pTrack->ShiftNoteRange(-12);
break;
}
GetActiveProject()->ModifyState(false);
ProjectManager::Get( *GetActiveProject() ).ModifyState(false);
using namespace RefreshCode;
mpData->result = UpdateVRuler | RefreshAll;
}
@ -341,7 +341,7 @@ UIHandle::Result NoteTrackVZoomHandle::Release
}
mZoomEnd = mZoomStart = 0;
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
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
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
been dragged to change its duration (stretch it). Using either past
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)
{
pProject->RollbackState();
ProjectManager::Get( *pProject ).RollbackState();
return RefreshCode::RefreshNone;
}

View File

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

View File

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

View File

@ -57,7 +57,8 @@ UIHandle::Result GainSliderHandle::SetValue
UIHandle::Result GainSliderHandle::CommitChanges
(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;
}
@ -135,7 +136,8 @@ UIHandle::Result PanSliderHandle::SetValue(AudacityProject *pProject, float newV
UIHandle::Result PanSliderHandle::CommitChanges
(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;
}

View File

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

View File

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

View File

@ -104,7 +104,8 @@ void TimeTrackMenuTable::OnSetTimeTrackRange(wxCommandEvent & /*event*/)
AudacityProject *const project = ::GetActiveProject();
pTrack->SetRangeLower((double)lower / 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,
upper),
/* i18n-hint: (verb)*/
@ -119,7 +120,8 @@ void TimeTrackMenuTable::OnTimeTrackLin(wxCommandEvent & /*event*/)
TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack);
pTrack->SetDisplayLog(false);
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;
mpData->result = RefreshAll | UpdateVRuler;
@ -130,7 +132,8 @@ void TimeTrackMenuTable::OnTimeTrackLog(wxCommandEvent & /*event*/)
TimeTrack *const pTrack = static_cast<TimeTrack*>(mpData->pTrack);
pTrack->SetDisplayLog(true);
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;
mpData->result = RefreshAll | UpdateVRuler;
@ -142,11 +145,13 @@ void TimeTrackMenuTable::OnTimeTrackLogInt(wxCommandEvent & /*event*/)
AudacityProject *const project = ::GetActiveProject();
if (pTrack->GetInterpolateLog()) {
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 {
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;
}

View File

@ -287,7 +287,7 @@ UIHandle::Result EnvelopeHandle::Release
const bool needUpdate = ForwardEventToEnvelopes(event, viewInfo);
pProject->PushState(
ProjectManager::Get( *pProject ).PushState(
/* i18n-hint: (verb) Audacity has just adjusted the envelope .*/
_("Adjusted envelope."),
/* 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)
{
pProject->RollbackState();
ProjectManager::Get( *pProject ).RollbackState();
mEnvelopeEditors.clear();
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
return RefreshAll | UpdateSelection | Cancelled;
@ -664,7 +664,7 @@ UIHandle::Result SelectHandle::Click
};
// For persistence of the selection change:
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
// Get timer events so we can auto-scroll
Connect(pProject);
@ -702,7 +702,7 @@ UIHandle::Result SelectHandle::Click
static_cast<WaveTrack*>(pTrack),
viewInfo, event.m_y, mRect.y, mRect.height);
// For persistence of the selection change:
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
mSelectionBoundary = SBWidth;
return UpdateSelection;
}
@ -986,7 +986,7 @@ UIHandle::Result SelectHandle::Release
wxWindow *)
{
using namespace RefreshCode;
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
mFrequencySnapper.reset();
mSnapManager.reset();
if (mSelectionStateChanger) {
@ -1126,7 +1126,7 @@ void SelectHandle::StartSelection( AudacityProject *pProject )
// PRL: commented out the Sonify stuff with the TrackPanel refactor.
// It was no-op anyway.
//SonifyBeginModifyState();
pProject->ModifyState(false);
ProjectManager::Get( *pProject ).ModifyState(false);
//SonifyEndModifyState();
}

View File

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

View File

@ -39,7 +39,7 @@ UIHandle::Result MinimizeButtonHandle::CommitChanges
bool wasMinimized = pTrack->GetMinimized();
for (auto channel : TrackList::Channels(pTrack.get()))
channel->SetMinimized(!wasMinimized);
pProject->ModifyState(true);
ProjectManager::Get( *pProject ).ModifyState(true);
// Redraw all tracks when any one of them expands or contracts
// (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))
channel->SetName(newName);
proj->PushState(wxString::Format(_("Renamed '%s' to '%s'"),
ProjectManager::Get( *proj )
.PushState(wxString::Format(_("Renamed '%s' to '%s'"),
oldName,
newName),
_("Name Change"));

View File

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