Skip to content

Commit

Permalink
Merge pull request #18530 from miiizen/18404-transpose-key-sig
Browse files Browse the repository at this point in the history
Transpose tool will only transpose initial key signature …
  • Loading branch information
cbjeukendrup authored Oct 30, 2023
2 parents c5a87cd + 341efb1 commit a2d9be1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ bool Score::transpose(TransposeMode mode, TransposeDirection direction, Key trKe
} else if (e->isKeySig() && trKeys && mode != TransposeMode::DIATONICALLY) {
KeySig* ks = toKeySig(e);
Fraction tick = segment->tick();
bool startKey = tick == s1->tick();
bool startKey = tick == s1->tick() && !isFirstSystemKeySig(ks);
bool addKey = ks->isChange();
if ((startKey || addKey) && !ks->isAtonal()) {
Staff* staff = ks->staff();
Expand Down
13 changes: 13 additions & 0 deletions src/engraving/dom/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "chord.h"
#include "chordrest.h"
#include "clef.h"
#include "keysig.h"
#include "measure.h"
#include "note.h"
#include "page.h"
Expand Down Expand Up @@ -1334,4 +1335,16 @@ String formatUniqueExcerptName(const String& baseName, const StringList& allExce

return result;
}

bool isFirstSystemKeySig(const KeySig* ks)
{
if (!ks) {
return false;
}
const System* sys = ks->measure()->system();
if (!sys) {
return false;
}
return ks->tick() == sys->firstMeasure()->tick();
}
}
5 changes: 4 additions & 1 deletion src/engraving/dom/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@

namespace mu::engraving {
class Chord;
class EngravingItem;
class KeySig;
class Note;
class Rest;
class Segment;
class System;
class Tuplet;
class EngravingItem;

enum class Key;

Expand Down Expand Up @@ -92,5 +93,7 @@ extern void collectChordsOverlappingRests(Segment* segment, staff_idx_t staffIdx
extern Interval ornamentIntervalToGeneralInterval(OrnamentInterval interval);

extern String formatUniqueExcerptName(const String& baseName, const StringList& allExcerptLowerNames);

extern bool isFirstSystemKeySig(const KeySig* ks);
} // namespace mu::engraving
#endif

0 comments on commit a2d9be1

Please sign in to comment.