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 : #ifndef MU_ENGRAVING_BAGPEMBELL_H
24 : #define MU_ENGRAVING_BAGPEMBELL_H
25 :
26 : #include <vector>
27 :
28 : #include "engravingitem.h"
29 :
30 : namespace mu::engraving {
31 : using BagpipeNoteList = std::vector<int>;
32 :
33 : //---------------------------------------------------------
34 : // BagpipeEmbellishmentInfo
35 : // name and notes for a BagpipeEmbellishment
36 : //---------------------------------------------------------
37 :
38 : struct BagpipeEmbellishmentInfo {
39 : const char* name = 0;
40 : AsciiStringView notes;
41 : };
42 :
43 : //---------------------------------------------------------
44 : // BagpipeEmbellishmentInfo
45 : // name, staff line and pitch for a bagpipe note
46 : //---------------------------------------------------------
47 :
48 : struct BagpipeNoteInfo {
49 : AsciiStringView name;
50 : int line = 0;
51 : int pitch = 0;
52 : };
53 :
54 : //---------------------------------------------------------
55 : // BagpipeEmbellishment
56 : // dummy element, used for drag&drop
57 : //---------------------------------------------------------
58 :
59 : class BagpipeEmbellishment final : public EngravingItem
60 : {
61 0 : OBJECT_ALLOCATOR(engraving, BagpipeEmbellishment)
62 2376 : DECLARE_CLASSOF(ElementType::BAGPIPE_EMBELLISHMENT)
63 :
64 : public:
65 0 : BagpipeEmbellishment(DummyParentOr<EngravingItem> parent)
66 0 : : EngravingItem(ElementType::BAGPIPE_EMBELLISHMENT, parent), m_embelType(EmbellishmentType(0)) { }
67 :
68 0 : BagpipeEmbellishment* clone() const override { return new BagpipeEmbellishment(*this); }
69 :
70 0 : EmbellishmentType embelType() const { return m_embelType; }
71 0 : void setEmbelType(EmbellishmentType val) { m_embelType = val; }
72 : double mag() const override;
73 :
74 : static const BagpipeNoteInfo BAGPIPE_NOTEINFO_LIST[];
75 : BagpipeNoteList resolveNoteList() const;
76 :
77 : struct LayoutData : public EngravingItem::LayoutData {
78 : struct NoteData {
79 : PointF headXY;
80 : LineF stemLine;
81 : PointF flagXY;
82 : LineF ledgerLine;
83 : };
84 :
85 : struct BeamData {
86 : double width = 0.0; // line width for beam
87 : double y = 0.0;
88 : double x1 = 0.0;
89 : double x2 = 0.0;
90 : };
91 :
92 : bool isDrawBeam = false;
93 : bool isDrawFlag = false;
94 : double spatium = 1.0; // spatium
95 : SymId headsym = SymId::noSym; // grace note head symbol
96 : SymId flagsym = SymId::noSym; // grace note flag symbol
97 : double stemLineW = 0.0; // line width for stem
98 : std::map<size_t /*note index*/, NoteData> notesData;
99 : BeamData beamData;
100 : };
101 0 : DECLARE_LAYOUTDATA_METHODS(BagpipeEmbellishment)
102 :
103 : private:
104 :
105 : EmbellishmentType m_embelType;
106 : };
107 : } // namespace mu::engraving
108 :
109 : #endif
|