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

Port PRs to 4.5 #26756

Merged
merged 11 commits into from
Feb 26, 2025
4 changes: 2 additions & 2 deletions src/engraving/dom/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ bool ChordRest::hasFollowingJumpItem() const

const Marker* marker = toMarker(e);

if (muse::contains(Marker::RIGHT_MARKERS, marker->markerType())) {
if (marker->isRightMarker()) {
return true;
}
}
Expand Down Expand Up @@ -1373,7 +1373,7 @@ bool ChordRest::hasPrecedingJumpItem() const
}

const Marker* marker = toMarker(e);
if (muse::contains(Marker::RIGHT_MARKERS, marker->markerType())) {
if (marker->isRightMarker()) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ void Score::cmdRemoveTimeSig(TimeSig* ts)
//
// we cannot remove a courtesy time signature
//
if (m->tick() != s->tick()) {
if (s->isCourtesySegment()) {
return;
}
Fraction tick = m->tick();
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Marker final : public TextBase
|| m_markerType == MarkerType::DA_DBLCODA;
}

inline bool isRightMarker() const { return muse::contains(Marker::RIGHT_MARKERS, m_markerType); }

Marker* clone() const override { return new Marker(*this); }

int subtype() const override { return int(m_markerType); }
Expand Down
7 changes: 4 additions & 3 deletions src/engraving/dom/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ void Measure::add(EngravingItem* e)
break;
case ElementType::JUMP:
case ElementType::MARKER:
if (e && (e->isJump() || muse::contains(Marker::RIGHT_MARKERS, toMarker(e)->markerType()))) {
if (e && (e->isJump() || (e->isMarker() && toMarker(e)->isRightMarker()))) {
// "To coda" markings act like jumps
setProperty(Pid::REPEAT_JUMP, true);
}
Expand Down Expand Up @@ -943,9 +943,10 @@ void Measure::remove(EngravingItem* e)
break;

case ElementType::JUMP:
setProperty(Pid::REPEAT_JUMP, false);
// fall through
case ElementType::MARKER:
if (e->isJump() || (e->isMarker() && toMarker(e)->isRightMarker())) {
setProperty(Pid::REPEAT_JUMP, false);
}
case ElementType::HBOX:
if (!el().remove(e)) {
LOGD("Measure(%p)::remove(%s,%p) not found", this, e->typeName(), e);
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/tiejumppointlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ String TieJumpPoint::precedingJumpItemName() const
}

const Marker* marker = toMarker(e);
if (muse::contains(Marker::RIGHT_MARKERS, marker->markerType())) {
if (marker->isRightMarker()) {
continue;
}

Expand Down
181 changes: 139 additions & 42 deletions src/engraving/rendering/score/measurelayout.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/engraving/rendering/score/measurelayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class MeasureLayout
static void addRepeatCourtesyParentheses(Measure* m, const bool continuation, LayoutContext& ctx);
static void placeParentheses(const Segment* segment, track_idx_t trackIdx, LayoutContext& ctx);
static void addRepeatCourtesies(Measure* m, LayoutContext& ctx);
static void removeRepeatCourtesies(Measure* m);
static void addRepeatContinuationCourtesies(Measure* m, LayoutContext& ctx);
static void removeRepeatContinuationCourtesies(Measure* m);
};
}
16 changes: 12 additions & 4 deletions src/engraving/rendering/score/modifydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,13 @@ void ModifyDom::sortMeasureSegments(Measure* measure, LayoutContext& ctx)
return ClefToBarlinePosition::AUTO;
};

Measure* nextMeasure = measure->nextMeasure();
MeasureBase* nextMb = measure->next();

if (!nextMb || !nextMb->isMeasure()) {
return;
}

Measure* nextMeasure = toMeasure(nextMb);

const bool sigsShouldBeInThisMeasure = ((measure->repeatEnd() && ctx.conf().styleB(Sid::changesBeforeBarlineRepeats))
|| (measure->repeatJump() && ctx.conf().styleB(Sid::changesBeforeBarlineOtherJumps)));
Expand Down Expand Up @@ -308,7 +314,8 @@ void ModifyDom::sortMeasureSegments(Measure* measure, LayoutContext& ctx)
}

// Move key sigs and time sigs at the end of this measure into the next measure
if ((seg.isKeySigType() || seg.isTimeSigType()) && (!sigsShouldBeInThisMeasure || !changeAppliesToRepeatAndContinuation(seg))) {
if ((seg.isKeySigType() || seg.isTimeSigType()) && !seg.header() && !seg.trailer()
&& (!sigsShouldBeInThisMeasure || !changeAppliesToRepeatAndContinuation(seg))) {
segsToMoveToNextMeasure.push_back(&seg);
}
}
Expand Down Expand Up @@ -352,7 +359,8 @@ void ModifyDom::sortMeasureSegments(Measure* measure, LayoutContext& ctx)
}

