Skip to content

Commit

Permalink
Code review corrections - 5
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Sep 22, 2023
1 parent adac824 commit 4eeb87b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
50 changes: 25 additions & 25 deletions src/engraving/rendering/dev/slurtielayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,18 +992,18 @@ void SlurTieLayout::fixArticulations(Slur* item, PointF& pt, Chord* c, double up

TieSegment* SlurTieLayout::layoutTieWithNoEndNote(Tie* item)
{
StaffType* st = item->staff()->staffType(item->startNote() ? item->startNote()->tick() : Fraction(0, 1));
StaffType* st = item->staff()->staffType(item->startNote()->tick());
Chord* c1 = item->startNote()->chord();
item->setTick(c1->tick());

if (item->slurDirection() == DirectionV::AUTO) {
bool simpleException = st && st->isSimpleTabStaff();
if (st && st->isSimpleTabStaff()) {
if (simpleException) {
item->setUp(isUpVoice(c1->voice()));
} else {
if (c1->measure()->hasVoices(c1->staffIdx(), c1->tick(), c1->actualTicks())) {
// in polyphonic passage, ties go on the stem side
item->setUp(simpleException ? isUpVoice(c1->voice()) : c1->up());
item->setUp(c1->up());
} else {
item->setUp(!c1->up());
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@ void SlurTieLayout::computeStartAndEndSystem(Tie* item, SlurTiePos& slurTiePos)
slurTiePos.system2 = endSystem;
}

PointF SlurTieLayout::computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd)
PointF SlurTieLayout::computeDefaultStartOrEndPoint(const Tie* tie, Grip startOrEnd)
{
if (startOrEnd != Grip::START && startOrEnd != Grip::END) {
return PointF();
Expand All @@ -1182,13 +1182,13 @@ PointF SlurTieLayout::computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd)

PointF result = note->pos() + chord->pos() + chord->segment()->pos() + chord->measure()->pos();

bool up = tie->up();
bool inside = tie->isInside();
int upSign = up ? -1 : 1;
int leftRightSign = start ? +1 : -1;
double noteWidth = note->width();
double noteHeight = note->height();
double spatium = tie->spatium();
const bool up = tie->up();
const bool inside = tie->isInside();
const int upSign = up ? -1 : 1;
const int leftRightSign = start ? +1 : -1;
const double noteWidth = note->width();
const double noteHeight = note->height();
const double spatium = tie->spatium();

double baseX, baseY = 0.0;
if (inside) {
Expand All @@ -1208,7 +1208,7 @@ PointF SlurTieLayout::computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd)
return result;
}

double SlurTieLayout::noteOpticalCenterForTie(Note* note, bool up)
double SlurTieLayout::noteOpticalCenterForTie(const Note* note, bool up)
{
SymId symId = note->layoutData()->cachedNoteheadSym;
PointF cutOutLeft = note->symSmuflAnchor(symId, up ? SmuflAnchorId::cutOutNW : SmuflAnchorId::cutOutSW);
Expand Down Expand Up @@ -1312,10 +1312,10 @@ void SlurTieLayout::adjustX(TieSegment* tieSegment, SlurTiePos& sPos, Grip start
return !s.toItem || (s.toItem == note || s.toItem->isHook() || s.toItem->isLedgerLine());
});

double arcSideMargin = 0.3 * spatium;
double pointsSideMargin = 0.15 * spatium;
double yBelow = tiePoint.y() - (tie->up() ? arcSideMargin : pointsSideMargin);
double yAbove = tiePoint.y() + (tie->up() ? pointsSideMargin : arcSideMargin);
const double arcSideMargin = 0.3 * spatium;
const double pointsSideMargin = 0.15 * spatium;
const double yBelow = tiePoint.y() - (tie->up() ? arcSideMargin : pointsSideMargin);
const double yAbove = tiePoint.y() + (tie->up() ? pointsSideMargin : arcSideMargin);
double pointToClear = start ? chordShape.rightMostEdgeAtHeight(yBelow, yAbove)
: chordShape.leftMostEdgeAtHeight(yBelow, yAbove);

Expand Down Expand Up @@ -1373,19 +1373,19 @@ void SlurTieLayout::adjustY(TieSegment* tieSegment)
bool up = tieSegment->tie()->up();
int upSign = up ? -1 : 1;

double spatium = tieSegment->spatium();
double staffLineDist = staff->lineDistance(tick) * spatium;
double staffLineThickness = tieSegment->style().styleMM(Sid::staffLineWidth);
const double spatium = tieSegment->spatium();
const double staffLineDist = staff->lineDistance(tick) * spatium;
const double staffLineThickness = tieSegment->style().styleMM(Sid::staffLineWidth);

// 1. Check for bad end point protrusion

double endPointY = tieSegment->ups(Grip::START).p.y();
int closestLineToEndpoints = up ? floor(endPointY / staffLineDist) : ceil(endPointY / staffLineDist);
bool isEndInsideStaff = closestLineToEndpoints >= 0 && closestLineToEndpoints < staff->lines(tick);
bool isEndInsideLedgerLines = !isEndInsideStaff && !tieSegment->tie()->isOuterTieOfChord(Grip::START);
const double endPointY = tieSegment->ups(Grip::START).p.y();
const int closestLineToEndpoints = up ? floor(endPointY / staffLineDist) : ceil(endPointY / staffLineDist);
const bool isEndInsideStaff = closestLineToEndpoints >= 0 && closestLineToEndpoints < staff->lines(tick);
const bool isEndInsideLedgerLines = !isEndInsideStaff && !tieSegment->tie()->isOuterTieOfChord(Grip::START);

double halfLineThicknessCorrection = 0.5 * staffLineThickness * upSign;
double protrusion = abs(endPointY - (closestLineToEndpoints * spatium - halfLineThicknessCorrection));
const double halfLineThicknessCorrection = 0.5 * staffLineThickness * upSign;
const double protrusion = abs(endPointY - (closestLineToEndpoints * spatium - halfLineThicknessCorrection));
const double badIntersectionLimit = 0.20 * spatium; // TODO: style

bool badIntersection = protrusion < badIntersectionLimit && (isEndInsideStaff || isEndInsideLedgerLines);
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/rendering/dev/slurtielayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class SlurTieLayout
static void fixArticulations(Slur* item, PointF& pt, Chord* c, double up, bool stemSide);

static void computeStartAndEndSystem(Tie* item, SlurTiePos& slurTiePos);
static PointF computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd);
static double noteOpticalCenterForTie(Note* note, bool up);
static PointF computeDefaultStartOrEndPoint(const Tie* tie, Grip startOrEnd);
static double noteOpticalCenterForTie(const Note* note, bool up);
static void correctForCrossStaff(Tie* tie, SlurTiePos& sPos);
static void forceHorizontal(Tie* tie, SlurTiePos& sPos);
static void adjustX(TieSegment* tieSegment, SlurTiePos& sPos, Grip startOrEnd);
Expand Down

0 comments on commit 4eeb87b

Please sign in to comment.