44#ifndef __AUDACITY_UNDOMANAGER__
45#define __AUDACITY_UNDOMANAGER__
108 using Extensions = std::vector<std::shared_ptr<UndoStateExtension>>;
133using UndoStack = std::vector <std::unique_ptr<UndoStackElem>>;
145{
return static_cast<UndoPush>(
static_cast<int>(a) |
static_cast<int>(b)); }
147{
return static_cast<UndoPush>(
static_cast<int>(a) &
static_cast<int>(b)); }
154 ,
public std::enable_shared_from_this<UndoManager>
171 void RenameState(
int state,
180 unsigned int GetNumStates();
181 unsigned int GetCurrentState();
192 void SetStateTo(
unsigned int n,
const Consumer &consumer);
193 void Undo(
const Consumer &consumer);
194 void Redo(
const Consumer &consumer);
197 void VisitStates(
const Consumer &consumer,
bool newestFirst );
203 bool UndoAvailable();
204 bool RedoAvailable();
207 bool UnsavedChanges()
const;
208 int GetSavedState()
const;
214 bool CheckAvailable(
int index);
217 void RemoveStateAt(
int n);
227 bool mayConsolidate {
false };
Utility ClientData::Site to register hooks into a host class that attach client data.
UndoPush operator&(UndoPush a, UndoPush b)
UndoPush operator|(UndoPush a, UndoPush b)
std::vector< std::unique_ptr< UndoStackElem > > UndoStack
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
An object that sends messages to an open-ended list of subscribed callbacks.
Holds a msgid for the translation catalog; may also bind format arguments.
Maintain a non-persistent list of states of the project, to support undo and redo commands.
AudacityProject & mProject
UndoManager(const UndoManager &)=delete
TranslatableString lastAction
std::function< void(const UndoStackElem &) > Consumer
std::function< std::shared_ptr< UndoStateExtension >(AudacityProject &)> Saver
Type of function that produces an UndoStateExtension object when saving state of a project.
Base class for extra information attached to undo/redo states.
virtual void RestoreUndoRedoState(AudacityProject &project)=0
Modify the project when undoing or redoing to some state in history.
virtual ~UndoStateExtension()
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
const TranslatableString desc
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
A convenient default parameter for class template Site.
Typically statically constructed.
Type of message published by UndoManager.
const size_t begin
Only significant for BeginPurge messages.
@ EndPurge
End elimination of old undo states.
@ Purge
Undo or redo states eliminated.
@ BeginPurge
Begin elimination of old undo states.
enum UndoRedoMessage::Type type
Holds one item with description and time range for the UndoManager.
UndoStackElem(UndoState::Extensions extensions, const TranslatableString &description_, const TranslatableString &shortDescription_)
TranslatableString description
TranslatableString shortDescription
std::vector< std::shared_ptr< UndoStateExtension > > Extensions
UndoState(Extensions extensions)