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 "draw/types/font.h"
26 :
27 : #include "engravingitem.h"
28 : #include "../types/types.h"
29 :
30 : namespace mu::engraving {
31 : class Note;
32 : class Factory;
33 :
34 : //---------------------------------------------------------
35 : // @@ Bend
36 : //---------------------------------------------------------
37 :
38 : /**********************************************************
39 : * OBSOLETE CLASS
40 : * Used to represent bends before version 4.2. Now
41 : * replaced by the GuitarBend class.
42 : *********************************************************/
43 :
44 : enum class BendType : unsigned char {
45 : BEND = 0,
46 : BEND_RELEASE,
47 : BEND_RELEASE_BEND,
48 : PREBEND,
49 : PREBEND_RELEASE,
50 : CUSTOM
51 : };
52 :
53 : class Bend final : public EngravingItem
54 : {
55 8 : OBJECT_ALLOCATOR(engraving, Bend)
56 2389 : DECLARE_CLASSOF(ElementType::BEND)
57 :
58 : public:
59 0 : Bend* clone() const override { return new Bend(*this); }
60 : void setOwnershipParent(DummyParentOr<Note> parent) { EngravingItem::setOwnershipParent(parent); }
61 :
62 12 : Note* note() const { return toNote(ownershipParent()); }
63 :
64 : static const char* label[13];
65 :
66 0 : PitchValues& points() { return m_points; }
67 32 : const PitchValues& points() const { return m_points; }
68 12 : void addPoint(const PitchValue& pv) { m_points.push_back(pv); }
69 0 : void setPoints(const PitchValues& p) { m_points = p; }
70 4 : bool playBend() const { return m_playBend; }
71 1 : void setPlayBend(bool v) { m_playBend = v; }
72 :
73 : String fontFace() const { return m_fontFace; }
74 : void setFontFace(String f) { m_fontFace = f; }
75 : double fontSize() const { return m_fontSize; }
76 : void setFontSize(double s) { m_fontSize = s; }
77 : FontStyle fontStyle() const { return m_fontStyle; }
78 : void setFontStyle(FontStyle s) { m_fontStyle = s; }
79 4 : Spatium lineWidth() const { return m_lineWidth; }
80 : void setLineWidth(Spatium w) { m_lineWidth = w; }
81 :
82 : muse::draw::Font font(double) const;
83 :
84 : // property methods
85 : PropertyValue getProperty(Pid propertyId) const override;
86 : bool setProperty(Pid propertyId, const PropertyValue&) override;
87 : PropertyValue propertyDefault(Pid) const override;
88 :
89 : struct LayoutData : public EngravingItem::LayoutData {
90 : // cache
91 : PointF notePos;
92 : double noteWidth = 0.0;
93 : double noteHeight = 0.0;
94 : };
95 4 : DECLARE_LAYOUTDATA_METHODS(Bend)
96 :
97 : private:
98 : friend class Factory;
99 :
100 : Bend(DummyParentOr<Note> parent);
101 :
102 : BendType parseBendTypeFromCurve() const;
103 : void updatePointsByBendType(const BendType bendType);
104 :
105 : bool m_playBend = true;
106 : PitchValues m_points;
107 :
108 : String m_fontFace;
109 : double m_fontSize = 0.0;
110 : FontStyle m_fontStyle = FontStyle::Undefined;
111 : Spatium m_lineWidth;
112 : };
113 : }
|