Skip to content

Commit

Permalink
update tpcs if "flipped keysig" is added, or removed
Browse files Browse the repository at this point in the history
  • Loading branch information
sammik committed Jul 9, 2023
1 parent e44addf commit f1f5170
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/engraving/libmscore/edit.cpp
Expand Up @@ -4980,6 +4980,7 @@ void Score::undoChangeFretting(Note* note, int pitch, int string, int fret, int
void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent key)
{
KeySig* lks = 0;
bool needsUpdate = false;

for (Staff* staff : ostaff->staffList()) {
if (staff->isDrumStaff(tick)) {
Expand All @@ -5000,12 +5001,14 @@ void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent ke
KeySig* ks = toKeySig(s->element(track));

Interval interval = staff->part()->instrument(tick)->transpose();
Interval oldStaffInterval = staff->transpose(tick);
KeySigEvent nkey = key;
bool concertPitch = score->style().styleB(Sid::concertPitch);

if (interval.chromatic && !concertPitch && !nkey.isAtonal()) {
interval.flip();
nkey.setKey(transposeKey(key.concertKey(), interval, staff->part()->preferSharpFlat()));
interval.flip();
}

updateInstrumentChangeTranspositions(key, staff, tick);
Expand All @@ -5024,6 +5027,13 @@ void Score::undoChangeKeySig(Staff* ostaff, const Fraction& tick, KeySigEvent ke
lks = nks;
}
}
if (interval != staff->transpose(tick) || interval != oldStaffInterval) {
needsUpdate = true;
}
}
if (needsUpdate) {
Fraction tickEnd = Fraction::fromTicks(ostaff->keyList()->nextKeyTick(tick.ticks()));
transpositionChanged(ostaff->part(), ostaff->transpose(tick), tick, tickEnd);
}
}

Expand Down

0 comments on commit f1f5170

Please sign in to comment.