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 2376 : DECLARE_CLASSOF(ElementType::BEND)
57 :
58 : public:
59 0 : Bend* clone() const override { return new Bend(*this); }
60 :
61 12 : Note* note() const { return toNote(ownershipParent()); }
62 :
63 : static const char* label[13];
64 :
65 0 : PitchValues& points() { return m_points; }
66 32 : const PitchValues& points() const { return m_points; }
67 12 : void addPoint(const PitchValue& pv) { m_points.push_back(pv); }
68 0 : void setPoints(const PitchValues& p) { m_points = p; }
69 4 : bool playBend() const { return m_playBend; }
70 1 : void setPlayBend(bool v) { m_playBend = v; }
71 :
72 : String fontFace() const { return m_fontFace; }
73 : void setFontFace(String f) { m_fontFace = f; }
74 : double fontSize() const { return m_fontSize; }
75 : void setFontSize(double s) { m_fontSize = s; }
76 : FontStyle fontStyle() const { return m_fontStyle; }
77 : void setFontStyle(FontStyle s) { m_fontStyle = s; }
78 4 : Spatium lineWidth() const { return m_lineWidth; }
79 : void setLineWidth(Spatium w) { m_lineWidth = w; }
80 :
81 : muse::draw::Font font(double) const;
82 :
83 : // property methods
84 : PropertyValue getProperty(Pid propertyId) const override;
85 : bool setProperty(Pid propertyId, const PropertyValue&) override;
86 : PropertyValue propertyDefault(Pid) const override;
87 :
88 : struct LayoutData : public EngravingItem::LayoutData {
89 : // cache
90 : PointF notePos;
91 : double noteWidth = 0.0;
92 : double noteHeight = 0.0;
93 : };
94 4 : DECLARE_LAYOUTDATA_METHODS(Bend)
95 :
96 : private:
97 : friend class Factory;
98 :
99 : Bend(DummyParentOr<Note> parent);
100 :
101 : BendType parseBendTypeFromCurve() const;
102 : void updatePointsByBendType(const BendType bendType);
103 :
104 : bool m_playBend = true;
105 : PitchValues m_points;
106 :
107 : String m_fontFace;
108 : double m_fontSize = 0.0;
109 : FontStyle m_fontStyle = FontStyle::Undefined;
110 : Spatium m_lineWidth;
111 : };
112 : }
|