Skip to content

Commit

Permalink
Merge pull request #24505 from miiizen/copy-clef
Browse files Browse the repository at this point in the history
Add clefs to parts & linked staves when copying
  • Loading branch information
mike-spa authored Sep 16, 2024
2 parents 98e2451 + b586468 commit f5419f2
Show file tree
Hide file tree
Showing 10 changed files with 2,356 additions and 122 deletions.
11 changes: 7 additions & 4 deletions src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6031,7 +6031,8 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
&& et != ElementType::FERMATA
&& et != ElementType::HARMONY
&& et != ElementType::HARP_DIAGRAM
&& et != ElementType::FIGURED_BASS)
&& et != ElementType::FIGURED_BASS
&& et != ElementType::CLEF)
) {
doUndoAddElement(element);
return;
Expand Down Expand Up @@ -6073,7 +6074,8 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
ElementType::VIBRATO,
ElementType::TEXTLINE,
ElementType::PEDAL,
ElementType::LYRICS
ElementType::LYRICS,
ElementType::CLEF
};

track_idx_t linkedTrack = ostaff->getLinkedTrackInStaff(staff, strack);
Expand Down Expand Up @@ -6211,13 +6213,14 @@ void Score::undoAddElement(EngravingItem* element, bool addToLinkedStaves, bool
|| element->isFermata()
|| element->isHarmony()
|| element->isHarpPedalDiagram()
|| element->isFiguredBass()) {
|| element->isFiguredBass()
|| element->isClef()) {
Segment* segment
= element->explicitParent()->isFretDiagram() ? toSegment(element->explicitParent()->explicitParent()) : toSegment(
element->explicitParent());
Fraction tick = segment->tick();
Measure* m = score->tick2measure(tick);
if ((segment->segmentType() == SegmentType::EndBarLine) && (m->tick() == tick)) {
if ((segment->segmentType() & (SegmentType::EndBarLine | SegmentType::Clef)) && (m->tick() == tick)) {
m = m->prevMeasure();
}
Segment* seg = m->undoGetSegment(segment->segmentType(), tick);
Expand Down
14 changes: 7 additions & 7 deletions src/engraving/dom/masterscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ MeasureBase* MasterScore::insertMeasure(MeasureBase* beforeMeasure, const Insert
TimeSig* nts = Factory::copyTimeSig(*ts);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::TimeSig, Fraction(0, 1));
nts->setParent(s);
undoAddElement(nts);
doUndoAddElement(nts);
}
for (KeySig* ks : keySigList) {
KeySig* nks = Factory::copyKeySig(*ks);
Expand All @@ -734,39 +734,39 @@ MeasureBase* MasterScore::insertMeasure(MeasureBase* beforeMeasure, const Insert
if (!nks->isAtonal()) {
nks->setKey(nks->concertKey()); // to set correct (transposing) key
}
undoAddElement(nks);
doUndoAddElement(nks);
}
for (Clef* clef : initClefList) {
Clef* nClef = Factory::copyClef(*clef);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::HeaderClef, Fraction(0, 1));
s->setHeader(true);
nClef->setParent(s);
undoAddElement(nClef);
doUndoAddElement(nClef);
}
for (Clef* clef : afterBarlineClefs) {
Clef* nClef = Factory::copyClef(*clef);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::Clef, Fraction(0, 1));
s->setHeader(true);
nClef->setParent(s);
undoAddElement(nClef);
doUndoAddElement(nClef);
}
for (Clef* clef : previousClefList) {
Clef* nClef = Factory::copyClef(*clef);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::Clef, newMeasure->ticks());
nClef->setParent(s);
undoAddElement(nClef);
doUndoAddElement(nClef);
}
for (Clef* clef : specialCaseClefs) {
Clef* nClef = Factory::copyClef(*clef);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::Clef, newMeasure->ticks());
nClef->setParent(s);
undoAddElement(nClef);
doUndoAddElement(nClef);
}
for (BarLine* barLine : previousBarLinesList) {
BarLine* nBarLine = Factory::copyBarLine(*barLine);
Segment* s = newMeasure->undoGetSegmentR(SegmentType::EndBarLine, newMeasure->ticks());
nBarLine->setParent(s);
undoAddElement(nBarLine);
doUndoAddElement(nBarLine);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/engraving/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ set(MODULE_TEST_SRC
${CMAKE_CURRENT_LIST_DIR}/utils/scorerw.h
${CMAKE_CURRENT_LIST_DIR}/utils/scorecomp.cpp
${CMAKE_CURRENT_LIST_DIR}/utils/scorecomp.h
${CMAKE_CURRENT_LIST_DIR}/utils/testutils.cpp
${CMAKE_CURRENT_LIST_DIR}/utils/testutils.h

${CMAKE_CURRENT_LIST_DIR}/barline_tests.cpp
${CMAKE_CURRENT_LIST_DIR}/beam_tests.cpp
Expand Down
Loading

0 comments on commit f5419f2

Please sign in to comment.