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 "engravingitem.h"
26 :
27 : #include "accidental.h"
28 : #include "durationtype.h"
29 : #include "../types/types.h"
30 :
31 : namespace mu::engraving {
32 : //---------------------------------------------------------
33 : // ShadowNote
34 : //---------------------------------------------------------
35 :
36 : /**
37 : Graphic representation of a shadow note,
38 : which shows the note insert position in note entry mode.
39 : */
40 :
41 : class ShadowNote final : public EngravingItem
42 : {
43 4429 : OBJECT_ALLOCATOR(engraving, ShadowNote)
44 : DECLARE_CLASSOF(ElementType::SHADOW_NOTE)
45 :
46 : public:
47 : ShadowNote(Score*);
48 :
49 0 : ShadowNote* clone() const override { return new ShadowNote(*this); }
50 :
51 : bool isValid() const;
52 :
53 0 : Fraction tick() const override { return m_tick; }
54 0 : void setTick(Fraction t) { m_tick = t; }
55 :
56 0 : int lineIndex() const { return m_lineIndex; }
57 0 : void setLineIndex(int n) { m_lineIndex = n; }
58 :
59 0 : bool isRest() const { return m_isRest; }
60 :
61 0 : const TDuration& duration() const { return m_duration; }
62 :
63 : void setState(SymId noteSymbol, TDuration duration, bool isRest, bool beyondScore, AccidentalType accidentalType = AccidentalType::NONE,
64 : const std::set<SymId>& articulationIds = {});
65 :
66 : void drawArticulations(muse::draw::Painter* painter) const;
67 : void drawCloseArticulation(muse::draw::Painter* painter, const SymId& articulation, RectF& boundRect, bool up,
68 : const SymId& prevArticulation) const;
69 : void drawFarArticulation(muse::draw::Painter* painter, const SymId& articulation, RectF& boundRect, bool up,
70 : bool accentStaccatoKern) const;
71 :
72 : bool computeUp() const;
73 0 : SymId noteheadSymbol() const { return m_noteheadSymbol; }
74 : bool hasStem() const;
75 : bool hasFlag() const;
76 : SymId flagSym() const;
77 : AccidentalType accidentalType() const;
78 : const std::set<SymId>& articulationIds() const;
79 :
80 : bool ledgerLinesVisible() const;
81 :
82 0 : bool isBeyondScore() const { return m_beyondScore; }
83 :
84 : private:
85 :
86 : Fraction m_tick;
87 : int m_lineIndex = -1;
88 : SymId m_noteheadSymbol = SymId::noSym;
89 : TDuration m_duration;
90 : bool m_isRest = false;
91 : AccidentalType m_accidentalType = AccidentalType::NONE;
92 : std::set<SymId> m_articulationIds;
93 : bool m_beyondScore = false;
94 : };
95 : } // namespace mu::engraving
|