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 "textbase.h"
26 :
27 : namespace mu::engraving {
28 : //---------------------------------------------------------
29 : // @@ Marker
30 : //
31 : // @P label string
32 : // @P markerType enum (Marker.CODA, .CODETTA, .FINE, .SEGNO, .TOCODA, .USER, .VARCODA, .VARSEGNO)
33 : //---------------------------------------------------------
34 :
35 : class Marker final : public TextBase
36 : {
37 445 : OBJECT_ALLOCATOR(engraving, Marker)
38 1525 : DECLARE_CLASSOF(ElementType::MARKER)
39 :
40 : public:
41 : Marker(DummyParentOr<EngravingItem> parent);
42 : Marker(DummyParentOr<EngravingItem> parent, TextStyleType);
43 :
44 : void setMarkerType(MarkerType t);
45 172 : MarkerType markerType() const { return m_markerType; }
46 : String markerTypeUserName() const;
47 :
48 2 : inline bool isSegno() const { return m_markerType == MarkerType::SEGNO || m_markerType == MarkerType::VARSEGNO; }
49 : inline bool isCoda() const
50 : {
51 : return m_markerType == MarkerType::CODA || m_markerType == MarkerType::VARCODA || m_markerType == MarkerType::CODETTA;
52 : }
53 :
54 : inline bool isToCoda() const
55 : {
56 : return m_markerType == MarkerType::TOCODA || m_markerType == MarkerType::TOCODASYM || m_markerType == MarkerType::DA_CODA
57 : || m_markerType == MarkerType::DA_DBLCODA;
58 : }
59 :
60 847 : inline bool isRightMarker() const { return muse::contains(Marker::RIGHT_MARKERS, m_markerType); }
61 :
62 0 : Marker* clone() const override { return new Marker(*this); }
63 :
64 0 : int subtype() const override { return int(m_markerType); }
65 : TranslatableString subtypeUserName() const override;
66 :
67 652 : Measure* measure() const { return (Measure*)ownershipParent(); }
68 :
69 994 : String label() const { return m_label; }
70 316 : void setLabel(const String& s) { m_label = s; }
71 :
72 : PropertyValue getProperty(Pid propertyId) const override;
73 : bool setProperty(Pid propertyId, const PropertyValue&) override;
74 : PropertyValue propertyDefault(Pid) const override;
75 :
76 : EngravingItem* nextSegmentElement() override;
77 : EngravingItem* prevSegmentElement() override;
78 : String accessibleInfo() const override;
79 :
80 343 : bool positionRelativeToNoteheadRest() const override { return false; }
81 :
82 727 : bool centerOnSymbol() const { return m_centerOnSymbol; }
83 0 : void setCenterOnSymbol(bool val) { m_centerOnSymbol = val; }
84 :
85 : std::vector<LineF> dragAnchorLines() const override;
86 :
87 : static constexpr std::array<MarkerType, 5> RIGHT_MARKERS {
88 : MarkerType::FINE,
89 : MarkerType::TOCODA,
90 : MarkerType::TOCODASYM,
91 : MarkerType::DA_CODA,
92 : MarkerType::DA_DBLCODA,
93 : };
94 :
95 : String symbolString() const;
96 :
97 : private:
98 : MarkerType m_markerType = MarkerType::FINE;
99 : String m_label = u"fine"; ///< referenced from Jump() element
100 :
101 : bool m_centerOnSymbol = true;
102 : };
103 :
104 : struct MarkerTypeTableItem {
105 : MarkerType type;
106 : AsciiStringView text;
107 : AsciiStringView label;
108 : bool rightAligned;
109 : };
110 :
111 : extern const std::vector<MarkerTypeTableItem> markerTypeTable;
112 : } // namespace mu::engraving
|