Skip to content

Commit

Permalink
Fix GH#8970, fix #292231: remove space between accidentals and arpeggios
Browse files Browse the repository at this point in the history
Backport of musescore#9097, fixes musescore#8970
  • Loading branch information
Nick-Mazuk authored and Jojo-Schmitz committed Sep 14, 2021
1 parent 146207c commit e16c662
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions libmscore/chord.cpp
Expand Up @@ -1912,6 +1912,12 @@ void Chord::layoutPitched()
// process notes
//-----------------------------------------

// Keeps track if there are any accidentals in this cord.
// Used to remove excess space in front of arpeggios.
// See GitHub issue #8970 for more details.
// https://github.com/musescore/MuseScore/issues/8970
bool chordHasAccidental = false;

for (Note* note : _notes) {
note->layout();

Expand All @@ -1923,6 +1929,8 @@ void Chord::layoutPitched()
lhead = qMax(lhead, -x1);

Accidental* accidental = note->accidental();
if (accidental)
chordHasAccidental = true;
if (accidental && accidental->addToSkyline() && !note->fixed()) {
// convert x position of accidental to segment coordinate system
qreal x = accidental->pos().x() + note->pos().x() + chordX;
Expand Down Expand Up @@ -2002,10 +2010,17 @@ void Chord::layoutPitched()
addLedgerLines();

if (_arpeggio) {
qreal arpeggioDistance = score()->styleP(Sid::ArpeggioNoteDistance) * mag_;
qreal arpeggioAccidentalDistance = score()->styleP(Sid::ArpeggioAccidentalDistance) * mag_;
qreal arpeggioNoteDistance = score()->styleP(Sid::ArpeggioNoteDistance) * mag_;
qreal accidentalDistance = score()->styleP(Sid::accidentalDistance) * mag_;

qreal gapSize = chordHasAccidental ? (arpeggioAccidentalDistance - accidentalDistance) : arpeggioNoteDistance;

_arpeggio->layout(); // only for width() !
_arpeggio->setHeight(0.0);
qreal extraX = _arpeggio->width() + arpeggioDistance + chordX;

qreal extraX = _arpeggio->width() + gapSize + chordX;

qreal y1 = upnote->pos().y() - upnote->headHeight() * .5;
_arpeggio->setPos(-(lll + extraX), y1);
if (_arpeggio->visible())
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.cpp
Expand Up @@ -448,6 +448,7 @@ static const StyleType styleTypes[] {
{ Sid::slurGateTime, "slurGateTime", QVariant(100) },

{ Sid::ArpeggioNoteDistance, "ArpeggioNoteDistance", Spatium(.5) },
{ Sid::ArpeggioAccidentalDistance, "ArpeggioAccidentalDistance", Spatium(.25) },
{ Sid::ArpeggioLineWidth, "ArpeggioLineWidth", Spatium(.18) },
{ Sid::ArpeggioHookLen, "ArpeggioHookLen", Spatium(.8) },
{ Sid::ArpeggioHiddenInStdIfTab,"ArpeggioHiddenInStdIfTab",QVariant(false)},
Expand Down
1 change: 1 addition & 0 deletions libmscore/style.h
Expand Up @@ -428,6 +428,7 @@ enum class Sid {
slurGateTime,

ArpeggioNoteDistance,
ArpeggioAccidentalDistance,
ArpeggioLineWidth,
ArpeggioHookLen,
ArpeggioHiddenInStdIfTab,
Expand Down

0 comments on commit e16c662

Please sign in to comment.