1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-02 17:09:26 +02:00

Distinguish another undo event type

This commit is contained in:
Paul Licameli 2019-06-08 10:59:42 -04:00
parent 06c9896498
commit e17fc86c23
4 changed files with 12 additions and 4 deletions

View File

@ -161,6 +161,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
EVT_CLIPBOARD_CHANGE, &HistoryWindow::UpdateDisplay, this); EVT_CLIPBOARD_CHANGE, &HistoryWindow::UpdateDisplay, this);
parent->Bind(EVT_UNDO_PUSHED, &HistoryWindow::UpdateDisplay, this); parent->Bind(EVT_UNDO_PUSHED, &HistoryWindow::UpdateDisplay, this);
parent->Bind(EVT_UNDO_MODIFIED, &HistoryWindow::UpdateDisplay, this); parent->Bind(EVT_UNDO_MODIFIED, &HistoryWindow::UpdateDisplay, this);
parent->Bind(EVT_UNDO_OR_REDO, &HistoryWindow::UpdateDisplay, this);
parent->Bind(EVT_UNDO_RESET, &HistoryWindow::UpdateDisplay, this); parent->Bind(EVT_UNDO_RESET, &HistoryWindow::UpdateDisplay, this);
} }

View File

@ -122,6 +122,7 @@ LyricsPanel::LyricsPanel(wxWindow* parent, wxWindowID id,
project->Bind(EVT_UNDO_PUSHED, &LyricsPanel::UpdateLyrics, this); project->Bind(EVT_UNDO_PUSHED, &LyricsPanel::UpdateLyrics, this);
project->Bind(EVT_UNDO_MODIFIED, &LyricsPanel::UpdateLyrics, this); project->Bind(EVT_UNDO_MODIFIED, &LyricsPanel::UpdateLyrics, this);
project->Bind(EVT_UNDO_OR_REDO, &LyricsPanel::UpdateLyrics, this);
project->Bind(EVT_UNDO_RESET, &LyricsPanel::UpdateLyrics, this); project->Bind(EVT_UNDO_RESET, &LyricsPanel::UpdateLyrics, this);
wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, &LyricsPanel::OnStartStop, this); wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK, &LyricsPanel::OnStartStop, this);

View File

@ -41,6 +41,7 @@ UndoManager
wxDEFINE_EVENT(EVT_UNDO_PUSHED, wxCommandEvent); wxDEFINE_EVENT(EVT_UNDO_PUSHED, wxCommandEvent);
wxDEFINE_EVENT(EVT_UNDO_MODIFIED, wxCommandEvent); wxDEFINE_EVENT(EVT_UNDO_MODIFIED, wxCommandEvent);
wxDEFINE_EVENT(EVT_UNDO_OR_REDO, wxCommandEvent);
wxDEFINE_EVENT(EVT_UNDO_RESET, wxCommandEvent); wxDEFINE_EVENT(EVT_UNDO_RESET, wxCommandEvent);
using ConstBlockFilePtr = const BlockFile*; using ConstBlockFilePtr = const BlockFile*;
@ -356,7 +357,7 @@ void UndoManager::Undo(const Consumer &consumer)
consumer( stack[current]->state ); consumer( stack[current]->state );
// wxWidgets will own the event object // wxWidgets will own the event object
mProject.QueueEvent( safenew wxCommandEvent{ EVT_UNDO_RESET } ); mProject.QueueEvent( safenew wxCommandEvent{ EVT_UNDO_OR_REDO } );
} }
void UndoManager::Redo(const Consumer &consumer) void UndoManager::Redo(const Consumer &consumer)
@ -384,7 +385,7 @@ void UndoManager::Redo(const Consumer &consumer)
consumer( stack[current]->state ); consumer( stack[current]->state );
// wxWidgets will own the event object // wxWidgets will own the event object
mProject.QueueEvent( safenew wxCommandEvent{ EVT_UNDO_RESET } ); mProject.QueueEvent( safenew wxCommandEvent{ EVT_UNDO_OR_REDO } );
} }
bool UndoManager::UnsavedChanges() bool UndoManager::UnsavedChanges()

View File

@ -64,7 +64,11 @@ wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_PUSHED, wxCommandEvent);
// Project state did not change, but current state was modified in Undo history // Project state did not change, but current state was modified in Undo history
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_MODIFIED, wxCommandEvent); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_MODIFIED, wxCommandEvent);
// Project state changed because of undo or redo or rollback; undo manager // Project state changed because of undo or redo; undo manager
// contents did not change other than the pointer to current state
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_OR_REDO, wxCommandEvent);
// Project state for changed other than single-step undo/redo; undo manager
// contents did not change other than the pointer to current state // contents did not change other than the pointer to current state
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_RESET, wxCommandEvent); wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_UNDO_RESET, wxCommandEvent);
@ -138,7 +142,8 @@ class AUDACITY_DLL_API UndoManager
void SetLongDescription(unsigned int n, const wxString &desc); void SetLongDescription(unsigned int n, const wxString &desc);
// These functions accept a callback that uses the state, // These functions accept a callback that uses the state,
// and then they send to the project EVT_UNDO_RESET when that has finished. // and then they send to the project EVT_UNDO_RESET or EVT_UNDO_OR_REDO when
// that has finished.
using Consumer = std::function< void( const UndoState & ) >; using Consumer = std::function< void( const UndoState & ) >;
void SetStateTo(unsigned int n, const Consumer &consumer); void SetStateTo(unsigned int n, const Consumer &consumer);
void Undo(const Consumer &consumer); void Undo(const Consumer &consumer);