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 : #pragma once
23 :
24 : #include "articulation.h"
25 :
26 : namespace mu::engraving {
27 : class AccidentalState;
28 :
29 : class Ornament final : public Articulation
30 : {
31 554 : OBJECT_ALLOCATOR(engraving, Ornament)
32 1350 : DECLARE_CLASSOF(ElementType::ORNAMENT)
33 :
34 : public:
35 : Ornament(DummyParentOr<ChordRest> parent);
36 4 : Ornament* clone() const override { return new Ornament(*this); }
37 : Ornament(const Ornament& o);
38 : ~Ornament();
39 :
40 : TranslatableString typeUserName() const override;
41 :
42 : static SymId fromTrillType(TrillType trillType);
43 :
44 : PropertyValue getProperty(Pid propertyId) const override;
45 : Sid getPropertyStyle(Pid propertyId) const override;
46 : PropertyValue propertyDefault(Pid id) const override;
47 : bool setProperty(Pid propertyId, const PropertyValue& v) override;
48 :
49 : bool hasIntervalAbove() const;
50 : bool hasIntervalBelow() const;
51 : bool hasFullIntervalChoice() const;
52 : bool showCueNote();
53 :
54 : void computeNotesAboveAndBelow(AccidentalState* accState);
55 :
56 : void scanElements(std::function<void(EngravingItem*)> func) override;
57 :
58 : void remove(EngravingItem* e) override;
59 :
60 2045 : Chord* cueNoteChord() const { return m_cueNoteChord; }
61 9 : void setCueNoteChord(Chord* c) { m_cueNoteChord = c; }
62 9 : void setNoteAbove(Note* n) { m_notesAboveAndBelow[0] = n; }
63 :
64 4559 : const auto& accidentalsAboveAndBelow() const { return m_accidentalsAboveAndBelow; }
65 310 : Accidental* accidentalAbove() const { return m_accidentalsAboveAndBelow[0]; }
66 191 : Accidental* accidentalBelow() const { return m_accidentalsAboveAndBelow[1]; }
67 17 : void setAccidentalAbove(Accidental* a) { m_accidentalsAboveAndBelow[0] = a; }
68 10 : void setAccidentalBelow(Accidental* a) { m_accidentalsAboveAndBelow[1] = a; }
69 :
70 0 : void setTrillOldCompatAccidental(Accidental* a) { m_trillOldCompatAccidental = a; }
71 :
72 740 : Note* noteAbove() const { return m_notesAboveAndBelow[0]; }
73 : Note* noteBelow() const { return m_notesAboveAndBelow[1]; }
74 :
75 : void setTrack(track_idx_t val) override;
76 :
77 0 : void setShowCueNote(AutoOnOff show) { m_showCueNote = show; }
78 :
79 : private:
80 : void updateAccidentalsAboveAndBelow();
81 : void updateCueNote();
82 : void mapOldTrillAccidental(Note* note, const Note* mainNote);
83 : void manageAccidentalVisibilityRules(Note* note);
84 :
85 : private:
86 75 : M_PROPERTY(OrnamentInterval, intervalAbove, setIntervalAbove)
87 41 : M_PROPERTY(OrnamentInterval, intervalBelow, setIntervalBelow)
88 6 : M_PROPERTY(OrnamentShowAccidental, showAccidental, setShowAccidental)
89 0 : M_PROPERTY(bool, startOnUpperNote, setStartOnUpperNote)
90 :
91 : std::array<Note*, 2> m_notesAboveAndBelow { nullptr, nullptr }; // [0] = above, [1] = below
92 :
93 : std::array<Accidental*, 2> m_accidentalsAboveAndBelow { nullptr, nullptr }; // [0] = above, [1] = below
94 :
95 : Chord* m_cueNoteChord = nullptr;
96 : AutoOnOff m_showCueNote = AutoOnOff::AUTO;
97 :
98 : Accidental* m_trillOldCompatAccidental = nullptr; // used temporarily to map old (i.e. pre-4.1) trill accidentals
99 : };
100 : }
|