Skip to content

Commit c9ebd29

Browse files
asattelyJojo-Schmitz
authored andcommitted
Fix GH#8975: Change how barline distance is used in order to avoid collisions in double bar lines
Backport of musescore#9138, part 1
1 parent cd17edc commit c9ebd29

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

libmscore/barline.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,17 @@ void BarLine::draw(QPainter* painter) const
585585

586586
qreal lw2 = score()->styleP(Sid::endBarWidth) * mag();
587587
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
588-
x += score()->styleP(Sid::endBarDistance) * mag();
588+
x += ((lw * .5) + score()->styleP(Sid::endBarDistance) + (lw2 * .5)) * mag();
589589
painter->drawLine(QLineF(x, y1, x, y2));
590590
}
591591
break;
592592

593593
case BarLineType::DOUBLE: {
594-
qreal lw2 = score()->styleP(Sid::doubleBarWidth) * mag();
595-
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
596-
qreal x = lw2 * .5;
594+
qreal lw = score()->styleP(Sid::doubleBarWidth) * mag();
595+
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
596+
qreal x = lw * .5;
597597
painter->drawLine(QLineF(x, y1, x, y2));
598-
x += score()->styleP(Sid::doubleBarDistance) * mag();
598+
x += ((lw * .5) + score()->styleP(Sid::doubleBarDistance) + (lw * .5)) * mag();
599599
painter->drawLine(QLineF(x, y1, x, y2));
600600
}
601601
break;
@@ -608,7 +608,7 @@ void BarLine::draw(QPainter* painter) const
608608

609609
qreal lw2 = score()->styleP(Sid::barWidth) * mag();
610610
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
611-
x += score()->styleP(Sid::endBarDistance) * mag();
611+
x += ((lw * .5) + score()->styleP(Sid::endBarDistance) + (lw2 * .5)) * mag();
612612
painter->drawLine(QLineF(x, y1, x, y2));
613613
}
614614
break;
@@ -625,7 +625,7 @@ void BarLine::draw(QPainter* painter) const
625625
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
626626
qreal x = lw2 * .5;
627627
painter->drawLine(QLineF(x, y1, x, y2));
628-
x += score()->styleP(Sid::endBarDistance) * mag();
628+
x += ((lw2 * .5) + score()->styleP(Sid::endBarDistance) + (lw2 * .5)) * mag();
629629
painter->drawLine(QLineF(x, y1, x, y2));
630630
}
631631
break;
@@ -638,11 +638,10 @@ void BarLine::draw(QPainter* painter) const
638638

639639
qreal lw = score()->styleP(Sid::barWidth) * mag();
640640
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
641-
x += score()->styleP(Sid::endBarDistance) * mag();
641+
x += ((lw2 * .5) + score()->styleP(Sid::endBarDistance) + (lw * .5)) * mag();
642642
painter->drawLine(QLineF(x, y1, x, y2));
643643

644-
x += score()->styleP(Sid::repeatBarlineDotSeparation) * mag();
645-
x -= symBbox(SymId::repeatDot).width() * .5;
644+
x += ((lw * .5) + score()->styleP(Sid::repeatBarlineDotSeparation)) * mag();
646645
drawDots(painter, x);
647646

648647
if (score()->styleB(Sid::repeatBarTips))
@@ -657,13 +656,12 @@ void BarLine::draw(QPainter* painter) const
657656
qreal x = 0.0; // symBbox(SymId::repeatDot).width() * .5;
658657
drawDots(painter, x);
659658

660-
x += score()->styleP(Sid::repeatBarlineDotSeparation) * mag();
661-
x += symBbox(SymId::repeatDot).width() * .5;
659+
x += symBbox(SymId::repeatDot).width();
660+
x += (score()->styleP(Sid::repeatBarlineDotSeparation) + (lw * .5)) * mag();
662661
painter->drawLine(QLineF(x, y1, x, y2));
663662

664-
x += score()->styleP(Sid::endBarDistance) * mag();
665-
666663
qreal lw2 = score()->styleP(Sid::endBarWidth) * mag();
664+
x += ((lw * .5) + score()->styleP(Sid::endBarDistance) + (lw2 * .5)) * mag();
667665
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
668666
painter->drawLine(QLineF(x, y1, x, y2));
669667

