Skip to content

Commit

Permalink
Fix #305613: Add heavy, reverse end and heavy double barlines
Browse files Browse the repository at this point in the history
Use translated names of barlines in timeline.
Previous versions won't show them and also loose them on save.
  • Loading branch information
Jojo-Schmitz committed Oct 25, 2020
1 parent 2a7fcf0 commit 0053122
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 19 deletions.
12 changes: 12 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,7 @@ static QString normalBarlineStyle(const BarLine* bl)
case BarLineType::DOUBLE:
return "light-light";
case BarLineType::END_REPEAT:
case BarLineType::REVERSE_END:
return "light-heavy";
case BarLineType::BROKEN:
return "dashed";
Expand All @@ -1654,6 +1655,10 @@ static QString normalBarlineStyle(const BarLine* bl)
case BarLineType::END:
case BarLineType::END_START_REPEAT:
return "light-heavy";
case BarLineType::HEAVY:
return "heavy";
case BarLineType::DOUBLE_HEAVY:
return "heavy-heavy";
default:
qDebug("bar subtype %d not supported", int(bst));
}
Expand Down Expand Up @@ -1824,6 +1829,7 @@ void ExportMusicXml::barlineRight(const Measure* const m, const int strack, cons
_xml.tag("bar-style", QString("light-light"));
break;
case BarLineType::END_REPEAT:
case BarLineType::REVERSE_END:
_xml.tag("bar-style", QString("light-heavy"));
break;
case BarLineType::BROKEN:
Expand All @@ -1836,6 +1842,12 @@ void ExportMusicXml::barlineRight(const Measure* const m, const int strack, cons
case BarLineType::END_START_REPEAT:
_xml.tag("bar-style", QString("light-heavy"));
break;
case BarLineType::HEAVY:
_xml.tag("bar-style", QString("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
10 changes: 7 additions & 3 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3122,6 +3122,8 @@ static bool determineBarLineType(const QString& barStyle, const QString& repeat,
type = BarLineType::START_REPEAT;
else if (barStyle == "light-heavy" && repeat.isEmpty())
type = BarLineType::END;
else if (barStyle == "heavy-light" && repeat.isEmpty())
type = BarLineType::REVERSE_END;
else if (barStyle == "regular")
type = BarLineType::NORMAL;
else if (barStyle == "dashed")
Expand All @@ -3133,9 +3135,11 @@ 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 == "heavy")
type = BarLineType::HEAVY;
else if (barStyle == "none")
visible = false;
else if (barStyle == "") {
Expand Down
45 changes: 44 additions & 1 deletion libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ 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::REVERSE_END:
case BarLineType::HEAVY:
case BarLineType::DOUBLE_HEAVY: {
Segment* segment = bl->segment();
SegmentType segmentType = segment->segmentType();
if (segmentType == SegmentType::EndBarLine) {
Expand Down Expand Up @@ -202,6 +205,9 @@ const std::vector<BarLineTableItem> BarLine::barLineTable {
{ BarLineType::END, Sym::symUserNames[int(SymId::barlineFinal)], "end" },
{ BarLineType::END_START_REPEAT, Sym::symUserNames[int(SymId::repeatRightLeft)], "end-start-repeat" },
{ BarLineType::DOTTED, Sym::symUserNames[int(SymId::barlineDotted)], "dotted" },
{ BarLineType::REVERSE_END, Sym::symUserNames[int(SymId::barlineReverseFinal)], "reverse-end" },
{ BarLineType::HEAVY, Sym::symUserNames[int(SymId::barlineHeavy)], "heavy" },
{ BarLineType::DOUBLE_HEAVY, Sym::symUserNames[int(SymId::barlineHeavyHeavy)], "double-heavy" },
};

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

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

qreal lw2 = score()->styleP(Sid::barWidth) * mag();
painter->setPen(QPen(curColor(), lw2, Qt::SolidLine, Qt::FlatCap));
x += score()->styleP(Sid::endBarDistance) * mag();
painter->drawLine(QLineF(x, y1, x, y2));
}
break;

case BarLineType::HEAVY: {
qreal lw = score()->styleP(Sid::endBarWidth) * mag();
painter->setPen(QPen(curColor(), lw, Qt::SolidLine, Qt::FlatCap));
painter->drawLine(QLineF(lw * .5, y1, lw * .5, y2));
}
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 @@ -1195,6 +1231,9 @@ qreal BarLine::layoutWidth(Score* score, BarLineType type)
case BarLineType::DOUBLE:
w = score->styleP(Sid::doubleBarWidth) + score->styleP(Sid::doubleBarDistance);
break;
case BarLineType::DOUBLE_HEAVY:
w = score->styleP(Sid::endBarWidth) * 2 + score->styleP(Sid::endBarDistance);
break;
case BarLineType::END_START_REPEAT:
w = score->styleP(Sid::endBarDistance) * 2
+ score->styleP(Sid::repeatBarlineDotSeparation) * 2
Expand All @@ -1208,6 +1247,7 @@ qreal BarLine::layoutWidth(Score* score, BarLineType type)
+ dotwidth * .5;
break;
case BarLineType::END:
case BarLineType::REVERSE_END:
w = (score->styleP(Sid::endBarWidth) + score->styleP(Sid::barWidth)) * .5
+ score->styleP(Sid::endBarDistance);
break;
Expand All @@ -1216,6 +1256,9 @@ qreal BarLine::layoutWidth(Score* score, BarLineType type)
case BarLineType::DOTTED:
w = score->styleP(Sid::barWidth);
break;
case BarLineType::HEAVY:
w = score->styleP(Sid::endBarWidth);
break;
}
return w;
}
Expand Down
12 changes: 11 additions & 1 deletion libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,23 @@ const int STAFF_GROUP_MAX = int(StaffGroup::TAB) + 1; // out of enum to avo

enum class BarLineType {
NORMAL = 1,
SINGLE = BarLineType::NORMAL,
DOUBLE = 2,
START_REPEAT = 4,
LEFT_REPEAT = BarLineType::START_REPEAT,
END_REPEAT = 8,
RIGHT_REPEAT = BarLineType::END_REPEAT,
BROKEN = 0x10,
DASHED = BarLineType::BROKEN,
END = 0x20,
FINAL = BarLineType::END,
END_START_REPEAT = 0x40,
DOTTED = 0x80
LEFT_RIGHT_REPEAT= BarLineType::END_START_REPEAT,
DOTTED = 0x80,
REVERSE_END = 0x100,
REVERSE_FINALE = BarLineType::REVERSE_END,
HEAVY = 0x200,
DOUBLE_HEAVY = 0x400,
};

constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
Expand Down
23 changes: 12 additions & 11 deletions libmscore/sym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3184,8 +3184,8 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Combining lower by one 31-limit schisma"),
QT_TRANSLATE_NOOP("symUserNames", "Combining lower by one 53-limit comma"),
"Combining open curly brace",
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 17-limit schisma)"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 19-limit schisma)"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 17-limit schisma"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 19-limit schisma"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 23-limit comma or 29-limit comma"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 31-limit schisma"),
QT_TRANSLATE_NOOP("symUserNames", "Combining raise by one 53-limit comma"),
Expand Down Expand Up @@ -3481,9 +3481,10 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Dashed barline"),
QT_TRANSLATE_NOOP("symUserNames", "Dotted barline"),
QT_TRANSLATE_NOOP("symUserNames", "Double barline"),
"Heavy barline",
"Heavy double barline",
"Reverse final barline",
QT_TRANSLATE_NOOP("symUserNames", "Final barline"),
QT_TRANSLATE_NOOP("symUserNames", "Heavy barline"),
QT_TRANSLATE_NOOP("symUserNames", "Heavy double barline"),
QT_TRANSLATE_NOOP("symUserNames", "Reverse final barline"),
QT_TRANSLATE_NOOP("symUserNames", "Short barline"),
QT_TRANSLATE_NOOP("symUserNames", "Single barline"),
QT_TRANSLATE_NOOP("symUserNames", "Tick barline"),
Expand Down Expand Up @@ -4157,8 +4158,8 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"Toe",
"Toe-click",
"Toe-drop",
"Toe-dtep",
"Toe-dap",
"Toe-step",
"Toe-tap",
"Trench",
"Wing",
"Wing-change",
Expand Down Expand Up @@ -4492,17 +4493,17 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"White mensural semiminima",
QT_TRANSLATE_NOOP("symUserNames", "Augmentation dot"),
"1024th note (semihemidemisemihemidemisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames","1024th note (semihemidemisemihemidemisemiquaver) stem up"),
QT_TRANSLATE_NOOP("symUserNames", "1024th note (semihemidemisemihemidemisemiquaver) stem up"),
"128th note (semihemidemisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames", "128th note (semihemidemisemiquaver) stem up"),
"16th note (semiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames", "16th note (semiquaver) stem up"),
"256th note (demisemihemidemisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames","256th note (demisemihemidemisemiquaver) stem up"),
QT_TRANSLATE_NOOP("symUserNames", "256th note (demisemihemidemisemiquaver) stem up"),
"32nd note (demisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames", "32nd note (demisemiquaver) stem up"),
"512th note (hemidemisemihemidemisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames","512th note (hemidemisemihemidemisemiquaver) stem up"),
QT_TRANSLATE_NOOP("symUserNames", "512th note (hemidemisemihemidemisemiquaver) stem up"),
"64th note (hemidemisemiquaver) stem down",
QT_TRANSLATE_NOOP("symUserNames", "64th note (hemidemisemiquaver) stem up"),
"Eighth note (quaver) stem down",
Expand Down Expand Up @@ -4947,7 +4948,6 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"Oblique straight line SW-NE",
"Oblique straight line tilted NW-SE",
"Oblique straight line tilted SW-NE",
QT_TRANSLATE_NOOP("symUserNames", "Short trill"),
"Oriscus",
"Pinc\u00e9 (Couperin)",
"Port de voix",
Expand Down Expand Up @@ -4985,6 +4985,7 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"Shake (Muffat)",
"Short oblique straight line NW-SE",
"Short oblique straight line SW-NE",
QT_TRANSLATE_NOOP("symUserNames", "Short trill"),
"Ornament top left concave stroke",
"Ornament top left convex stroke",
"Ornament top right concave stroke",
Expand Down
83 changes: 80 additions & 3 deletions mscore/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,16 +878,81 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"..#.#.."
};

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

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

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

