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

Fix continuation courtesy layout #26565

Merged
merged 2 commits into from
Feb 18, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/engraving/dom/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void Measure::add(EngravingItem* e)
case ElementType::MARKER:
if (e && (e->isJump() || muse::contains(Marker::RIGHT_MARKERS, toMarker(e)->markerType()))) {
// "To coda" markings act like jumps
setRepeatJump(true);
setProperty(Pid::REPEAT_JUMP, true);
}
el().push_back(e);
break;
Expand Down Expand Up @@ -943,7 +943,7 @@ void Measure::remove(EngravingItem* e)
break;

case ElementType::JUMP:
setRepeatJump(false);
setProperty(Pid::REPEAT_JUMP, false);
// fall through
case ElementType::MARKER:
case ElementType::HBOX:
Expand Down
24 changes: 15 additions & 9 deletions src/engraving/rendering/score/measurelayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2034,15 +2034,21 @@ Parenthesis* MeasureLayout::findOrCreateParenthesis(Segment* segment, const Dire
return paren;
}

static void calcParenTopBottom(Parenthesis* item, double& top, double& bottom)
static void calcParenTopBottom(Parenthesis* item, double& top, double& bottom, LayoutContext& ctx)
{
Segment* seg = item->segment();
EngravingItem* el = seg->element(item->track());
const double spatium = item->spatium();
if (el) {
top = std::min(top, el->shape().top() + el->pos().y() + spatium / 4);
bottom = std::max(bottom, el->shape().bottom() + el->pos().y() - spatium / 4);
if (!el) {
return;
}

if (!el->ldata()->isValid()) {
TLayout::layoutItem(el, ctx);
}

top = std::min(top, el->shape().top() + el->pos().y() + spatium / 4);
bottom = std::max(bottom, el->shape().bottom() + el->pos().y() - spatium / 4);
}

void MeasureLayout::addRepeatCourtesyParentheses(Measure* m, const bool continuation, LayoutContext& ctx)
Expand All @@ -2051,7 +2057,7 @@ void MeasureLayout::addRepeatCourtesyParentheses(Measure* m, const bool continua
const SegmentType ksSegType = continuation ? SegmentType::KeySigStartRepeatAnnounce : SegmentType::KeySigRepeatAnnounce;
const SegmentType clefSegType = continuation ? SegmentType::ClefStartRepeatAnnounce : SegmentType::ClefRepeatAnnounce;

const Fraction sigTick = continuation ? Fraction(0, 0) : m->ticks();
const Fraction sigTick = continuation ? Fraction(0, 1) : m->ticks();

auto segShouldHaveParenthesis = [&](const Segment* seg, const track_idx_t track) -> bool {
const EngravingItem* el = seg ? seg->element(track) : nullptr;
Expand Down Expand Up @@ -2081,8 +2087,8 @@ void MeasureLayout::addRepeatCourtesyParentheses(Measure* m, const bool continua
!= TimeSigPlacement::NORMAL;
if ((ctx.conf().styleB(Sid::smallParens) || needsBigTimeSigAdjust) && leftParen && rightParen) {
const double spatium = leftParen->spatium();
calcParenTopBottom(leftParen, top, bottom);
calcParenTopBottom(rightParen, top, bottom);
calcParenTopBottom(leftParen, top, bottom, ctx);
calcParenTopBottom(rightParen, top, bottom, ctx);

double height = bottom - top;

Expand Down Expand Up @@ -2182,7 +2188,7 @@ void MeasureLayout::removeRepeatCourtesyParenthesesMeasure(Measure* m, const boo
const SegmentType ksSegType = continuation ? SegmentType::KeySigStartRepeatAnnounce : SegmentType::KeySigRepeatAnnounce;
const SegmentType clefSegType = continuation ? SegmentType::ClefStartRepeatAnnounce : SegmentType::ClefRepeatAnnounce;

const Fraction sigTick = continuation ? Fraction(0, 0) : m->ticks();
const Fraction sigTick = continuation ? Fraction(0, 1) : m->ticks();

Segment* clefSeg = m->findSegmentR(clefSegType, sigTick);
Segment* ksSeg = m->findSegmentR(ksSegType, sigTick);
Expand Down Expand Up @@ -2471,7 +2477,7 @@ void MeasureLayout::addSystemHeader(Measure* m, bool isFirstSystem, LayoutContex
const System* sys = searchMeasure->system();
if (isFirstClef && searchMeasure->tick() >= clefTick) {
// Need to check previous measure for clef change if one not found in this measure
Segment* clefSeg = searchMeasure->findFirstR(SegmentType::Clef | SegmentType::HeaderClef, Fraction(0, 0));
Segment* clefSeg = searchMeasure->findFirstR(SegmentType::Clef | SegmentType::HeaderClef, Fraction(0, 1));
Measure* prevMeas = searchMeasure->prevMeasure();
if (prevMeas && !clefSeg) {
clefSeg = prevMeas->findSegment(SegmentType::Clef, m->tick());
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4514,7 +4514,7 @@ void TLayout::layoutParenthesis(Parenthesis* item, LayoutContext& ctx)

Parenthesis::LayoutData* ldata = item->mutldata();
ldata->setPos(PointF());
ldata->clearShape();
ldata->reset();
ldata->path.reset();

const Staff* staff = item->staff();
Expand Down
Loading