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 447 : OBJECT_ALLOCATOR(engraving, Marker)
38 1525 : DECLARE_CLASSOF(ElementType::MARKER)
39 :
40 : public:
41 : Marker(DummyParentOr<Measure> parent);
42 : Marker(DummyParentOr<Measure> 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 : void setOwnershipParent(DummyParentOr<Measure> parent) { EngravingItem::setOwnershipParent(parent); }
64 :
65 0 : int subtype() const override { return int(m_markerType); }
66 : TranslatableString subtypeUserName() const override;
67 :
68 652 : Measure* measure() const { return (Measure*)ownershipParent(); }
69 :
70 994 : String label() const { return m_label; }
71 316 : void setLabel(const String& s) { m_label = s; }
72 :
73 : PropertyValue getProperty(Pid propertyId) const override;
74 : bool setProperty(Pid propertyId, const PropertyValue&) override;
75 : PropertyValue propertyDefault(Pid) const override;
76 :
77 : EngravingItem* nextSegmentElement() override;
78 : EngravingItem* prevSegmentElement() override;
79 : String accessibleInfo() const override;
80 :
81 343 : bool positionRelativeToNoteheadRest() const override { return false; }
82 :
83 727 : bool centerOnSymbol() const { return m_centerOnSymbol; }
84 0 : void setCenterOnSymbol(bool val) { m_centerOnSymbol = val; }
85 :
86 : std::vector<LineF> dragAnchorLines() const override;
87 :
88 : static constexpr std::array<MarkerType, 5> RIGHT_MARKERS {
89 : MarkerType::FINE,
90 : MarkerType::TOCODA,
91 : MarkerType::TOCODASYM,
92 : MarkerType::DA_CODA,
93 : MarkerType::DA_DBLCODA,
94 : };
95 :
96 : String symbolString() const;
97 :
98 : private:
99 : MarkerType m_markerType = MarkerType::FINE;
100 : String m_label = u"fine"; ///< referenced from Jump() element
101 :
102 : bool m_centerOnSymbol = true;
103 : };
104 :
105 : struct MarkerTypeTableItem {
106 : MarkerType type;
107 : AsciiStringView text;
108 : AsciiStringView label;
109 : bool rightAligned;
110 : };
111 :
112 : extern const std::vector<MarkerTypeTableItem> markerTypeTable;
113 : } // namespace mu::engraving
|