Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more flexibility for Spanners to compute start and end segment #18904

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/engraving/dom/excerpt.cpp
Expand Up @@ -1504,6 +1504,12 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star
}
}
}
for (Segment& seg : nm->segments()) {
seg.checkEmpty();
if (seg.empty()) {
score->undoRemoveElement(&seg);
}
}
}

for (auto i : oscore->spanner()) {
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/score.h
Expand Up @@ -565,7 +565,7 @@ class Score : public EngravingObject
Segment* tick2segmentMM(const Fraction& tick, bool first, SegmentType st) const;
Segment* tick2segmentMM(const Fraction& tick) const;
Segment* tick2segmentMM(const Fraction& tick, bool first) const;
Segment* tick2leftSegment(const Fraction& tick, bool useMMrest = false) const;
Segment* tick2leftSegment(const Fraction& tick, bool useMMrest = false, bool anySegmentType = false) const;
Segment* tick2rightSegment(const Fraction& tick, bool useMMrest = false) const;
Segment* tick2leftSegmentMM(const Fraction& tick) { return tick2leftSegment(tick, /* useMMRest */ true); }

Expand Down
8 changes: 6 additions & 2 deletions src/engraving/dom/spanner.cpp
Expand Up @@ -987,7 +987,11 @@ ChordRest* Spanner::findEndCR() const
Segment* Spanner::startSegment() const
{
assert(score() != NULL);
return score()->tick2rightSegment(tick(), style().styleB(Sid::createMultiMeasureRests));
Segment* rightSegment = score()->tick2rightSegment(tick(), style().styleB(Sid::createMultiMeasureRests));
if (rightSegment && rightSegment->tick() < tick2()) {
return rightSegment;
}
return score()->tick2leftSegment(tick(), style().styleB(Sid::createMultiMeasureRests));
}

//---------------------------------------------------------
Expand All @@ -996,7 +1000,7 @@ Segment* Spanner::startSegment() const

Segment* Spanner::endSegment() const
{
return score()->tick2leftSegment(tick2(), style().styleB(Sid::createMultiMeasureRests));
return score()->tick2leftSegment(tick2(), style().styleB(Sid::createMultiMeasureRests), systemFlag());
}

//---------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions src/engraving/dom/utils.cpp
Expand Up @@ -205,16 +205,18 @@ Segment* Score::tick2segment(const Fraction& tick, bool first) const
/// the first segment *before* this tick position
//---------------------------------------------------------

Segment* Score::tick2leftSegment(const Fraction& tick, bool useMMrest) const
Segment* Score::tick2leftSegment(const Fraction& tick, bool useMMrest, bool anySegmentType) const
{
Measure* m = useMMrest ? tick2measureMM(tick) : tick2measure(tick);
if (m == 0) {
LOGD("tick2leftSegment(): not found tick %d", tick.ticks());
return 0;
}

// loop over all segments
SegmentType segmentType = anySegmentType ? SegmentType::All : SegmentType::ChordRest;
Segment* ps = 0;
for (Segment* s = m->first(SegmentType::ChordRest); s; s = s->next(SegmentType::ChordRest)) {
for (Segment* s = m->first(segmentType); s; s = s->next(segmentType)) {
if (tick < s->tick()) {
return ps;
} else if (tick == s->tick()) {
Expand Down