Skip to content

Commit

Permalink
Amend glissando staff y difference function to allow cross staff glisses
Browse files Browse the repository at this point in the history
  • Loading branch information
miiizen committed Oct 1, 2024
1 parent 6401855 commit 4a807fe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/engraving/dom/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,13 +1187,14 @@ Fraction actualTicks(Fraction duration, Tuplet* tuplet, Fraction timeStretch)
return f;
}

double yStaffDifference(const System* system1, staff_idx_t staffIdx1, const System* system2, staff_idx_t staffIdx2)
double yStaffDifference(const System* system1, const System* system2, staff_idx_t staffIdx)
{
if (!system1 || !system2) {
return 0.0;
}
const SysStaff* staff1 = system1->staff(staffIdx1);
const SysStaff* staff2 = system2->staff(staffIdx2);

const SysStaff* staff1 = system1->staff(staffIdx);
const SysStaff* staff2 = system2->staff(staffIdx);
if (!staff1 || !staff2) {
return 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extern Segment* skipTuplet(Tuplet* tuplet);
extern SymIdList timeSigSymIdsFromString(const String&);
extern Fraction actualTicks(Fraction duration, Tuplet* tuplet, Fraction timeStretch);

extern double yStaffDifference(const System* system1, staff_idx_t staffIdx1, const System* system2, staff_idx_t staffIdx2);
extern double yStaffDifference(const System* system1, const System* system2, staff_idx_t staffIdx1);

extern bool allowRemoveWhenRemovingStaves(EngravingItem* item, staff_idx_t startStaff, staff_idx_t endStaff = 0);
extern bool moveDownWhenAddingStaves(EngravingItem* item, staff_idx_t startStaff, staff_idx_t endStaff = 0);
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/rendering/score/tlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4954,7 +4954,7 @@ void TLayout::layoutNoteAnchoredLine(SLine* item, EngravingItem::LayoutData* lda
}
double startY = startSeg->ldata()->pos().y();
double yTot = endSeg->ldata()->pos().y() + endSeg->ipos2().y() - startY;
yTot -= yStaffDifference(endSeg->system(), track2staff(item->track2()), startSeg->system(), track2staff(item->track()));
yTot -= yStaffDifference(endSeg->system(), startSeg->system(), track2staff(item->track2()));
double ratio = muse::divide(yTot, xTot, 1.0);
// interpolate y-coord of intermediate points across total width and height
double xCurr = 0.0;
Expand All @@ -4966,7 +4966,7 @@ void TLayout::layoutNoteAnchoredLine(SLine* item, EngravingItem::LayoutData* lda
segm->rypos2() = yCurr - segm->ldata()->pos().y(); // position segm. end point at yCurr
// next segment shall start where this segment stopped
SpannerSegment* nextSeg = item->segmentAt(i + 1);
yCurr += yStaffDifference(nextSeg->system(), track2staff(item->track2()), segm->system(), track2staff(item->track()));
yCurr += yStaffDifference(nextSeg->system(), segm->system(), track2staff(item->track2()));
segm = nextSeg;
segm->rypos2() += segm->ldata()->pos().y() - yCurr; // adjust next segm. vertical length
segm->mutldata()->setPosY(yCurr); // position next segm. start point at yCurr
Expand Down
Binary file added vtest/scores/gliss-6.mscz
Binary file not shown.

0 comments on commit 4a807fe

Please sign in to comment.