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_TREMOLOBAR_H
24 : #define MU_ENGRAVING_TREMOLOBAR_H
25 :
26 : #include "engravingitem.h"
27 :
28 : namespace mu::engraving {
29 : //---------------------------------------------------------
30 : // @@ TremoloBar
31 : //
32 : // @P userMag double
33 : // @P lineWidth double
34 : // @P play bool play tremolo bar
35 : //---------------------------------------------------------
36 :
37 : enum class TremoloBarType : unsigned char {
38 : DIP = 0,
39 : DIVE,
40 : RELEASE_UP,
41 : INVERTED_DIP,
42 : RETURN,
43 : RELEASE_DOWN,
44 : CUSTOM
45 : };
46 :
47 : class TremoloBar final : public EngravingItem
48 : {
49 58 : OBJECT_ALLOCATOR(engraving, TremoloBar)
50 138 : DECLARE_CLASSOF(ElementType::TREMOLOBAR)
51 :
52 : public:
53 :
54 0 : TremoloBar* clone() const override { return new TremoloBar(*this); }
55 :
56 85 : PitchValues& points() { return m_points; }
57 49 : const PitchValues& points() const { return m_points; }
58 0 : void setPoints(const PitchValues& p) { m_points = p; }
59 :
60 : PropertyValue getProperty(Pid propertyId) const override;
61 : bool setProperty(Pid propertyId, const PropertyValue&) override;
62 : PropertyValue propertyDefault(Pid) const override;
63 :
64 42 : double userMag() const { return m_userMag; }
65 1 : void setUserMag(double m) { m_userMag = m; }
66 :
67 31 : void setLineWidth(Spatium v) { m_lw = v; }
68 38 : Spatium lineWidth() const { return m_lw; }
69 :
70 4 : bool play() const { return m_play; }
71 0 : void setPlay(bool val) { m_play = val; }
72 :
73 : struct LayoutData : public EngravingItem::LayoutData {
74 : PolygonF polygon;
75 : };
76 30 : DECLARE_LAYOUTDATA_METHODS(TremoloBar)
77 :
78 : private:
79 :
80 : friend class Factory;
81 : TremoloBar(DummyParentOr<EngravingItem> parent);
82 :
83 : TremoloBarType parseTremoloBarTypeFromCurve(const PitchValues& curve) const;
84 : void updatePointsByTremoloBarType(const TremoloBarType type);
85 :
86 : Spatium m_lw;
87 : double m_userMag = 1.0; // allowed 0.1 - 10.0
88 : bool m_play = true;
89 :
90 : PitchValues m_points;
91 : };
92 : } // namespace mu::engraving
93 : #endif
|