1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 15:49:36 +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/Empty9x16.xpm"
#include "BatchCommands.h"
#include "Track.h"
#include "UndoManager.h"
#include "Theme.h"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,9 +21,9 @@
#include "Experimental.h"
#include "audacity/Types.h"
#include "UndoManager.h" //JKC: Included for PUSH_XXX definitions.
#include "widgets/NumericTextCtrl.h"
#include "SelectedRegion.h"
#include "WaveTrackLocation.h"
#include "Snap.h"
@ -457,8 +457,9 @@ protected:
virtual void MakeParentRedrawScrollbars();
// 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,
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
// 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 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
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
virtual void TP_RedrawScrollbars() = 0;

View File

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