/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace GUI { class UndoStack { public: UndoStack(); ~UndoStack(); void push(NonnullOwnPtr); bool can_undo() const; bool can_redo() const; void undo(); void redo(); void set_current_unmodified(); bool is_current_modified() const; void clear(); Optional undo_action_text() const; Optional redo_action_text() const; Function on_state_change; private: NonnullOwnPtrVector m_stack; size_t m_stack_index { 0 }; Optional m_clean_index; }; }