Skip to content

Commit df5615e

Browse files
Nick-MazukJojo-Schmitz
authored andcommitted
Use flat caps for arpeggio lines
Backport of musescore#9219
1 parent 8e76bfd commit df5615e

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

libmscore/arpeggio.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void Arpeggio::read(XmlReader& e)
109109

110110
//---------------------------------------------------------
111111
// symbolLine
112-
// construct a string of symbols aproximating width w
112+
// construct a string of symbols approximating width w
113113
//---------------------------------------------------------
114114

115115
void Arpeggio::symbolLine(SymId end, SymId fill)
@@ -180,25 +180,28 @@ void Arpeggio::layout()
180180
qreal _spatium = spatium();
181181
qreal x1 = _spatium * .5;
182182
qreal w = symBbox(SymId::arrowheadBlackUp).width();
183-
qreal lw = score()->styleS(Sid::ArpeggioLineWidth).val() * _spatium;
184-
setbbox(QRectF(x1 - w * .5, y1, w, y2 - y1 + lw * .5));
183+
qreal terminalDistance = 0;
184+
if (parent())
185+
terminalDistance = _spatium / 4 - score()->styleP(Sid::ArpeggioLineWidth) / 2;
186+
setbbox(QRectF(x1 - w * .5, y1, w, y2 - y1 + terminalDistance));
185187
}
186188
break;
187189

188190
case ArpeggioType::DOWN_STRAIGHT: {
189191
qreal _spatium = spatium();
190192
qreal x1 = _spatium * .5;
191193
qreal w = symBbox(SymId::arrowheadBlackDown).width();
192-
qreal lw = score()->styleS(Sid::ArpeggioLineWidth).val() * _spatium;
193-
setbbox(QRectF(x1 - w * .5, y1 - lw * .5, w, y2 - y1 + lw * .5));
194+
qreal terminalDistance = 0;
195+
if (parent())
196+
terminalDistance = _spatium / 4 - score()->styleP(Sid::ArpeggioLineWidth) / 2;
197+
setbbox(QRectF(x1 - w * .5, y1 - terminalDistance, w, y2 - y1 + terminalDistance));
194198
}
195199
break;
196200

197201
case ArpeggioType::BRACKET: {
198202
qreal _spatium = spatium();
199-
qreal lw = score()->styleS(Sid::ArpeggioLineWidth).val() * _spatium * .5;
200203
qreal w = score()->styleS(Sid::ArpeggioHookLen).val() * _spatium;
201-
setbbox(QRectF(0.0, y1, w, y2-y1).adjusted(-lw, -lw, lw, lw));
204+
setbbox(QRectF(0.0, y1, w, y2 - y1));
202205
break;
203206
}
204207
}
@@ -214,14 +217,14 @@ void Arpeggio::draw(QPainter* p) const
214217
return;
215218
qreal _spatium = spatium();
216219

217-
qreal y1 = -_userLen1;
218-
qreal y2 = _height + _userLen2;
220+
qreal y1 = bbox().top();
221+
qreal y2 = bbox().bottom();
219222

220-
p->setPen(QPen(curColor(),
221-
score()->styleS(Sid::ArpeggioLineWidth).val() * _spatium,
222-
Qt::SolidLine, Qt::RoundCap));
223+
qreal lineWidth = score()->styleP(Sid::ArpeggioLineWidth);
223224

225+
p->setPen(QPen(curColor(), lineWidth, Qt::SolidLine,Qt::FlatCap));
224226
p->save();
227+
225228
switch (arpeggioType()) {
226229
case ArpeggioType::NORMAL:
227230
case ArpeggioType::UP:
@@ -266,9 +269,9 @@ void Arpeggio::draw(QPainter* p) const
266269
case ArpeggioType::BRACKET:
267270
{
268271
qreal w = score()->styleS(Sid::ArpeggioHookLen).val() * _spatium;
269-
p->drawLine(QLineF(0.0, y1, 0.0, y2));
270272
p->drawLine(QLineF(0.0, y1, w, y1));
271273
p->drawLine(QLineF(0.0, y2, w, y2));
274+
p->drawLine(QLineF(0.0, y1 - lineWidth / 2, 0.0, y2 + lineWidth / 2));
272275
}
273276
break;
274277
}

0 commit comments

Comments
 (0)