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 : #include "rasgueado.h"
24 :
25 : #include "score.h"
26 : #include "system.h"
27 : #include "text.h"
28 :
29 : using namespace mu;
30 : using namespace mu::engraving;
31 :
32 : namespace mu::engraving {
33 : static const ElementStyle rasgueadoStyle {
34 : { Sid::letRingFontFace, Pid::BEGIN_FONT_FACE },
35 : { Sid::letRingFontFace, Pid::CONTINUE_FONT_FACE },
36 : { Sid::letRingFontFace, Pid::END_FONT_FACE },
37 : { Sid::letRingFontSize, Pid::BEGIN_FONT_SIZE },
38 : { Sid::letRingFontSize, Pid::CONTINUE_FONT_SIZE },
39 : { Sid::letRingFontSize, Pid::END_FONT_SIZE },
40 : { Sid::letRingFontStyle, Pid::BEGIN_FONT_STYLE },
41 : { Sid::letRingFontStyle, Pid::CONTINUE_FONT_STYLE },
42 : { Sid::letRingFontStyle, Pid::END_FONT_STYLE },
43 : { Sid::letRingTextAlign, Pid::BEGIN_TEXT_ALIGN },
44 : { Sid::letRingTextAlign, Pid::CONTINUE_TEXT_ALIGN },
45 : { Sid::letRingTextAlign, Pid::END_TEXT_ALIGN },
46 : { Sid::letRingPosition, Pid::BEGIN_TEXT_POSITION },
47 : { Sid::letRingPosition, Pid::CONTINUE_TEXT_POSITION },
48 : { Sid::letRingPosition, Pid::END_TEXT_POSITION },
49 : { Sid::letRingHookHeight, Pid::BEGIN_HOOK_HEIGHT },
50 : { Sid::letRingHookHeight, Pid::END_HOOK_HEIGHT },
51 : { Sid::letRingLineStyle, Pid::LINE_STYLE },
52 : { Sid::letRingDashLineLen, Pid::DASH_LINE_LEN },
53 : { Sid::letRingDashGapLen, Pid::DASH_GAP_LEN },
54 : { Sid::letRingFontSpatiumDependent, Pid::TEXT_SIZE_SPATIUM_DEPENDENT },
55 : { Sid::letRingEndHookType, Pid::END_HOOK_TYPE },
56 : { Sid::letRingLineWidth, Pid::LINE_WIDTH },
57 : { Sid::ottava8VAPlacement, Pid::PLACEMENT },
58 : { Sid::letRingMusicalSymbolSize, Pid::BEGIN_TEXT_MUSIC_SYMBOLS_SIZE },
59 : { Sid::letRingMusicalSymbolSize, Pid::CONTINUE_TEXT_MUSIC_SYMBOLS_SIZE },
60 : { Sid::letRingMusicalSymbolSize, Pid::END_TEXT_MUSIC_SYMBOLS_SIZE },
61 : { Sid::dummyMusicalSymbolsScale, Pid::BEGIN_TEXT_MUSICAL_SYMBOLS_SCALE },
62 : { Sid::dummyMusicalSymbolsScale, Pid::CONTINUE_TEXT_MUSICAL_SYMBOLS_SCALE },
63 : { Sid::dummyMusicalSymbolsScale, Pid::END_TEXT_MUSICAL_SYMBOLS_SCALE },
64 : };
65 :
66 4 : RasgueadoSegment::RasgueadoSegment(Rasgueado* sp)
67 4 : : TextLineBaseSegment(ElementType::RASGUEADO_SEGMENT, sp, ElementFlag::MOVABLE | ElementFlag::ON_STAFF)
68 : {
69 4 : m_text->setTextStyleType(propertyDefault(Pid::TEXT_STYLE).value<TextStyleType>());
70 4 : m_endText->setTextStyleType(propertyDefault(Pid::TEXT_STYLE).value<TextStyleType>());
71 4 : }
72 :
73 : //---------------------------------------------------------
74 : // Rasgueado
75 : //---------------------------------------------------------
76 :
77 66 : Rasgueado::Rasgueado(DummyParentOr<EngravingItem> parent)
78 66 : : ChordTextLineBase(ElementType::RASGUEADO, parent)
79 : {
80 66 : initElementStyle(&rasgueadoStyle);
81 66 : resetProperty(Pid::LINE_VISIBLE);
82 :
83 66 : resetProperty(Pid::BEGIN_TEXT_PLACE);
84 66 : resetProperty(Pid::BEGIN_TEXT);
85 66 : resetProperty(Pid::CONTINUE_TEXT_PLACE);
86 66 : resetProperty(Pid::CONTINUE_TEXT);
87 66 : resetProperty(Pid::END_TEXT_PLACE);
88 66 : resetProperty(Pid::END_TEXT);
89 66 : }
90 :
91 : static const ElementStyle rasgueadoSegmentStyle {
92 : { Sid::letRingMinDistance, Pid::MIN_DISTANCE },
93 : };
94 :
95 : //---------------------------------------------------------
96 : // createLineSegment
97 : //---------------------------------------------------------
98 :
99 4 : LineSegment* Rasgueado::createLineSegment()
100 : {
101 4 : RasgueadoSegment* wb = new RasgueadoSegment(this);
102 4 : wb->setTrack(track());
103 4 : wb->initElementStyle(&rasgueadoSegmentStyle);
104 4 : return wb;
105 : }
106 :
107 : //---------------------------------------------------------
108 : // propertyDefault
109 : //---------------------------------------------------------
110 :
111 1545 : PropertyValue Rasgueado::propertyDefault(Pid propertyId) const
112 : {
113 1545 : switch (propertyId) {
114 2 : case Pid::LINE_WIDTH:
115 2 : return style().styleV(Sid::letRingLineWidth);
116 :
117 0 : case Pid::ALIGN:
118 0 : return Align(AlignH::LEFT, AlignV::BASELINE);
119 :
120 2 : case Pid::LINE_STYLE:
121 2 : return style().styleV(Sid::letRingLineStyle);
122 :
123 101 : case Pid::LINE_VISIBLE:
124 101 : return true;
125 :
126 70 : case Pid::CONTINUE_TEXT_OFFSET:
127 : case Pid::END_TEXT_OFFSET:
128 70 : return PropertyValue::fromValue(PointF(0, 0));
129 :
130 2 : case Pid::BEGIN_FONT_STYLE:
131 2 : return style().styleV(Sid::letRingFontStyle);
132 :
133 202 : case Pid::BEGIN_TEXT:
134 : case Pid::CONTINUE_TEXT:
135 202 : return PropertyValue::fromValue("rasg"); // TODO: fix the style
136 101 : case Pid::END_TEXT:
137 101 : return "";
138 :
139 35 : case Pid::BEGIN_HOOK_TYPE:
140 35 : return HookType::NONE;
141 :
142 303 : case Pid::BEGIN_TEXT_PLACE:
143 : case Pid::CONTINUE_TEXT_PLACE:
144 : case Pid::END_TEXT_PLACE:
145 303 : return TextPlace::AUTO;
146 :
147 8 : case Pid::TEXT_STYLE:
148 8 : return TextStyleType::LET_RING;
149 :
150 280 : case Pid::BEGIN_FILLED_ARROW_HEIGHT: // No arrow endings for rasguedo
151 : case Pid::BEGIN_FILLED_ARROW_WIDTH:
152 : case Pid::END_FILLED_ARROW_HEIGHT:
153 : case Pid::END_FILLED_ARROW_WIDTH:
154 : case Pid::BEGIN_LINE_ARROW_HEIGHT:
155 : case Pid::BEGIN_LINE_ARROW_WIDTH:
156 : case Pid::END_LINE_ARROW_HEIGHT:
157 : case Pid::END_LINE_ARROW_WIDTH:
158 280 : return 0.0;
159 :
160 439 : default:
161 439 : return TextLineBase::propertyDefault(propertyId);
162 : }
163 : }
164 :
165 : //---------------------------------------------------------
166 : // getPropertyStyle
167 : //---------------------------------------------------------
168 :
169 2069 : Sid Rasgueado::getPropertyStyle(Pid id) const
170 : {
171 2069 : switch (id) {
172 68 : case Pid::PLACEMENT:
173 68 : return Sid::ottava8VAPlacement; // TODO: fix the style
174 68 : case Pid::BEGIN_FONT_FACE:
175 68 : return Sid::letRingFontFace;
176 204 : case Pid::BEGIN_FONT_SIZE:
177 : case Pid::CONTINUE_FONT_SIZE:
178 : case Pid::END_FONT_SIZE:
179 204 : return Sid::letRingFontSize;
180 202 : case Pid::BEGIN_FONT_STYLE:
181 : case Pid::CONTINUE_FONT_STYLE:
182 : case Pid::END_FONT_STYLE:
183 202 : return Sid::letRingFontStyle;
184 204 : case Pid::BEGIN_TEXT_ALIGN:
185 : case Pid::CONTINUE_TEXT_ALIGN:
186 : case Pid::END_TEXT_ALIGN:
187 204 : return Sid::letRingTextAlign;
188 136 : case Pid::BEGIN_HOOK_HEIGHT:
189 : case Pid::END_HOOK_HEIGHT:
190 136 : return Sid::letRingHookHeight;
191 1187 : default:
192 1187 : break;
193 : }
194 1187 : return TextLineBase::getPropertyStyle(id);
195 : }
196 :
197 4 : Sid Rasgueado::defaultPosSid() const
198 : {
199 4 : return placeAbove() ? Sid::letRingPosAbove : Sid::letRingPosBelow;
200 : }
201 : }
|