QPixmap* startRepeatPixmap = new QPixmap(startRepeat);
QPixmap* endRepeatPixmap = new QPixmap(endRepeat);
QPixmap* endBarlinePixmap = new QPixmap(endBarline);
QPixmap* doubleBarlinePixmap = new QPixmap(doubleBarline);
QPixmap* reverseEndBarlinePixmap = new QPixmap(reverseEndBarline);
QPixmap* heavyBarlinePixmap = new QPixmap(heavyBarline);
QPixmap* doubleHeavyBarlinePixmap = new QPixmap(doubleHeavyBarline);

_barlines[BarLineType::START_REPEAT] = startRepeatPixmap;
_barlines[BarLineType::END_REPEAT] = endRepeatPixmap;
_barlines[BarLineType::END] = endBarlinePixmap;
_barlines[BarLineType::DOUBLE] = doubleBarlinePixmap;

_barlines[BarLineType::REVERSE_END] = reverseEndBarlinePixmap;
_barlines[BarLineType::HEAVY] = heavyBarlinePixmap;
_barlines[BarLineType::DOUBLE_HEAVY] = doubleHeavyBarlinePixmap;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1302,8 +1367,11 @@ void Timeline::barlineMeta(Segment* seg, int* stagger, int pos)
switch (barline->barLineType()) {
case BarLineType::START_REPEAT:
case BarLineType::END_REPEAT:
case BarLineType::DOUBLE:
case BarLineType::END:
case BarLineType::DOUBLE:
case BarLineType::REVERSE_END:
case BarLineType::HEAVY:
case BarLineType::DOUBLE_HEAVY:
repeatText = BarLine::userTypeName(barline->barLineType());
break;
case BarLineType::END_START_REPEAT:
Expand Down Expand Up @@ -1493,6 +1561,9 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
{ BarLine::userTypeName(BarLineType::END_REPEAT), BarLineType::END_REPEAT },
{ BarLine::userTypeName(BarLineType::END), BarLineType::END },
{ BarLine::userTypeName(BarLineType::DOUBLE), BarLineType::DOUBLE },
{ BarLine::userTypeName(BarLineType::REVERSE_END), BarLineType::REVERSE_END },
{ BarLine::userTypeName(BarLineType::HEAVY), BarLineType::HEAVY },
{ BarLine::userTypeName(BarLineType::DOUBLE_HEAVY), BarLineType::DOUBLE_HEAVY },
};

