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) 2025 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 "transaction/undoablecommand.h"
26 :
27 : #include "../dom/chord.h"
28 : #include "../dom/note.h"
29 :
30 : namespace mu::engraving {
31 : enum class SymId;
32 : enum class AccidentalType : unsigned char;
33 : enum class Key : signed char;
34 : class Score;
35 : class EngravingItem;
36 : class Articulation;
37 :
38 : enum class UpDownMode : char {
39 : CHROMATIC, OCTAVE, DIATONIC
40 : };
41 :
42 : class EditNote
43 : {
44 : public:
45 : static void toggleOrnament(Score* score, SymId attr);
46 : static void toggleAccidental(Score* score, AccidentalType at);
47 : static void applyAccidentalToInputNotes(Score* score, AccidentalType accidentalType);
48 : static void changeAccidental(Score* score, AccidentalType idx);
49 : static void changeAccidental(Score* score, Note* note, AccidentalType accidental);
50 : static void undoChangePitch(Score* score, Note* note, int pitch, int tpc1, int tpc2);
51 : static void undoChangeFretting(Score* score, Note* note, int pitch, int string, int fret, int tpc1, int tpc2);
52 : static void upDown(Score* score, bool up, UpDownMode mode);
53 : private:
54 : static void changeAccidental2(Note* n, int pitch, int tpc);
55 : static void upDownChromatic(bool up, int pitch, Note* n, Key key, int tpc1, int tpc2, int& newPitch, int& newTpc1, int& newTpc2);
56 : };
57 :
58 : class ChangeVelocity : public UndoableCommand
59 : {
60 0 : OBJECT_ALLOCATOR(engraving, ChangeVelocity)
61 :
62 : Note* note = nullptr;
63 : int userVelocity = 0;
64 :
65 : void flip() override;
66 :
67 : public:
68 : ChangeVelocity(Note*, int);
69 :
70 0 : UNDO_TYPE(CommandType::ChangeVelocity)
71 0 : UNDO_NAME("ChangeVelocity")
72 0 : UNDO_CHANGED_OBJECTS({ note })
73 : };
74 :
75 : class ChangeNoteEventList : public UndoableCommand
76 : {
77 0 : OBJECT_ALLOCATOR(engraving, ChangeNoteEventList)
78 :
79 : Note* note = nullptr;
80 : NoteEventList newEvents;
81 : PlayEventType newPetype;
82 :
83 : void flip() override;
84 :
85 : public:
86 0 : ChangeNoteEventList(Note* n, NoteEventList& ne)
87 0 : : note(n), newEvents(ne), newPetype(PlayEventType::User) {}
88 0 : UNDO_NAME("ChangeNoteEventList")
89 0 : UNDO_CHANGED_OBJECTS({ note });
90 : };
91 :
92 : class ChangeNoteEvent : public UndoableCommand
93 : {
94 0 : OBJECT_ALLOCATOR(engraving, ChangeNoteEvent)
95 :
96 : Note* note = nullptr;
97 : NoteEvent* oldEvent = nullptr;
98 : NoteEvent newEvent;
99 : PlayEventType newPetype;
100 :
101 : void flip() override;
102 :
103 : public:
104 0 : ChangeNoteEvent(Note* n, NoteEvent* oe, const NoteEvent& ne)
105 0 : : note(n), oldEvent(oe), newEvent(ne), newPetype(PlayEventType::User) {}
106 0 : UNDO_NAME("ChangeNoteEvent")
107 0 : UNDO_CHANGED_OBJECTS({ note })
108 : };
109 :
110 : class ChangeChordPlayEventType : public UndoableCommand
111 : {
112 0 : OBJECT_ALLOCATOR(engraving, ChangeChordPlayEventType)
113 :
114 : Chord* chord = nullptr;
115 : PlayEventType petype;
116 : std::vector<NoteEventList> events;
117 :
118 : void flip() override;
119 :
120 : public:
121 0 : ChangeChordPlayEventType(Chord* c, PlayEventType pet)
122 0 : : chord(c), petype(pet)
123 : {
124 0 : events = c->getNoteEventLists();
125 0 : }
126 :
127 0 : UNDO_NAME("ChangeChordPlayEventType")
128 0 : UNDO_CHANGED_OBJECTS({ chord });
129 : };
130 : }
|