1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Remove UndoManager.h from other headers

This commit is contained in:
Paul Licameli 2016-02-24 11:41:26 -05:00
parent beea490bb6
commit 73ced7b93f
11 changed files with 52 additions and 31 deletions

View File

@ -42,6 +42,7 @@
#include "../images/Arrow.xpm" #include "../images/Arrow.xpm"
#include "../images/Empty9x16.xpm" #include "../images/Empty9x16.xpm"
#include "BatchCommands.h" #include "BatchCommands.h"
#include "Track.h"
#include "UndoManager.h" #include "UndoManager.h"
#include "Theme.h" #include "Theme.h"

View File

@ -36,6 +36,7 @@ undo memory so as to free up space.
#include "UndoManager.h" #include "UndoManager.h"
#include "Project.h" #include "Project.h"
#include "ShuttleGui.h" #include "ShuttleGui.h"
#include "Track.h"
enum { enum {
ID_AVAIL = 1000, ID_AVAIL = 1000,

View File

@ -58,6 +58,7 @@ for drawing different aspects of the label and its text box.
#include "Project.h" #include "Project.h"
#include "TrackArtist.h" #include "TrackArtist.h"
#include "TrackPanel.h" #include "TrackPanel.h"
#include "UndoManager.h"
#include "commands/CommandManager.h" #include "commands/CommandManager.h"
#include "effects/TimeWarper.h" #include "effects/TimeWarper.h"

View File

@ -119,6 +119,7 @@ simplifies construction of menu items.
#include "Snap.h" #include "Snap.h"
#include "UndoManager.h"
#include "WaveTrack.h" #include "WaveTrack.h"
#if defined(EXPERIMENTAL_CRASH_REPORT) #if defined(EXPERIMENTAL_CRASH_REPORT)
@ -1598,10 +1599,10 @@ void AudacityProject::CreateRecentFilesMenu(CommandManager *c)
void AudacityProject::ModifyUndoMenuItems() void AudacityProject::ModifyUndoMenuItems()
{ {
wxString desc; wxString desc;
int cur = mUndoManager.GetCurrentState(); int cur = GetUndoManager()->GetCurrentState();
if (mUndoManager.UndoAvailable()) { if (GetUndoManager()->UndoAvailable()) {
mUndoManager.GetShortDescription(cur, &desc); GetUndoManager()->GetShortDescription(cur, &desc);
mCommandManager.Modify(wxT("Undo"), mCommandManager.Modify(wxT("Undo"),
wxString::Format(_("&Undo %s"), wxString::Format(_("&Undo %s"),
desc.c_str())); desc.c_str()));
@ -1611,8 +1612,8 @@ void AudacityProject::ModifyUndoMenuItems()
wxString::Format(_("&Undo"))); wxString::Format(_("&Undo")));
} }
if (mUndoManager.RedoAvailable()) { if (GetUndoManager()->RedoAvailable()) {
mUndoManager.GetShortDescription(cur+1, &desc); GetUndoManager()->GetShortDescription(cur+1, &desc);
mCommandManager.Modify(wxT("Redo"), mCommandManager.Modify(wxT("Redo"),
wxString::Format(_("&Redo %s"), wxString::Format(_("&Redo %s"),
desc.c_str())); desc.c_str()));
@ -1756,16 +1757,16 @@ wxUint32 AudacityProject::GetUpdateFlags()
if((msClipT1 - msClipT0) > 0.0) if((msClipT1 - msClipT0) > 0.0)
flags |= ClipboardFlag; flags |= ClipboardFlag;
if (mUndoManager.UnsavedChanges()) if (GetUndoManager()->UnsavedChanges())
flags |= UnsavedChangesFlag; flags |= UnsavedChangesFlag;
if (!mLastEffect.IsEmpty()) if (!mLastEffect.IsEmpty())
flags |= HasLastEffectFlag; flags |= HasLastEffectFlag;
if (mUndoManager.UndoAvailable()) if (GetUndoManager()->UndoAvailable())
flags |= UndoAvailableFlag; flags |= UndoAvailableFlag;
if (mUndoManager.RedoAvailable()) if (GetUndoManager()->RedoAvailable())
flags |= RedoAvailableFlag; flags |= RedoAvailableFlag;
if (ZoomInAvailable() && (flags & TracksExistFlag)) if (ZoomInAvailable() && (flags & TracksExistFlag))
@ -3761,7 +3762,7 @@ void AudacityProject::OnPrint()
void AudacityProject::OnUndo() void AudacityProject::OnUndo()
{ {
if (!mUndoManager.UndoAvailable()) { if (!GetUndoManager()->UndoAvailable()) {
wxMessageBox(_("Nothing to undo")); wxMessageBox(_("Nothing to undo"));
return; return;
} }
@ -3771,7 +3772,7 @@ void AudacityProject::OnUndo()
return; return;
} }
TrackList *l = mUndoManager.Undo(&mViewInfo.selectedRegion); TrackList *l = GetUndoManager()->Undo(&mViewInfo.selectedRegion);
PopState(l); PopState(l);
mTrackPanel->SetFocusedTrack(NULL); mTrackPanel->SetFocusedTrack(NULL);
@ -3787,7 +3788,7 @@ void AudacityProject::OnUndo()
void AudacityProject::OnRedo() void AudacityProject::OnRedo()
{ {
if (!mUndoManager.RedoAvailable()) { if (!GetUndoManager()->RedoAvailable()) {
wxMessageBox(_("Nothing to redo")); wxMessageBox(_("Nothing to redo"));
return; return;
} }
@ -3796,7 +3797,7 @@ void AudacityProject::OnRedo()
return; return;
} }
TrackList *l = mUndoManager.Redo(&mViewInfo.selectedRegion); TrackList *l = GetUndoManager()->Redo(&mViewInfo.selectedRegion);
PopState(l); PopState(l);
mTrackPanel->SetFocusedTrack(NULL); mTrackPanel->SetFocusedTrack(NULL);
@ -5262,7 +5263,7 @@ void AudacityProject::OnShowClipping()
void AudacityProject::OnHistory() void AudacityProject::OnHistory()
{ {
if (!mHistoryWindow) if (!mHistoryWindow)
mHistoryWindow = new HistoryWindow(this, &mUndoManager); mHistoryWindow = new HistoryWindow(this, GetUndoManager());
mHistoryWindow->Show(); mHistoryWindow->Show();
mHistoryWindow->Raise(); mHistoryWindow->Raise();
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();

View File

@ -27,6 +27,7 @@
#endif #endif
#include "Project.h" #include "Project.h"
#include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER #include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER
#include "UndoManager.h"
#include "WaveTrack.h" #include "WaveTrack.h"
#include "widgets/Meter.h" #include "widgets/Meter.h"

View File

@ -143,6 +143,8 @@ scroll information. It also has some status flags.
#include "FileDialog.h" #include "FileDialog.h"
#include "UndoManager.h"
#include "toolbars/ToolManager.h" #include "toolbars/ToolManager.h"
#include "toolbars/ControlToolBar.h" #include "toolbars/ControlToolBar.h"
#include "toolbars/DeviceToolBar.h" #include "toolbars/DeviceToolBar.h"
@ -796,6 +798,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))), mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))),
mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))), mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))),
mBandwidthSelectionFormatName(gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT(""))), mBandwidthSelectionFormatName(gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT(""))),
mUndoManager(safenew UndoManager),
mDirty(false), mDirty(false),
mRuler(NULL), mRuler(NULL),
mTrackPanel(NULL), mTrackPanel(NULL),
@ -2211,7 +2214,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
// We may not bother to prompt the user to save, if the // We may not bother to prompt the user to save, if the
// project is now empty. // project is now empty.
if (event.CanVeto() && (mEmptyCanBeDirty || bHasTracks)) { if (event.CanVeto() && (mEmptyCanBeDirty || bHasTracks)) {
if (mUndoManager.UnsavedChanges()) { if (GetUndoManager()->UnsavedChanges()) {
wxString Message = _("Save changes before closing?"); wxString Message = _("Save changes before closing?");
if( !bHasTracks ) if( !bHasTracks )
@ -2336,7 +2339,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
// This must be done before the following Deref() since it holds // This must be done before the following Deref() since it holds
// references to the DirManager. // references to the DirManager.
mUndoManager.ClearStates(); GetUndoManager()->ClearStates();
// MM: Tell the DirManager it can now DELETE itself // MM: Tell the DirManager it can now DELETE itself
// if it finds it is no longer needed. If it is still // if it finds it is no longer needed. If it is still
@ -3411,7 +3414,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
bool bHasTracks = (iter.First() != NULL); bool bHasTracks = (iter.First() != NULL);
if (!bHasTracks) if (!bHasTracks)
{ {
if (mUndoManager.UnsavedChanges() && mEmptyCanBeDirty) { if (GetUndoManager()->UnsavedChanges() && mEmptyCanBeDirty) {
int result = wxMessageBox(_("Your project is now empty.\nIf saved, the project will have no tracks.\n\nTo save any previously open tracks:\nClick 'No', Edit > Undo until all tracks\nare open, then File > Save Project.\n\nSave anyway?"), int result = wxMessageBox(_("Your project is now empty.\nIf saved, the project will have no tracks.\n\nTo save any previously open tracks:\nClick 'No', Edit > Undo until all tracks\nare open, then File > Save Project.\n\nSave anyway?"),
_("Warning - Empty Project"), _("Warning - Empty Project"),
wxYES_NO | wxICON_QUESTION, this); wxYES_NO | wxICON_QUESTION, this);
@ -3596,7 +3599,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
t = iter.Next(); t = iter.Next();
} }
mUndoManager.StateSaved(); GetUndoManager()->StateSaved();
} }
// If we get here, saving the project was successful, so we can DELETE // If we get here, saving the project was successful, so we can DELETE
@ -3979,12 +3982,12 @@ void AudacityProject::InitialState()
mImportXMLTagHandler = NULL; mImportXMLTagHandler = NULL;
} }
mUndoManager.ClearStates(); GetUndoManager()->ClearStates();
mUndoManager.PushState(mTracks, mViewInfo.selectedRegion, GetUndoManager()->PushState(mTracks, mViewInfo.selectedRegion,
_("Created new project"), wxT("")); _("Created new project"), wxT(""));
mUndoManager.StateSaved(); GetUndoManager()->StateSaved();
if (mHistoryWindow) if (mHistoryWindow)
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();
@ -3996,11 +3999,16 @@ void AudacityProject::InitialState()
this->UpdateMixerBoard(); this->UpdateMixerBoard();
} }
void AudacityProject::PushState(const wxString &desc, const wxString &shortDesc)
{
PushState(desc, shortDesc, PUSH_AUTOSAVE);
}
void AudacityProject::PushState(const wxString &desc, void AudacityProject::PushState(const wxString &desc,
const wxString &shortDesc, const wxString &shortDesc,
int flags ) int flags )
{ {
mUndoManager.PushState(mTracks, mViewInfo.selectedRegion, GetUndoManager()->PushState(mTracks, mViewInfo.selectedRegion,
desc, shortDesc, flags); desc, shortDesc, flags);
mDirty = true; mDirty = true;
@ -4036,7 +4044,7 @@ void AudacityProject::RollbackState()
void AudacityProject::ModifyState(bool bWantsAutoSave) void AudacityProject::ModifyState(bool bWantsAutoSave)
{ {
mUndoManager.ModifyState(mTracks, mViewInfo.selectedRegion); GetUndoManager()->ModifyState(mTracks, mViewInfo.selectedRegion);
if (bWantsAutoSave) if (bWantsAutoSave)
AutoSave(); AutoSave();
} }
@ -4097,7 +4105,7 @@ void AudacityProject::PopState(TrackList * l)
void AudacityProject::SetStateTo(unsigned int n) void AudacityProject::SetStateTo(unsigned int n)
{ {
TrackList *l = TrackList *l =
mUndoManager.SetStateTo(n, &mViewInfo.selectedRegion); GetUndoManager()->SetStateTo(n, &mViewInfo.selectedRegion);
PopState(l); PopState(l);
HandleResize(); HandleResize();

View File

@ -22,7 +22,6 @@
#include "Experimental.h" #include "Experimental.h"
#include "DirManager.h" #include "DirManager.h"
#include "UndoManager.h"
#include "ViewInfo.h" #include "ViewInfo.h"
#include "TrackPanelListener.h" #include "TrackPanelListener.h"
#include "AudioIOListener.h" #include "AudioIOListener.h"
@ -90,6 +89,7 @@ class WaveTrackArray;
class Regions; class Regions;
class LWSlider; class LWSlider;
class UndoManager;
AudacityProject *CreateNewAudacityProject(); AudacityProject *CreateNewAudacityProject();
AUDACITY_DLL_API AudacityProject *GetActiveProject(); AUDACITY_DLL_API AudacityProject *GetActiveProject();
@ -157,7 +157,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
AudioIOStartStreamOptions GetDefaultPlayOptions(); AudioIOStartStreamOptions GetDefaultPlayOptions();
TrackList *GetTracks() { return mTracks; } TrackList *GetTracks() { return mTracks; }
UndoManager *GetUndoManager() { return &mUndoManager; } UndoManager *GetUndoManager() { return mUndoManager.get(); }
sampleFormat GetDefaultFormat() { return mDefaultFormat; } sampleFormat GetDefaultFormat() { return mDefaultFormat; }
@ -486,8 +486,8 @@ public:
static void AllProjectsDeleteLock(); static void AllProjectsDeleteLock();
static void AllProjectsDeleteUnlock(); static void AllProjectsDeleteUnlock();
void PushState(const wxString &desc, const wxString &shortDesc, void PushState(const wxString &desc, const wxString &shortDesc); // use PUSH_AUTOSAVE
int flags = PUSH_AUTOSAVE); void PushState(const wxString &desc, const wxString &shortDesc, int flags);
void RollbackState(); void RollbackState();
private: private:
@ -546,7 +546,7 @@ public:
static ODLock *msAllProjectDeleteMutex; static ODLock *msAllProjectDeleteMutex;
// History/Undo manager // History/Undo manager
UndoManager mUndoManager; std::unique_ptr<UndoManager> mUndoManager;
bool mDirty; bool mDirty;
// Commands // Commands

View File

@ -181,6 +181,7 @@ is time to refresh some aspect of the screen.
#include "TimeTrack.h" #include "TimeTrack.h"
#include "TrackArtist.h" #include "TrackArtist.h"
#include "TrackPanelAx.h" #include "TrackPanelAx.h"
#include "UndoManager.h"
#include "WaveTrack.h" #include "WaveTrack.h"
#include "commands/Keyboard.h" #include "commands/Keyboard.h"
@ -1497,6 +1498,11 @@ void TrackPanel::MakeParentPushState(const wxString &desc, const wxString &short
mListener->TP_PushState(desc, shortDesc, flags); mListener->TP_PushState(desc, shortDesc, flags);
} }
void TrackPanel::MakeParentPushState(const wxString &desc, const wxString &shortDesc)
{
MakeParentPushState(desc, shortDesc, PUSH_AUTOSAVE);
}
void TrackPanel::MakeParentModifyState(bool bWantsAutoSave) void TrackPanel::MakeParentModifyState(bool bWantsAutoSave)
{ {
mListener->TP_ModifyState(bWantsAutoSave); mListener->TP_ModifyState(bWantsAutoSave);

View File

@ -21,9 +21,9 @@
#include "Experimental.h" #include "Experimental.h"
#include "audacity/Types.h" #include "audacity/Types.h"
#include "UndoManager.h" //JKC: Included for PUSH_XXX definitions.
#include "widgets/NumericTextCtrl.h" #include "widgets/NumericTextCtrl.h"
#include "SelectedRegion.h"
#include "WaveTrackLocation.h" #include "WaveTrackLocation.h"
#include "Snap.h" #include "Snap.h"
@ -457,8 +457,9 @@ protected:
virtual void MakeParentRedrawScrollbars(); virtual void MakeParentRedrawScrollbars();
// AS: Pushing the state preserves state for Undo operations. // AS: Pushing the state preserves state for Undo operations.
virtual void MakeParentPushState(const wxString &desc, const wxString &shortDesc); // use PUSH_AUTOSAVE
virtual void MakeParentPushState(const wxString &desc, const wxString &shortDesc, virtual void MakeParentPushState(const wxString &desc, const wxString &shortDesc,
int flags = PUSH_AUTOSAVE); int flags);
virtual void MakeParentModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after virtual void MakeParentModifyState(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 // a crash, as it can take many seconds for large (eg. 10 track-hours) projects

View File

@ -26,7 +26,7 @@ class AUDACITY_DLL_API TrackPanelListener {
virtual ToolsToolBar * TP_GetToolsToolBar() = 0; virtual ToolsToolBar * TP_GetToolsToolBar() = 0;
virtual void TP_PushState(const wxString &shortDesc, const wxString &longDesc, virtual void TP_PushState(const wxString &shortDesc, const wxString &longDesc,
int flags = PUSH_AUTOSAVE) = 0; int flags) = 0;
virtual void TP_ModifyState(bool bWantsAutoSave) = 0; // if true, writes auto-save file. Should set only if you really want the state change restored after virtual void TP_ModifyState(bool bWantsAutoSave) = 0; // 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 // a crash, as it can take many seconds for large (eg. 10 track-hours) projects
virtual void TP_RedrawScrollbars() = 0; virtual void TP_RedrawScrollbars() = 0;

View File

@ -22,6 +22,7 @@ in a background thread.
#include "ODManager.h" #include "ODManager.h"
#include "../WaveTrack.h" #include "../WaveTrack.h"
#include "../Project.h" #include "../Project.h"
#include "../UndoManager.h"
//temporarilly commented out till it is added to all projects //temporarilly commented out till it is added to all projects
//#include "../Profiler.h" //#include "../Profiler.h"