Skip to content

Commit

Permalink
adding revers end barline and (single) heavy barline too
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed May 19, 2020
1 parent 445ea48 commit a0fbc59
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 15 deletions.
7 changes: 7 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,8 @@ 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:
Expand Down Expand Up @@ -1699,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 @@ -1711,6 +1715,9 @@ 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;
Expand Down
4 changes: 4 additions & 0 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 @@ -3130,6 +3132,8 @@ static bool determineBarLineType(const QString& barStyle, const QString& repeat,
*/
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
30 changes: 29 additions & 1 deletion libmscore/barline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ static void undoChangeBarLineType(BarLine* bl, BarLineType barType, bool allStav
case BarLineType::DOUBLE:
case BarLineType::BROKEN:
case BarLineType::DOTTED:
case BarLineType::REVERSE_END:
case BarLineType::HEAVY:
case BarLineType::DOUBLE_HEAVY: {
Segment* segment = bl->segment();
SegmentType segmentType = segment->segmentType();
Expand Down Expand Up @@ -203,7 +205,9 @@ 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" },
{ BarLineType::REVERSE_END, QT_TRANSLATE_NOOP("Palette", "Reverse Final barline"), "reverse-end" },
{ BarLineType::HEAVY, QT_TRANSLATE_NOOP("Palette", "Heavy barline"), "heavy" },
{ BarLineType::DOUBLE_HEAVY, QT_TRANSLATE_NOOP("Palette", "Heavy double barline"), "double-heavy" },
};

//---------------------------------------------------------
Expand Down Expand Up @@ -578,6 +582,26 @@ 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));
Expand Down Expand Up @@ -1221,6 +1245,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 @@ -1229,6 +1254,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: 5 additions & 2 deletions libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +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,
DASHED = BROKEN,
END = 0x20,
END_START_REPEAT = 0x40,
DOTTED = 0x80,
DOUBLE_HEAVY = 0x100,
REVERSE_END = 0x100,
HEAVY = 0x200,
DOUBLE_HEAVY = 0x400,
};

constexpr BarLineType operator| (BarLineType t1, BarLineType t2) {
Expand Down
73 changes: 61 additions & 12 deletions mscore/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
std::tuple<int, qreal, Element*, Element*, bool> ri(0, 0, nullptr, nullptr, false);
_repeatInfo = ri;

static const char* leftRepeat[] = {
static const char* startRepeat[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand All @@ -818,7 +818,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"##.#..."
};

static const char* rightRepeat[] = {
static const char* endRepeat[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand All @@ -838,7 +838,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"...#.##"
};

static const char* finalBarline[] = {
static const char* endBarline[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand Down Expand Up @@ -878,6 +878,45 @@ 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",
Expand All @@ -898,16 +937,20 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
".##.##."
};

QPixmap* leftRepeatPixmap = new QPixmap(leftRepeat);
QPixmap* rightRepeatPixmap = new QPixmap(rightRepeat);
QPixmap* finalBarlinePixmap = new QPixmap(finalBarline);
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[BarLine::userTypeName(BarLineType::START_REPEAT)] = leftRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END_REPEAT)] = rightRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END)] = finalBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::START_REPEAT)] = startRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END_REPEAT)] = endRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END)] = endBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::DOUBLE)] = doubleBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::REVERSE_END)] = reverseEndBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::HEAVY)] = heavyBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::DOUBLE_HEAVY)] = doubleHeavyBarlinePixmap;
}

Expand Down Expand Up @@ -1279,12 +1322,14 @@ void Timeline::barlineMeta(Segment* seg, int* stagger, int pos)
case BarLineType::START_REPEAT:
case BarLineType::END_REPEAT:
case BarLineType::DOUBLE:
case BarLineType::DOUBLE_HEAVY:
case BarLineType::END:
case BarLineType::REVERSE_END:
case BarLineType::HEAVY:
case BarLineType::DOUBLE_HEAVY:
repeatText = BarLine::userTypeName(barline->barLineType());
break;
case BarLineType::END_START_REPEAT: // actually an end repeat followed by a start repeat, so nothing needs to be done here
break;
case BarLineType::END_START_REPEAT:
// actually an end repeat followed by a start repeat, so nothing needs to be done here
default:
break;
}
Expand Down Expand Up @@ -1482,6 +1527,8 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
if ((metaText == BarLine::userTypeName(BarLineType::END_REPEAT) ||
metaText == BarLine::userTypeName(BarLineType::END) ||
metaText == BarLine::userTypeName(BarLineType::DOUBLE) ||
metaText == BarLine::userTypeName(BarLineType::REVERSE_END) ||
//metaText == BarLine::userTypeName(BarLineType::HEAVY) ||
metaText == BarLine::userTypeName(BarLineType::DOUBLE_HEAVY) ||
std::get<2>(_repeatInfo))
&& !_collapsedMeta) {
Expand Down Expand Up @@ -1827,6 +1874,8 @@ void Timeline::drawSelection()
if (barline &&
(barline->barLineType() == BarLineType::END_REPEAT ||
barline->barLineType() == BarLineType::DOUBLE ||
barline->barLineType() == BarLineType::REVERSE_END ||
barline->barLineType() == BarLineType::HEAVY ||
barline->barLineType() == BarLineType::DOUBLE_HEAVY ||
barline->barLineType() == BarLineType::END) &&
measure != _score->lastMeasure()) {
Expand Down

0 comments on commit a0fbc59

Please sign in to comment.