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_TEXTLINEBASE_H
24 : #define MU_ENGRAVING_TEXTLINEBASE_H
25 :
26 : #include "../types/types.h"
27 :
28 : #include "line.h"
29 : #include "property.h"
30 :
31 : namespace mu::engraving {
32 : class EngravingItem;
33 : class Text;
34 : class TextLineBase;
35 :
36 : //---------------------------------------------------------
37 : // @@ TextLineBaseSegment
38 : //---------------------------------------------------------
39 :
40 : class TextLineBaseSegment : public LineSegment
41 : {
42 0 : OBJECT_ALLOCATOR(engraving, TextLineBaseSegment)
43 :
44 : public:
45 : TextLineBaseSegment(const ElementType& type, TextLineBase*, ElementFlags f = ElementFlag::NOTHING);
46 : TextLineBaseSegment(const TextLineBaseSegment&);
47 : ~TextLineBaseSegment();
48 :
49 2566 : TextLineBase* textLineBase() const { return (TextLineBase*)spanner(); }
50 :
51 : void setSelected(bool f) override;
52 :
53 : void spatiumChanged(double /*oldValue*/, double /*newValue*/) override;
54 :
55 : EngravingObject* propertyDelegate(Pid) const override;
56 :
57 : bool setProperty(Pid id, const PropertyValue& v) override;
58 :
59 11 : bool twoLines() const { return m_twoLines; }
60 472 : void setTwoLines(bool val) { m_twoLines = val; }
61 :
62 27438 : Text* text() const { return m_text; }
63 21983 : Text* endText() const { return m_endText; }
64 :
65 : struct LayoutData : public EngravingItem::LayoutData {
66 : std::array<PointF, 6> points;
67 : PolygonF joinedHairpin = PolygonF();
68 : PolygonF beginArrow = PolygonF();
69 : PolygonF endArrow = PolygonF();
70 : int npoints = 0;
71 : double lineLength = 0;
72 : };
73 3844 : DECLARE_LAYOUTDATA_METHODS(TextLineBaseSegment)
74 :
75 : static RectF boundingBoxOfLine(const PointF& p1, const PointF& p2, double lw2, bool isDottedLine);
76 :
77 : protected:
78 :
79 : Text* m_text = nullptr;
80 : Text* m_endText = nullptr;
81 :
82 : bool m_twoLines = false;
83 : };
84 :
85 : //---------------------------------------------------------
86 : // @@ TextLineBase
87 : //---------------------------------------------------------
88 :
89 : class TextLineBase : public SLine
90 : {
91 0 : OBJECT_ALLOCATOR(engraving, TextLineBase)
92 :
93 5376 : M_PROPERTY(bool, lineVisible, setLineVisible)
94 5018 : M_PROPERTY2(HookType, beginHookType, setBeginHookType, HookType::NONE)
95 4739 : M_PROPERTY2(HookType, endHookType, setEndHookType, HookType::NONE)
96 2632 : M_PROPERTY(Spatium, beginHookHeight, setBeginHookHeight)
97 2463 : M_PROPERTY(Spatium, endHookHeight, setEndHookHeight)
98 113 : M_PROPERTY(Spatium, beginLineArrowHeight, setBeginLineArrowHeight)
99 113 : M_PROPERTY(Spatium, beginLineArrowWidth, setBeginLineArrowWidth)
100 113 : M_PROPERTY(Spatium, beginFilledArrowHeight, setBeginFilledArrowHeight)
101 113 : M_PROPERTY(Spatium, beginFilledArrowWidth, setBeginFilledArrowWidth)
102 113 : M_PROPERTY(Spatium, endLineArrowHeight, setEndLineArrowHeight)
103 113 : M_PROPERTY(Spatium, endLineArrowWidth, setEndLineArrowWidth)
104 113 : M_PROPERTY(Spatium, endFilledArrowHeight, setEndFilledArrowHeight)
105 113 : M_PROPERTY(Spatium, endFilledArrowWidth, setEndFilledArrowWidth)
106 2426 : M_PROPERTY(Spatium, gapBetweenTextAndLine, setGapBetweenTextAndLine)
107 :
108 1619 : M_PROPERTY2(TextPlace, beginTextPlace, setBeginTextPlace, TextPlace::AUTO)
109 4859 : M_PROPERTY(String, beginText, setBeginText)
110 2180 : M_PROPERTY(Align, beginTextAlign, setBeginTextAlign)
111 2608 : M_PROPERTY(AlignH, beginTextPosition, setBeginTextPosition)
112 3607 : M_PROPERTY(String, beginFontFamily, setBeginFontFamily)
113 3607 : M_PROPERTY(double, beginFontSize, setBeginFontSize)
114 3607 : M_PROPERTY(FontStyle, beginFontStyle, setBeginFontStyle)
115 3607 : M_PROPERTY2(double, beginTextMusicalSymbolsScale, setBeginTextMusicalSymbolsScale, 1.0)
116 3607 : M_PROPERTY2(double, beginTextMusicSymbolsSize, setBeginTextMusicSymbolsSize, 12.0)
117 1673 : M_PROPERTY(PointF, beginTextOffset, setBeginTextOffset)
118 :
119 1736 : M_PROPERTY2(TextPlace, continueTextPlace, setContinueTextPlace, TextPlace::AUTO)
120 2384 : M_PROPERTY2(double, continueTextMusicalSymbolsScale, setContinueTextMusicalSymbolsScale, 1.0)
121 2384 : M_PROPERTY2(double, continueTextMusicSymbolsSize, setContinueTextMusicSymbolsSize, 12.0)
122 2996 : M_PROPERTY(String, continueText, setContinueText)
123 511 : M_PROPERTY(Align, continueTextAlign, setContinueTextAlign)
124 939 : M_PROPERTY(AlignH, continueTextPosition, setContinueTextPosition)
125 2384 : M_PROPERTY(String, continueFontFamily, setContinueFontFamily)
126 2384 : M_PROPERTY(double, continueFontSize, setContinueFontSize)
127 2384 : M_PROPERTY(FontStyle, continueFontStyle, setContinueFontStyle)
128 314 : M_PROPERTY(PointF, continueTextOffset, setContinueTextOffset)
129 :
130 1537 : M_PROPERTY2(TextPlace, endTextPlace, setEndTextPlace, TextPlace::AUTO)
131 3605 : M_PROPERTY2(double, endTextMusicalSymbolsScale, setEndTextMusicalSymbolsScale, 1.0)
132 3605 : M_PROPERTY2(double, endTextMusicSymbolsSize, setEndTextMusicSymbolsSize, 12.0)
133 3551 : M_PROPERTY(String, endText, setEndText)
134 2178 : M_PROPERTY(Align, endTextAlign, setEndTextAlign)
135 2606 : M_PROPERTY(AlignH, endTextPosition, setEndTextPosition)
136 3605 : M_PROPERTY(String, endFontFamily, setEndFontFamily)
137 3605 : M_PROPERTY(double, endFontSize, setEndFontSize)
138 3605 : M_PROPERTY(FontStyle, endFontStyle, setEndFontStyle)
139 1535 : M_PROPERTY(PointF, endTextOffset, setEndTextOffset)
140 3690 : M_PROPERTY(bool, textSizeSpatiumDependent, setTextSizeSpatiumDependent)
141 :
142 : public:
143 630 : TextLineBase(const ElementType& type, EngravingObject* parent, ElementFlags = ElementFlag::NOTHING);
144 :
145 : void spatiumChanged(double /*oldValue*/, double /*newValue*/) override;
146 :
147 : PropertyValue getProperty(Pid id) const override;
148 : bool setProperty(Pid propertyId, const PropertyValue&) override;
149 : PropertyValue propertyDefault(Pid) const override;
150 : PropertyFlags propertyFlags(Pid) const override;
151 : void setPropertyFlags(Pid, PropertyFlags) override;
152 :
153 : static const std::array<Pid, 45>& textLineBasePropertyIds();
154 :
155 : void reset() override;
156 :
157 : protected:
158 : friend class TextLineBaseSegment;
159 : };
160 :
161 9441 : inline bool isSystemTextLine(const EngravingItem* element)
162 : {
163 9441 : return element && element->isTextLineBase() && element->systemFlag();
164 : }
165 : } // namespace mu::engraving
166 :
167 : #endif
|