Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Dec 19, 2024
1 parent 01e1deb commit 9944367
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/engraving/dom/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,10 @@ bool ChordRest::followingJumpItem() const
const Measure* measure = seg->measure();
const Fraction nextTick = seg->tick() + actualTicks();

if (measure->lastChordRest(track()) != this) {
return false;
}

// Jumps & markers
for (const EngravingItem* e : measure->el()) {
if (!e->isJump() && !e->isMarker()) {
Expand Down Expand Up @@ -1340,7 +1344,7 @@ bool ChordRest::followingJumpItem() const
}

// Repeats
if (measure->endTick() == nextTick && measure->repeatEnd()) {
if (measure->repeatEnd()) {
return true;
}

Expand All @@ -1365,6 +1369,10 @@ bool ChordRest::precedingJumpItem() const
const Segment* seg = segment();
const Measure* measure = seg->measure();

if (measure->firstChordRest(track()) != this) {
return false;
}

if (seg->score()->firstSegment(SegmentType::ChordRest) == seg) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/score/slurtielayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ SpannerSegment* SlurTieLayout::layoutSystem(Slur* item, System* system, LayoutCo
endPoint = tie->segmentAt(0)->ups(Grip::END).pos();
}

if (outgoingPartialSlur && tie->nsegments() == 1) {
if (outgoingPartialSlur && tie->type() == ElementType::TIE && tie->nsegments() == 1) {
// For partial slurs ending midway through a tie, get top of the tie shape at the slur's end X
const TieSegment* tieSeg = tie->frontSegment();
const Shape tieShape = tieSeg->shape().translate(tieSeg->pos());
Expand Down
21 changes: 17 additions & 4 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2268,20 +2268,33 @@ void NotationInteraction::doAddSlur(EngravingItem* firstItem, EngravingItem* sec

if (firstItem && secondItem && (firstItem->isBarLine() != secondItem->isBarLine())) {
const bool outgoing = firstItem->isChordRest();
const ChordRest* cr = outgoing ? toChordRest(firstItem) : toChordRest(secondItem);
const BarLine* bl = outgoing ? toBarLine(secondItem) : toBarLine(firstItem);

// Check the barline is the start of a repeat section
const Segment* adjacentCrSeg
= outgoing ? bl->segment()->prev1(SegmentType::ChordRest) : bl->segment()->next1(SegmentType::ChordRest);
ChordRest* adjacentCr = nullptr;
for (track_idx_t track = 0; track < score()->ntracks(); track++) {
EngravingItem* adjacentItem = adjacentCrSeg->element(track);
if (!adjacentItem || !adjacentItem->isChordRest()) {
continue;
}
adjacentCr = toChordRest(adjacentItem);
break;
}

if ((outgoing && !cr->followingJumpItem()) || (!outgoing && !cr->precedingJumpItem())) {
if (!adjacentCr || (outgoing && !adjacentCr->followingJumpItem()) || (!outgoing && !adjacentCr->precedingJumpItem())) {
return;
}

Slur* partialSlur = slurTemplate ? slurTemplate->clone() : Factory::createSlur(score()->dummy());
if (outgoing) {
partialSlur->undoSetOutgoing(true);
firstChordRest = toChordRest(firstItem);
secondChordRest = toChordRest(firstItem);
secondChordRest = toChordRest(adjacentCr);
} else {
partialSlur->undoSetIncoming(true);
firstChordRest = toChordRest(secondItem);
firstChordRest = toChordRest(adjacentCr);
secondChordRest = toChordRest(secondItem);
}
slurTemplate = partialSlur;
Expand Down

0 comments on commit 9944367

Please sign in to comment.