Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include "async/notification.h"
26 : #include "async/channel.h"
27 :
28 : #include "types/translatablestring.h"
29 :
30 : namespace mu::engraving {
31 : class EditData;
32 : class Transaction;
33 : struct ScoreChanges;
34 : enum class ElementType : unsigned char;
35 : }
36 :
37 : namespace mu::notation {
38 : class INotationUndoStack
39 : {
40 : public:
41 0 : virtual ~INotationUndoStack() = default;
42 :
43 : virtual bool canUndo() const = 0;
44 : virtual void undo(mu::engraving::EditData*) = 0;
45 :
46 : virtual bool canRedo() const = 0;
47 : virtual void redo(mu::engraving::EditData*) = 0;
48 :
49 : virtual void undoRedoToIndex(size_t, mu::engraving::EditData*) = 0;
50 :
51 : virtual void transaction(const muse::TranslatableString& actionName, std::function<void(mu::engraving::Transaction&)> func) = 0;
52 :
53 : virtual void prepareChanges(const muse::TranslatableString&) = 0;
54 : virtual void rollbackChanges() = 0;
55 : virtual void commitChanges() = 0;
56 :
57 : virtual void mergeTransactions(const size_t startIdx) = 0;
58 :
59 : virtual bool isStackClean() const = 0;
60 :
61 : virtual void lock() = 0;
62 : virtual void unlock() = 0;
63 : virtual bool isLocked() const = 0;
64 :
65 : virtual const muse::TranslatableString topMostUndoActionName() const = 0;
66 : virtual const muse::TranslatableString topMostRedoActionName() const = 0;
67 : virtual size_t undoRedoActionCount() const = 0;
68 : virtual size_t currentStateIndex() const = 0;
69 : virtual const muse::TranslatableString lastActionNameAtIdx(size_t) const = 0;
70 :
71 : virtual muse::async::Notification stackChanged() const = 0;
72 : virtual muse::async::Channel<engraving::ScoreChanges> changesChannel() const = 0;
73 : virtual muse::async::Notification undoRedoNotification() const = 0;
74 : };
75 :
76 : using INotationUndoStackPtr = std::shared_ptr<INotationUndoStack>;
77 : }
|