Skip to content

Commit

Permalink
Fix #305613: Add reverse end, (single) heavy and heavy double barline
Browse files Browse the repository at this point in the history
Use translated names of barlines in timeline.
Change to use SMuFL names for barlines so we use the same strings and
translations in basic and advanced workspace palettes, master symbols
palette (untranslated before), inspector and timeline.

Previous versions won't sdhow them and also loose them on save
  • Loading branch information
Jojo-Schmitz committed May 19, 2020
1 parent f978f1d commit 00e8e92
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 70 deletions.
12 changes: 12 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,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 @@ -1623,6 +1624,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 @@ -1697,6 +1702,7 @@ void ExportMusicXml::barlineRight(const Measure* const m)
_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 @@ -1709,6 +1715,12 @@ void ExportMusicXml::barlineRight(const Measure* const m)
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
8 changes: 6 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,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 @@ -3127,9 +3129,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
64 changes: 54 additions & 10 deletions 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 @@ -194,14 +197,17 @@ class BarLineEditData : public ElementEditData {
//---------------------------------------------------------

const std::vector<BarLineTableItem> BarLine::barLineTable {
{ BarLineType::NORMAL, QT_TRANSLATE_NOOP("Palette", "Normal barline"), "normal" },
{ BarLineType::DOUBLE, QT_TRANSLATE_NOOP("Palette", "Double barline"), "double" },
{ BarLineType::START_REPEAT, QT_TRANSLATE_NOOP("Palette", "Start repeat barline"), "start-repeat" },
{ BarLineType::END_REPEAT, QT_TRANSLATE_NOOP("Palette", "End repeat barline"), "end-repeat" },
{ BarLineType::BROKEN, QT_TRANSLATE_NOOP("Palette", "Dashed barline"), "dashed" },
{ 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::NORMAL, Sym::symUserNames[int(SymId::barlineSingle)], "normal" },
{ BarLineType::DOUBLE, Sym::symUserNames[int(SymId::barlineDouble)], "double" },
{ BarLineType::START_REPEAT, Sym::symUserNames[int(SymId::repeatLeft)], "start-repeat" },
{ BarLineType::END_REPEAT, Sym::symUserNames[int(SymId::repeatRight)], "end-repeat" },
{ BarLineType::BROKEN, Sym::symUserNames[int(SymId::barlineDashed)], "dashed" },
{ 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 All @@ -223,7 +229,7 @@ QString BarLine::userTypeName(BarLineType t)
{
for (const auto& i : barLineTable) {
if (i.type == t)
return qApp->translate("Palette", i.userName);
return qApp->translate("symUserNames", i.userName);
}
return QString();
}
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,10 @@ 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 +1248,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 +1257,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
7 changes: 6 additions & 1 deletion libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,18 @@ const int STAFF_GROUP_MAX = int(StaffGroup::TAB) + 1; // out of enum to avo

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

constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
Expand Down
26 changes: 13 additions & 13 deletions libmscore/sym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3274,16 +3274,16 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Unstress above"),
QT_TRANSLATE_NOOP("symUserNames", "Unstress below"),
"Augmentation dot",
"Dashed barline",
"Dotted barline",
"Double barline",
"Final barline",
"Heavy barline",
"Heavy double barline",
"Reverse final barline",
"Short barline",
"Single barline",
"Tick barline",
QT_TRANSLATE_NOOP("symUserNames", "Dashed barline"),
QT_TRANSLATE_NOOP("symUserNames", "Dotted barline"),
QT_TRANSLATE_NOOP("symUserNames", "Double 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"),
"Accel./rit. beam 1 (widest)",
"Accel./rit. beam 10",
"Accel./rit. beam 11",
Expand Down Expand Up @@ -4908,9 +4908,9 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Repeat last four bars"),
"Single repeat dot",
"Repeat dots",
"Left (start) repeat sign",
"Right (end) repeat sign",
"Right and left repeat sign",
QT_TRANSLATE_NOOP("symUserNames", "Left (start) repeat sign"),
QT_TRANSLATE_NOOP("symUserNames", "Right (end) repeat sign"),
QT_TRANSLATE_NOOP("symUserNames", "Right and left repeat sign"),
"1024th rest",
QT_TRANSLATE_NOOP("symUserNames", "128th (semihemidemisemiquaver) rest"),
QT_TRANSLATE_NOOP("symUserNames", "16th (semiquaver) rest"),
Expand Down
2 changes: 1 addition & 1 deletion mscore/inspector/inspectorBarline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ InspectorBarLine::InspectorBarLine(QWidget* parent)
b.setupUi(addWidget());

for (auto i : BarLine::barLineTable)
b.type->addItem(qApp->translate("Palette", i.userName), int(i.type));
b.type->addItem(qApp->translate("symUserName", i.userName), int(i.type));

const std::vector<InspectorItem> il = {
{ Pid::LEADING_SPACE, 1, s.leadingSpace, s.resetLeadingSpace },
Expand Down
Loading

0 comments on commit 00e8e92

Please sign in to comment.