Skip to content

Commit

Permalink
fix #305613: add heavy double barline
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed May 19, 2020
1 parent f978f1d commit c07d278
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
5 changes: 5 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,8 @@ static QString normalBarlineStyle(const BarLine* bl)
case BarLineType::END:
case BarLineType::END_START_REPEAT:
return "light-heavy";
case BarLineType::DOUBLE_HEAVY:
return "heavy-heavy";
default:
qDebug("bar subtype %d not supported", int(bst));
}
Expand Down Expand Up @@ -1709,6 +1711,9 @@ void ExportMusicXml::barlineRight(const Measure* const m)
case BarLineType::END_START_REPEAT:
_xml.tag("bar-style", QString("light-heavy"));
break;
case BarLineType::DOUBLE_HEAVY:
_xml.tag("bar-style", QString("heavy-heavy"));
break;
default:
qDebug("ExportMusicXml::bar(): bar subtype %d not supported", int(bst));
break;
Expand Down
4 changes: 2 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,9 +3127,9 @@ static bool determineBarLineType(const QString& barStyle, const QString& repeat,
/*
else if (barStyle == "heavy-light")
;
else if (barStyle == "heavy-heavy")
;
*/
else if (barStyle == "heavy-heavy")
type = BarLineType::DOUBLE_HEAVY;
else if (barStyle == "none")
visible = false;
else if (barStyle == "") {
Expand Down
15 changes: 14 additions & 1 deletion libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ static void undoChangeBarLineType(BarLine* bl, BarLineType barType, bool allStav
case BarLineType::NORMAL:
case BarLineType::DOUBLE:
case BarLineType::BROKEN:
case BarLineType::DOTTED: {
case BarLineType::DOTTED:
case BarLineType::DOUBLE_HEAVY: {
Segment* segment = bl->segment();
SegmentType segmentType = segment->segmentType();
if (segmentType == SegmentType::EndBarLine) {
Expand Down Expand Up @@ -202,6 +203,7 @@ const std::vector<BarLineTableItem> BarLine::barLineTable {
{ BarLineType::END, QT_TRANSLATE_NOOP("Palette", "Final barline"), "end" },
{ BarLineType::END_START_REPEAT, QT_TRANSLATE_NOOP("Palette", "End-start repeat barline"), "end-start-repeat" },
{ BarLineType::DOTTED, QT_TRANSLATE_NOOP("Palette", "Dotted barline"), "dotted" },
{ BarLineType::DOUBLE_HEAVY, QT_TRANSLATE_NOOP("Palette", "Double heavy barline"), "double heavy" },
};

//---------------------------------------------------------
Expand Down Expand Up @@ -576,6 +578,16 @@ void BarLine::draw(QPainter* painter) const
}
break;

case BarLineType::DOUBLE_HEAVY: {
qreal lw2 = score()->styleP(Sid::endBarWidth) * mag();
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
qreal x = lw2 * .5;
painter->drawLine(QLineF(x, y1, x, y2));
x += score()->styleP(Sid::endBarDistance) * mag();
painter->drawLine(QLineF(x, y1, x, y2));
}
break;

case BarLineType::START_REPEAT: {
qreal lw2 = score()->styleP(Sid::endBarWidth) * mag();
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
Expand Down Expand Up @@ -1193,6 +1205,7 @@ qreal BarLine::layoutWidth(Score* score, BarLineType type)
qreal w {0.0};
switch (type) {
case BarLineType::DOUBLE:
case BarLineType::DOUBLE_HEAVY:
w = score->styleP(Sid::doubleBarWidth) + score->styleP(Sid::doubleBarDistance);
break;
case BarLineType::END_START_REPEAT:
Expand Down
4 changes: 3 additions & 1 deletion libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ enum class BarLineType {
START_REPEAT = 4,
END_REPEAT = 8,
BROKEN = 0x10,
//DASHED = BROKEN,
END = 0x20,
END_START_REPEAT = 0x40,
DOTTED = 0x80
DOTTED = 0x80,
DOUBLE_HEAVY = 0x100,
};

constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
Expand Down
50 changes: 42 additions & 8 deletions mscore/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,15 +878,37 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"..#.#.."
};

static const char* doubleHeavyBarline[] = {
"7 14 2 1",
"# c #000000",
". c None",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##.",
".##.##."
};

QPixmap* leftRepeatPixmap = new QPixmap(leftRepeat);
QPixmap* rightRepeatPixmap = new QPixmap(rightRepeat);
QPixmap* finalBarlinePixmap = new QPixmap(finalBarline);
QPixmap* doubleBarlinePixmap = new QPixmap(doubleBarline);
QPixmap* doubleHeavyBarlinePixmap = new QPixmap(doubleHeavyBarline);

_barlines["Start repeat"] = leftRepeatPixmap;
_barlines["End repeat"] = rightRepeatPixmap;
_barlines["Start repeat barline"] = leftRepeatPixmap;
_barlines["End repeat barline"] = rightRepeatPixmap;
_barlines["Final barline"] = finalBarlinePixmap;
_barlines["Double barline"] = doubleBarlinePixmap;
_barlines["Double heavy barline"] = doubleHeavyBarlinePixmap;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1255,17 +1277,21 @@ void Timeline::barlineMeta(Segment* seg, int* stagger, int pos)
if (barline) {
switch (barline->barLineType()) {
case BarLineType::START_REPEAT:
repeatText = QString("Start repeat");
repeatText = QString("Start repeat barline");
break;
case BarLineType::END_REPEAT:
repeatText = QString("End repeat");
repeatText = QString("End repeat barline");
break;
case BarLineType::END_START_REPEAT:
// actually an end repeat followed by a start repeat, so nothing needs to be done here
//repeatText = QString("End-start repeat barline");
break;
case BarLineType::DOUBLE:
repeatText = QString("Double barline");
break;
case BarLineType::DOUBLE_HEAVY:
repeatText = QString("Double heavy barline");
break;
case BarLineType::END:
repeatText = QString("Final barline");
break;
Expand Down Expand Up @@ -1454,7 +1480,7 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
textWidth = 10;
if (textWidth > _gridWidth) {
textWidth = _gridWidth;
if (metaText == QString("End repeat") && std::get<4>(_repeatInfo))
if (metaText == QString("End repeat barline") && std::get<4>(_repeatInfo))
textWidth /= 2;
}
}
Expand All @@ -1463,7 +1489,12 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
textWidth = getWidth() - x;

// Adjust x for end repeats
if ((metaText == QString("End repeat") || metaText == QString("Final barline") || metaText == QString("Double barline") || std::get<2>(_repeatInfo)) && !_collapsedMeta) {
if ((metaText == QString("End repeat barline") ||
metaText == QString("Final barline") ||
metaText == QString("Double barline") ||
metaText == QString("Double heavy barline") ||
std::get<2>(_repeatInfo))
&& !_collapsedMeta) {
if (std::get<0>(_repeatInfo) > 0)
x = pos + _gridWidth - std::get<1>(_repeatInfo) + std::get<0>(_repeatInfo) * _spacing;
else {
Expand All @@ -1486,7 +1517,7 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
// Exact values required for repeat pixmap to work visually
if (textWidth != 10)
graphicsPixmapItem = new QGraphicsPixmapItem();
if (metaText == QString("Start repeat"))
if (metaText == QString("Start repeat barline"))
std::get<4>(_repeatInfo) = true;
graphicsPixmapItem->setX(x + 2);
graphicsPixmapItem->setY(_gridHeight * row + verticalScrollBar()->value() + 3);
Expand Down Expand Up @@ -1806,7 +1837,10 @@ void Timeline::drawSelection()
staffIdx = -1;
BarLine* barline = toBarLine(element);
if (barline &&
(barline->barLineType() == BarLineType::END_REPEAT || barline->barLineType() == BarLineType::DOUBLE || barline->barLineType() == BarLineType::END) &&
(barline->barLineType() == BarLineType::END_REPEAT ||
barline->barLineType() == BarLineType::DOUBLE ||
barline->barLineType() == BarLineType::DOUBLE_HEAVY ||
barline->barLineType() == BarLineType::END) &&
measure != _score->lastMeasure()) {
if (measure->prevMeasure())
measure = measure->prevMeasure();
Expand Down

0 comments on commit c07d278

Please sign in to comment.