#pragma once #include "datatypes/signal.h" #include "datatypes/variant.h" #include "objects/base/instance.h" #include "utils.h" #include #include #include struct UndoStatePropertyChanged { std::shared_ptr affectedInstance; std::string property; Variant oldValue; Variant newValue; }; struct UndoStateInstanceCreated { std::shared_ptr instance; std::shared_ptr newParent; }; struct UndoStateInstanceRemoved { std::shared_ptr instance; std::shared_ptr oldParent; }; struct UndoStateInstanceReparented { std::shared_ptr instance; nullable std::shared_ptr oldParent; nullable std::shared_ptr newParent; }; struct UndoStateSelectionChanged { std::vector> oldSelection; std::vector> newSelection; }; typedef std::variant UndoStateChange; typedef std::vector UndoState; class UndoHistory { // Ignore PushState requests bool processingUndo = false; std::deque undoHistory; std::stack redoHistory; public: int maxBufferSize = 100; void PushState(UndoState); void Undo(); void Redo(); };