Skip to content

Commit

Permalink
Fix initial slur positioning
Browse files Browse the repository at this point in the history
when timestamps are given for start and end
  • Loading branch information
brdvd committed Nov 30, 2021
1 parent 84108b6 commit a4b9cb6
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/slur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,24 +881,14 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
bool isShortSlur = false;
if (x2 - x1 < doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)) isShortSlur = true;

/************** calculate the radius for adjusting the x position **************/

int startRadius = 0;
if (!start->Is(TIMESTAMP_ATTR)) {
startRadius = start->GetDrawingRadius(doc);
}

int endRadius = 0;
if (!end->Is(TIMESTAMP_ATTR)) {
endRadius = end->GetDrawingRadius(doc);
}

Beam *parentBeam = NULL;
FTrem *parentFTrem = NULL;
int yChordMax = 0, yChordMin = 0;
const int unit = doc->GetDrawingUnit(staff->m_drawingStaffSize);
if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_START)) {
// first get the min max of the chord (if any)
if (((spanningType == SPANNING_START_END) || (spanningType == SPANNING_START)) && !start->Is(TIMESTAMP_ATTR)) {
// get the radius for adjusting the x position
const int startRadius = start->GetDrawingRadius(doc);
// get the min max of the chord (if any)
if (startChord) {
startChord->GetYExtremes(yChordMax, yChordMin);
}
Expand Down Expand Up @@ -930,8 +920,8 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
}
// d(^)
else {
// put it on the side, move it left, but not if we have a @tstamp
if (!start->Is(TIMESTAMP_ATTR) && (startStemLen != 0)) x1 += unit * 2;
// put it on the side, move it right
if (startStemLen != 0) x1 += unit * 2;
if (startChord)
y1 = yChordMax + unit * 3;
else
Expand Down Expand Up @@ -975,7 +965,7 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
}
// P(_)
else {
// put it on the side, but no need to move it left
// put it on the side, but no need to move it right
if (startChord) {
y1 = yChordMin - unit * 3;
}
Expand All @@ -985,7 +975,9 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
}
}
}
if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_END)) {
if (((spanningType == SPANNING_START_END) || (spanningType == SPANNING_END)) && !end->Is(TIMESTAMP_ATTR)) {
// get the radius for adjusting the x position
const int endRadius = end->GetDrawingRadius(doc);
// get the min max of the chord if any
if (endChord) {
endChord->GetYExtremes(yChordMax, yChordMin);
Expand Down Expand Up @@ -1040,7 +1032,7 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
}
// (^)d
else {
// put it on the side, no need to move it right
// put it on the side, no need to move it left
if (endChord) {
y2 = yChordMax + unit * 3;
}
Expand Down Expand Up @@ -1095,8 +1087,8 @@ std::pair<Point, Point> Slur::AdjustCoordinates(
}
// (_)P
else {
// put it on the side, move it right, but not if we have a @tstamp2
if (!end->Is(TIMESTAMP_ATTR)) x2 -= unit * 2;
// put it on the side, move it left
if (endStemLen != 0) x2 -= unit * 2;
if (endChord) {
y2 = yChordMin - unit * 3;
}
Expand Down

0 comments on commit a4b9cb6

Please sign in to comment.