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_VOLTA_H
24 : #define MU_ENGRAVING_VOLTA_H
25 :
26 : #include "textlinebase.h"
27 :
28 : namespace mu::engraving {
29 : class Score;
30 :
31 : class Volta;
32 : class Measure;
33 :
34 : //---------------------------------------------------------
35 : // @@ VoltaSegment
36 : //---------------------------------------------------------
37 :
38 : class VoltaSegment final : public TextLineBaseSegment
39 : {
40 626 : OBJECT_ALLOCATOR(engraving, VoltaSegment)
41 : DECLARE_CLASSOF(ElementType::VOLTA_SEGMENT)
42 :
43 : public:
44 : VoltaSegment(Volta*);
45 :
46 103 : VoltaSegment* clone() const override { return new VoltaSegment(*this); }
47 :
48 335 : Volta* volta() const { return (Volta*)spanner(); }
49 :
50 : PropertyDelegate resolvePropertyDelegate(Pid) const override;
51 : };
52 :
53 : //---------------------------------------------------------
54 : // @@ Volta
55 : // @P voltaType enum (Volta.CLOSE, Volta.OPEN)
56 : //---------------------------------------------------------
57 :
58 : class Volta final : public TextLineBase
59 : {
60 999 : OBJECT_ALLOCATOR(engraving, Volta)
61 1549 : DECLARE_CLASSOF(ElementType::VOLTA)
62 :
63 : public:
64 : enum class Type : char {
65 : OPEN, CLOSED
66 : };
67 :
68 : Volta(DummyParent* parent);
69 :
70 297 : Volta* clone() const override { return new Volta(*this); }
71 : void setOwnershipParent(EngravingObject*) = delete;
72 :
73 3706 : Anchor anchor() const override { return Anchor::MEASURE; }
74 :
75 : LineSegment* createLineSegment() override;
76 :
77 0 : bool allowTimeAnchor() const override { return false; }
78 :
79 : void setChannel() const;
80 :
81 647 : std::vector<int> endings() const { return m_endings; }
82 135 : std::vector<int>& endings() { return m_endings; }
83 : void setEndings(const std::vector<int>& l);
84 : void setText(const String& s);
85 : String text() const;
86 :
87 : bool hasEnding(int repeat) const;
88 : int firstEnding() const;
89 : int lastEnding() const;
90 : void setVoltaType(Volta::Type); // deprecated
91 : Type voltaType() const; // deprecated
92 :
93 : bool isFirstVolta() const { return m_endings.size() == 1 && hasEnding(1); }
94 :
95 : PropertyValue getProperty(Pid propertyId) const override;
96 : bool setProperty(Pid propertyId, const PropertyValue&) override;
97 : PropertyValue propertyDefault(Pid) const override;
98 :
99 : String accessibleInfo() const override;
100 :
101 : PointF linePos(Grip grip, System** system) const override;
102 :
103 : protected:
104 : Sid defaultPosSid() const override;
105 :
106 : private:
107 : std::vector<int> m_endings;
108 : };
109 : } // namespace mu::engraving
110 :
111 : #ifndef NO_QT_SUPPORT
112 18 : Q_DECLARE_METATYPE(mu::engraving::Volta::Type)
113 : #endif
114 :
115 : #endif
|