@@ -678,25 +676,23 @@ void BarLine::draw(QPainter* painter) const
678676
qreal x = 0.0; // symBbox(SymId::repeatDot).width() * .5;
679677
drawDots(painter, x);
680678

681-
x += score()->styleP(Sid::repeatBarlineDotSeparation) * mag();
682-
x += symBbox(SymId::repeatDot).width() * .5;
679+
x += symBbox(SymId::repeatDot).width();
680+
x += (score()->styleP(Sid::repeatBarlineDotSeparation) + (lw * .5)) * mag();
683681
painter->drawLine(QLineF(x, y1, x, y2));
684682

685-
x += score()->styleP(Sid::endBarDistance) * mag();
686-
687683
qreal lw2 = score()->styleP(Sid::endBarWidth) * mag();
684+
x += ((lw * .5) + score()->styleP(Sid::endBarDistance) + (lw2 * .5)) * mag();
688685
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
689686
painter->drawLine(QLineF(x, y1, x, y2));
690687

691688
if (score()->styleB(Sid::repeatBarTips))
692689
drawTips(painter, true, x + lw2 * .5);
693690

694691
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
695-
x += score()->styleP(Sid::endBarDistance) * mag();
692+
x += ((lw2 * .5) + score()->styleP(Sid::endBarDistance) + (lw * .5)) * mag();
696693
painter->drawLine(QLineF(x, y1, x, y2));
697694

698-
x += score()->styleP(Sid::repeatBarlineDotSeparation) * mag();
699-
x -= symBbox(SymId::repeatDot).width() * .5;
695+
x += ((lw * .5) + score()->styleP(Sid::repeatBarlineDotSeparation)) * mag();
700696
drawDots(painter, x);
701697

702698
if (score()->styleB(Sid::repeatBarTips))
@@ -1247,26 +1243,32 @@ qreal BarLine::layoutWidth(Score* score, BarLineType type)
12471243
qreal w {0.0};
12481244
switch (type) {
12491245
case BarLineType::DOUBLE:
1250-
w = score->styleP(Sid::doubleBarWidth) + score->styleP(Sid::doubleBarDistance);
1246+
w = (score->styleP(Sid::doubleBarWidth) * 2)
1247+
+ score->styleP(Sid::doubleBarDistance);
12511248
break;
12521249
case BarLineType::DOUBLE_HEAVY:
1253-
w = score->styleP(Sid::endBarWidth) + score->styleP(Sid::endBarDistance);
1250+
w = (score->styleP(Sid::endBarWidth) * 2)
1251+
+ score->styleP(Sid::endBarDistance);
12541252
break;
12551253
case BarLineType::END_START_REPEAT:
1256-
w = score->styleP(Sid::endBarDistance) * 2
1257-
+ score->styleP(Sid::repeatBarlineDotSeparation) * 2
1258-
+ dotwidth;
1254+
w = score->styleP(Sid::endBarWidth)
1255+
+ (score->styleP(Sid::barWidth) * 2)
1256+
+ (score->styleP(Sid::endBarDistance) * 2)
1257+
+ (score->styleP(Sid::repeatBarlineDotSeparation) * 2)
1258+
+ (dotwidth * 2);
12591259
break;
12601260
case BarLineType::START_REPEAT:
12611261
case BarLineType::END_REPEAT:
1262-
w = score->styleP(Sid::endBarWidth) * .5
1262+
w = score->styleP(Sid::endBarWidth)
1263+
+ score->styleP(Sid::barWidth)
12631264
+ score->styleP(Sid::endBarDistance)
12641265
+ score->styleP(Sid::repeatBarlineDotSeparation)
1265-
+ dotwidth * .5;
1266+
+ dotwidth;
12661267
break;
12671268
case BarLineType::END:
12681269
case BarLineType::REVERSE_END:
1269-
w = (score->styleP(Sid::endBarWidth) + score->styleP(Sid::barWidth)) * .5
1270+
w = score->styleP(Sid::endBarWidth)
1271+
+ score->styleP(Sid::barWidth)
12701272
+ score->styleP(Sid::endBarDistance);
12711273
break;
12721274
case BarLineType::BROKEN:

0 commit comments

Comments
 (0)