Skip to content

Commit

Permalink
Fix #305555: add cut2 and cut3 time signatures to master palette
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz authored and vpereverzev committed Dec 14, 2020
1 parent d8fa6e6 commit a8f9cd3
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 13 deletions.
4 changes: 4 additions & 0 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,10 @@ void ExportMusicXml::timesig(TimeSig* tsig)
tagName += " symbol=\"common\"";
else if (st == TimeSigType::ALLA_BREVE)
tagName += " symbol=\"cut\"";
else if (st == TimeSigType::CUT_BACH)
tagName += " symbol=\"cut2\"";
else if (st == TimeSigType::CUT_TRIPLE)
tagName += " symbol=\"cut3\"";
if (!tsig->visible())
tagName += " print-object=\"no\"";
tagName += color2xml(tsig);
Expand Down
12 changes: 12 additions & 0 deletions importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,18 @@ static bool determineTimeSig(MxmlLogger* logger, const QXmlStreamReader* const x
btp = 4;
return true;
}
else if (beats == "2" && beatType == "2" && timeSymbol == "cut2") {
st = TimeSigType::CUT_BACH;
bts = 2;
btp = 2;
return true;
}
else if (beats == "9" && beatType == "8" && timeSymbol == "cut3") {
st = TimeSigType::CUT_TRIPLE;
bts = 9;
btp = 8;
return true;
}
else {
if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
logger->logError(QString("time symbol '%1' not recognized with beats=%2 and beat-type=%3")
Expand Down
12 changes: 12 additions & 0 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3744,6 +3744,18 @@ static bool determineTimeSig(const QString beats, const QString beatType, const
btp = 4;
return true;
}
else if (beats == "2" && beatType == "2" && timeSymbol == "cut2") {
st = TimeSigType::CUT_BACH;
bts = 2;
btp = 2;
return true;
}
else if (beats == "9" && beatType == "8" && timeSymbol == "cut3") {
st = TimeSigType::CUT_TRIPLE;
bts = 9;
btp = 8;
return true;
}
else {
if (!timeSymbol.isEmpty() && timeSymbol != "normal") {
qDebug("determineTimeSig: time symbol <%s> not recognized with beats=%s and beat-type=%s",
Expand Down
8 changes: 4 additions & 4 deletions libmscore/sym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5511,12 +5511,12 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"Control character for denominator digit",
"Control character for numerator digit",
"Time signature comma",
"Common time",
QT_TRANSLATE_NOOP("symUserNames", "Common time"),
"Reversed common time",
"Turned common time",
"Cut time (Bach)",
"Cut triple time (9/8)",
"Cut time",
QT_TRANSLATE_NOOP("symUserNames", "Cut time (Bach)"),
QT_TRANSLATE_NOOP("symUserNames", "Cut triple time (9/8)"),
QT_TRANSLATE_NOOP("symUserNames", "Cut time"),
"Reversed cut time",
"Turned cut time",
"Time signature equals",
Expand Down
24 changes: 22 additions & 2 deletions libmscore/timesig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ void TimeSig::layout()
ns.push_back(SymId::timeSigCutCommon);
ds.clear();
}
else if (sigType == TimeSigType::CUT_BACH) {
pz = QPointF(0.0, yoff);
setbbox(symBbox(SymId::timeSigCut2).translated(pz));
ns.clear();
ns.push_back(SymId::timeSigCut2);
ds.clear();
}
else if (sigType == TimeSigType::CUT_TRIPLE) {
pz = QPointF(0.0, yoff);
setbbox(symBbox(SymId::timeSigCut3).translated(pz));
ns.clear();
ns.push_back(SymId::timeSigCut3);
ds.clear();
}
else {
if (_numeratorString.isEmpty()) {
ns = toTimeSigString(_numeratorString.isEmpty() ? QString::number(_sig.numerator()) : _numeratorString);
Expand Down Expand Up @@ -567,10 +581,16 @@ QString TimeSig::accessibleInfo() const
QString timeSigString;
switch (timeSigType()) {
case TimeSigType::FOUR_FOUR:
timeSigString = QObject::tr("Common time");
timeSigString = qApp->translate("symUserNames", "Common time");
break;
case TimeSigType::ALLA_BREVE:
timeSigString = QObject::tr("Cut time");
timeSigString = qApp->translate("symUserNames", "Cut time");
break;
case TimeSigType::CUT_BACH:
timeSigString = qApp->translate("symUserNames", "Cut time (Bach)");
break;
case TimeSigType::CUT_TRIPLE:
timeSigString = qApp->translate("symUserNames", "Cut triple time (9/8)");
break;
default:
timeSigString = QObject::tr("%1/%2 time").arg(QString::number(numerator()), QString::number(denominator()));
Expand Down
2 changes: 2 additions & 0 deletions libmscore/timesig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ enum class TimeSigType : char {
NORMAL, // use sz/sn text
FOUR_FOUR, // common time (4/4)
ALLA_BREVE, // cut time (2/2)
CUT_BACH, // cut time (Bach)
CUT_TRIPLE, // cut triple time (9/8)
};

//---------------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions mscore/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1741,11 +1741,13 @@ PalettePanel* MuseScore::newTimePalettePanel()
{ 7, 8, TimeSigType::NORMAL, "7/8" },
{ 9, 8, TimeSigType::NORMAL, "9/8" },
{ 12, 8, TimeSigType::NORMAL, "12/8" },
{ 4, 4, TimeSigType::FOUR_FOUR, QT_TRANSLATE_NOOP("Palette", "4/4 common time") },
{ 2, 2, TimeSigType::ALLA_BREVE, QT_TRANSLATE_NOOP("Palette", "2/2 alla breve") },
{ 4, 4, TimeSigType::FOUR_FOUR, QT_TRANSLATE_NOOP("symUserNames", "Common time") },
{ 2, 2, TimeSigType::ALLA_BREVE, QT_TRANSLATE_NOOP("symUserNames", "Cut time") },
{ 2, 2, TimeSigType::NORMAL, "2/2" },
{ 3, 2, TimeSigType::NORMAL, "3/2" },
{ 4, 2, TimeSigType::NORMAL, "4/2" },
{ 2, 2, TimeSigType::CUT_BACH, QT_TRANSLATE_NOOP("symUserNames", "Cut time (Bach)") },
{ 9, 8, TimeSigType::CUT_TRIPLE, QT_TRANSLATE_NOOP("symUserNames", "Cut triple time (9/8)") },
};

PalettePanel* sp = new PalettePanel(PalettePanel::Type::TimeSig);
Expand Down
8 changes: 7 additions & 1 deletion mscore/timesigproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TimeSigProperties::TimeSigProperties(TimeSig* t, QWidget* parent)
zNominal->setEnabled(false);
nNominal->setEnabled(false);

// TODO: fix http://musescore.org/en/node/42341
// TODO: fix https://musescore.org/en/node/42341
// for now, editing of actual (local) time sig is disabled in dialog
// but more importantly, the dialog should make it clear that this is "local" change only
// and not normally the right way to add 7/4 to a score
Expand All @@ -82,6 +82,12 @@ TimeSigProperties::TimeSigProperties(TimeSig* t, QWidget* parent)
case TimeSigType::ALLA_BREVE:
allaBreveButton->setChecked(true);
break;
case TimeSigType::CUT_BACH:
// cutBachButton->setChecked(true);
// break;
case TimeSigType::CUT_TRIPLE:
// cutTripleButton->setChecked(true);
break;
}

// set ID's of other symbols
Expand Down
10 changes: 10 additions & 0 deletions mtest/libmscore/timesig/tst_timesig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,16 @@ void TestTimesig::timesig10()
ts2->setSig(Fraction(2, 2), TimeSigType::NORMAL);
TimeSig* ts3 = new TimeSig(score);
ts3->setSig(Fraction(4, 4), TimeSigType::FOUR_FOUR);
//TimeSig* ts4 = new TimeSig(score);
//ts4->setSig(Fraction(2, 2), TimeSigType::CUT_BACH);

score->cmdAddTimeSig(m2, 0, ts2, false);
m2 = score->firstMeasure()->nextMeasure();
score->cmdAddTimeSig(m2, 0, ts3, false);
//m2 = score->firstMeasure()->nextMeasure();
//score->cmdAddTimeSig(m2, 0, ts4, false);
//m2 = score->firstMeasure()->nextMeasure();
//score->cmdAddTimeSig(m2, 0, ts5, false);

score->doLayout();
QVERIFY(saveCompareScore(score, "timesig-10.mscx", DIR + "timesig-10-ref.mscx"));
Expand All @@ -304,11 +310,15 @@ void TestTimesig::timesig_78216()
Measure* m1 = score->firstMeasure();
Measure* m2 = m1->nextMeasure();
Measure* m3 = m2->nextMeasure();
//Measure* m4 = m3->nextMeasure();
//Measure* m5 = m4->nextMeasure();

// verify no timesig exists in segment of final tick of m1, m2, m3
QVERIFY2(!m1->findSegment(SegmentType::TimeSig, m1->endTick()), "Should be no timesig at the end of measure 1.");
QVERIFY2(!m2->findSegment(SegmentType::TimeSig, m2->endTick()), "Should be no timesig at the end of measure 2.");
QVERIFY2(!m3->findSegment(SegmentType::TimeSig, m3->endTick()), "Should be no timesig at the end of measure 3.");
//QVERIFY2(!m4->findSegment(SegmentType::TimeSig, m4->endTick()), "Should be no timesig at the end of measure 4.");
//QVERIFY2(!m5->findSegment(SegmentType::TimeSig, m5->endTick()), "Should be no timesig at the end of measure 5.");
delete score;
}

Expand Down
4 changes: 2 additions & 2 deletions share/workspaces/Advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@
<sigD>8</sigD>
</TimeSig>
</Cell>
<Cell name="4/4 common time">
<Cell name="Common time">
<staff>1</staff>
<TimeSig>
<subtype>1</subtype>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
</Cell>
<Cell name="2/2 alla breve">
<Cell name="Cut time">
<staff>1</staff>
<TimeSig>
<subtype>2</subtype>
Expand Down
4 changes: 2 additions & 2 deletions share/workspaces/Basic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@
<sigD>8</sigD>
</TimeSig>
</Cell>
<Cell name="4/4 common time">
<Cell name="Common time">
<staff>1</staff>
<TimeSig>
<subtype>1</subtype>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
</Cell>
<Cell name="2/2 alla breve">
<Cell name="Cut time">
<staff>1</staff>
<TimeSig>
<subtype>2</subtype>
Expand Down

0 comments on commit a8f9cd3

Please sign in to comment.