49#ifndef __AUDACITY_UNDOMANAGER__
50#define __AUDACITY_UNDOMANAGER__
113 using Extensions = std::vector<std::shared_ptr<UndoStateExtension>>;
116 std::shared_ptr<TrackList> &&tracks_,
130 std::shared_ptr<TrackList> &&tracks_,
134 :
state(
std::move(extensions),
std::move(tracks_), selectedRegion_)
145using UndoStack = std::vector <std::unique_ptr<UndoStackElem>>;
157{
return static_cast<UndoPush>(
static_cast<int>(a) |
static_cast<int>(b)); }
159{
return static_cast<UndoPush>(
static_cast<int>(a) &
static_cast<int>(b)); }
166 ,
public std::enable_shared_from_this<UndoManager>
186 void RenameState(
int state,
195 unsigned int GetNumStates();
196 unsigned int GetCurrentState();
207 void SetStateTo(
unsigned int n,
const Consumer &consumer);
208 void Undo(
const Consumer &consumer);
209 void Redo(
const Consumer &consumer);
212 void VisitStates(
const Consumer &consumer,
bool newestFirst );
218 bool UndoAvailable();
219 bool RedoAvailable();
222 bool UnsavedChanges()
const;
223 int GetSavedState()
const;
230 void RemoveStateAt(
int n);
241 bool mayConsolidate {
false };
Utility ClientData::Site to register hooks into a host class that attach client data.
const TranslatableString desc
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.
Defines a selected portion of a project.
Abstract base class for an object holding data associated with points on a time axis.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
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 &)=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.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
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.
TranslatableString description
TranslatableString shortDescription
UndoStackElem(UndoState::Extensions extensions, std::shared_ptr< TrackList > &&tracks_, const TranslatableString &description_, const TranslatableString &shortDescription_, const SelectedRegion &selectedRegion_)
std::vector< std::shared_ptr< UndoStateExtension > > Extensions
std::shared_ptr< TrackList > tracks
UndoState(Extensions extensions, std::shared_ptr< TrackList > &&tracks_, const SelectedRegion &selectedRegion_)
SelectedRegion selectedRegion