1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Define UndoManager::VisitStates

This commit is contained in:
Paul Licameli
2019-07-18 13:17:10 -04:00
parent d49a888b98
commit 490271f259
4 changed files with 62 additions and 29 deletions

View File

@@ -76,7 +76,6 @@ class Tags;
class Track;
class TrackList;
struct UndoStackElem;
struct UndoState {
UndoState(std::shared_ptr<TrackList> &&tracks_,
const std::shared_ptr<Tags> &tags_,
@@ -89,6 +88,24 @@ struct UndoState {
SelectedRegion selectedRegion; // by value
};
struct UndoStackElem {
UndoStackElem(std::shared_ptr<TrackList> &&tracks_,
const TranslatableString &description_,
const TranslatableString &shortDescription_,
const SelectedRegion &selectedRegion_,
const std::shared_ptr<Tags> &tags_)
: state(std::move(tracks_), tags_, selectedRegion_)
, description(description_)
, shortDescription(shortDescription_)
{
}
UndoState state;
TranslatableString description;
TranslatableString shortDescription;
};
using UndoStack = std::vector <std::unique_ptr<UndoStackElem>>;
using SpaceArray = std::vector <unsigned long long> ;
@@ -150,11 +167,18 @@ class AUDACITY_DLL_API UndoManager final
// These functions accept a callback that uses the state,
// 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 UndoStackElem & ) >;
void SetStateTo(unsigned int n, const Consumer &consumer);
void Undo(const Consumer &consumer);
void Redo(const Consumer &consumer);
//! Give read-only access to all states
void VisitStates( const Consumer &consumer, bool newestFirst );
//! Visit a specified range of states
/*! end is exclusive; visit newer states first if end < begin */
void VisitStates(
const Consumer &consumer, size_t begin, size_t end );
bool UndoAvailable();
bool RedoAvailable();