// Move key sigs and time sigs at the start of the next measure to the end of this measure
if ((seg.isTimeSigType() || seg.isKeySigType()) && sigsShouldBeInThisMeasure && changeAppliesToRepeatAndContinuation(seg)) {
if ((seg.isTimeSigType() || seg.isKeySigType()) && !seg.header() && !seg.trailer()
&& sigsShouldBeInThisMeasure && changeAppliesToRepeatAndContinuation(seg)) {
segsToMoveToThisMeasure.push_back(&seg);
}
}
Expand All @@ -379,7 +387,7 @@ void ModifyDom::sortMeasureSegments(Measure* measure, LayoutContext& ctx)
// Sort segments at start of first measure
Measure* prevMeasure = measure->prevMeasure();
if (prevMeasure && prevMeasure == ctx.dom().firstMeasure()) {
ModifyDom::removeAndAddBeginSegments(prevMeasure);
removeAndAddBeginSegments(prevMeasure);
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/engraving/rendering/score/slurtielayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1852,31 +1852,30 @@ void SlurTieLayout::setPartialTieEndPos(PartialTie* item, SlurTiePos& sPos)
const Segment* seg = chord->segment();
const Measure* measure = seg->measure();
const System* system = measure->system();
double width = item->style().styleS(Sid::minHangingTieLength).val() * item->spatium();

if (seg->measure()->isFirstInSystem() && !outgoing) {
sPos.p1 = PointF((system ? system->firstNoteRestSegmentX(true) : 0), sPos.p2.y());
return;
}

const Segment* adjSeg = outgoing ? seg->next() : seg->prev();
const Segment* adjSeg = outgoing ? seg->next1() : seg->prev1();
while (adjSeg && (!adjSeg->isActive() || !adjSeg->enabled())) {
adjSeg = outgoing ? seg->next() : seg->prev();
adjSeg = outgoing ? seg->next1() : seg->prev1();
}

double widthToSegment = 0.0;
if (adjSeg) {
EngravingItem* element = adjSeg->element(staff2track(item->vStaffIdx()));
const double elementWidth = element ? element->width() : 0.0;
double widthToSegment = outgoing ? adjSeg->xPosInSystemCoords() - sPos.p1.x() : sPos.p2.x()
- (adjSeg->xPosInSystemCoords() + elementWidth);
widthToSegment = outgoing ? adjSeg->xPosInSystemCoords() - sPos.p1.x() : sPos.p2.x()
- (adjSeg->xPosInSystemCoords() + elementWidth);
widthToSegment -= 0.25 * item->spatium();
width = std::max(widthToSegment, width);
}

if (outgoing) {
sPos.p2 = PointF(sPos.p1.x() + width, sPos.p1.y());
sPos.p2 = PointF(sPos.p1.x() + widthToSegment, sPos.p1.y());
} else {
sPos.p1 = PointF(sPos.p2.x() - width, sPos.p2.y());
sPos.p1 = PointF(sPos.p2.x() - widthToSegment, sPos.p2.y());
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/engraving/rendering/score/systemlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,10 +1417,14 @@ void SystemLayout::layoutSystemElements(System* system, LayoutContext& ctx)
}

if (s->isType(SegmentType::TimeSigType)) {
TimeSig* ts = toTimeSig(s->element(e->track()));
TimeSigPlacement timeSigPlacement = ts->style().styleV(Sid::timeSigPlacement).value<TimeSigPlacement>();
EngravingItem* el = s->element(e->track());
TimeSig* timeSig = el ? toTimeSig(el) : nullptr;
if (!timeSig) {
continue;
}
TimeSigPlacement timeSigPlacement = timeSig->style().styleV(Sid::timeSigPlacement).value<TimeSigPlacement>();
if (timeSigPlacement == TimeSigPlacement::ACROSS_STAVES) {
if (!ts->showOnThisStaff()) {
if (!timeSig->showOnThisStaff()) {
e->mutldata()->reset();
}
continue;
Expand Down
7 changes: 7 additions & 0 deletions src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3683,6 +3683,13 @@ void TLayout::layoutKeySig(const KeySig* item, KeySig::LayoutData* ldata, const
if (item->staff()) {
t2 = item->staff()->key(item->tick() - Fraction(1, 480 * 4));
}
if (item->segment() && item->segment()->isType(SegmentType::KeySigStartRepeatAnnounce)) {
// Handle naturals in continuation courtesy
Segment* prevCourtesySeg
= prevMeasure ? prevMeasure->findSegmentR(SegmentType::KeySigRepeatAnnounce, prevMeasure->ticks()) : nullptr;
EngravingItem* prevCourtesy = prevCourtesySeg ? prevCourtesySeg->element(item->track()) : nullptr;
t2 = prevCourtesy && prevCourtesy->isKeySig() ? toKeySig(prevCourtesy)->key() : t2;
}
if (t2 == Key::C) {
naturalsOn = false;
} else {
Expand Down
Binary file added vtest/scores/courtesy-changes-5.mscz
Binary file not shown.
Binary file added vtest/scores/courtesy-changes-6.mscz
Binary file not shown.
Binary file added vtest/scores/courtesy-changes-7.mscz
Binary file not shown.
Binary file added vtest/scores/courtesy-changes-8.mscz
Binary file not shown.
Binary file added vtest/scores/partialTieEndAlignment.mscz
Binary file not shown.
Loading