Skip to content

Commit

Permalink
Move isFirstSystemKeySig to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Oct 23, 2023
1 parent 3631bf4 commit 803e646
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
9 changes: 0 additions & 9 deletions src/engraving/dom/keysig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ bool KeySig::isChange() const
return staff()->currentKeyTick(keyTick) == keyTick;
}

bool KeySig::isFirstSystemKeySig()
{
System* sys = measure()->system();
if (!sys) {
return false;
}
return tick().ticks() == sys->firstMeasure()->tick().ticks();
}

//---------------------------------------------------------
// changeKeySigEvent
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/engraving/dom/keysig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class KeySig final : public EngravingItem
bool isAtonal() const { return m_sig.isAtonal(); }
bool isChange() const;
const KeySigEvent& keySigEvent() const { return m_sig; }
bool isFirstSystemKeySig();
bool operator==(const KeySig&) const;
void changeKeySigEvent(const KeySigEvent&);
void setKeySigEvent(const KeySigEvent& e) { m_sig = e; }
Expand Down
3 changes: 2 additions & 1 deletion src/engraving/dom/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "segment.h"
#include "staff.h"
#include "stafftype.h"
#include "system.h"
#include "undo.h"
#include "utils.h"

Expand Down Expand Up @@ -489,7 +490,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() && !ks->isFirstSystemKeySig();
bool startKey = tick == s1->tick() && !isFirstSystemKeySig(ks);
bool addKey = ks->isChange();
if ((startKey || addKey) && !ks->isAtonal()) {
Staff* staff = ks->staff();
Expand Down
12 changes: 12 additions & 0 deletions src/engraving/dom/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,4 +1334,16 @@ String formatUniqueExcerptName(const String& baseName, const StringList& allExce

return result;
}

bool isFirstSystemKeySig(const KeySig* ks)
{
if (!ks) {
return false;
}
System* sys = ks->measure()->system();
if (!sys) {
return false;
}
return ks->tick().ticks() == sys->firstMeasure()->tick().ticks();
}
}
3 changes: 3 additions & 0 deletions src/engraving/dom/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "types/types.h"

#include "interval.h"
#include "keysig.h"

#include "draw/types/geometry.h"

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 803e646

Please sign in to comment.