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