BarLineType barLineType = barLineTypes[metaText];
Expand All @@ -1516,6 +1587,9 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
if ((barLineType == BarLineType::END_REPEAT ||
barLineType == BarLineType::END ||
barLineType == BarLineType::DOUBLE ||
barLineType == BarLineType::REVERSE_END ||
barLineType == BarLineType::HEAVY ||
barLineType == BarLineType::DOUBLE_HEAVY ||
std::get<2>(_repeatInfo))
&& !_collapsedMeta) {
if (std::get<0>(_repeatInfo) > 0)
Expand Down Expand Up @@ -1876,8 +1950,11 @@ void Timeline::drawSelection()
BarLine* barline = toBarLine(element);
if (barline &&
(barline->barLineType() == BarLineType::END_REPEAT ||
barline->barLineType() == BarLineType::END ||
barline->barLineType() == BarLineType::DOUBLE ||
barline->barLineType() == BarLineType::END) &&
barline->barLineType() == BarLineType::REVERSE_END ||
barline->barLineType() == BarLineType::HEAVY ||
barline->barLineType() == BarLineType::DOUBLE_HEAVY) &&
measure != _score->lastMeasure()) {
if (measure->prevMeasure())
measure = measure->prevMeasure();
Expand Down

0 comments on commit 0053122

Please sign in to comment.