Skip to content

Commit 4eeb87b

Browse files
committed
Code review corrections - 5
1 parent adac824 commit 4eeb87b

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

src/engraving/rendering/dev/slurtielayout.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -992,18 +992,18 @@ void SlurTieLayout::fixArticulations(Slur* item, PointF& pt, Chord* c, double up
992992

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

999999
if (item->slurDirection() == DirectionV::AUTO) {
10001000
bool simpleException = st && st->isSimpleTabStaff();
1001-
if (st && st->isSimpleTabStaff()) {
1001+
if (simpleException) {
10021002
item->setUp(isUpVoice(c1->voice()));
10031003
} else {
10041004
if (c1->measure()->hasVoices(c1->staffIdx(), c1->tick(), c1->actualTicks())) {
10051005
// in polyphonic passage, ties go on the stem side
1006-
item->setUp(simpleException ? isUpVoice(c1->voice()) : c1->up());
1006+
item->setUp(c1->up());
10071007
} else {
10081008
item->setUp(!c1->up());
10091009
}
@@ -1165,7 +1165,7 @@ void SlurTieLayout::computeStartAndEndSystem(Tie* item, SlurTiePos& slurTiePos)
11651165
slurTiePos.system2 = endSystem;
11661166
}
11671167

1168-
PointF SlurTieLayout::computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd)
1168+
PointF SlurTieLayout::computeDefaultStartOrEndPoint(const Tie* tie, Grip startOrEnd)
11691169
{
11701170
if (startOrEnd != Grip::START && startOrEnd != Grip::END) {
11711171
return PointF();
@@ -1182,13 +1182,13 @@ PointF SlurTieLayout::computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd)
11821182

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

1185-
bool up = tie->up();
1186-
bool inside = tie->isInside();
1187-
int upSign = up ? -1 : 1;
1188-
int leftRightSign = start ? +1 : -1;
1189-
double noteWidth = note->width();
1190-
double noteHeight = note->height();
1191-
double spatium = tie->spatium();
1185+
const bool up = tie->up();
1186+
const bool inside = tie->isInside();
1187+
const int upSign = up ? -1 : 1;
1188+
const int leftRightSign = start ? +1 : -1;
1189+
const double noteWidth = note->width();
1190+
const double noteHeight = note->height();
1191+
const double spatium = tie->spatium();
11921192

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

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

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

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

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

13801380
// 1. Check for bad end point protrusion
13811381

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

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

13911391
bool badIntersection = protrusion < badIntersectionLimit && (isEndInsideStaff || isEndInsideLedgerLines);

src/engraving/rendering/dev/slurtielayout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class SlurTieLayout
5757
static void fixArticulations(Slur* item, PointF& pt, Chord* c, double up, bool stemSide);
5858

5959
static void computeStartAndEndSystem(Tie* item, SlurTiePos& slurTiePos);
60-
static PointF computeDefaultStartOrEndPoint(Tie* tie, Grip startOrEnd);
61-
static double noteOpticalCenterForTie(Note* note, bool up);
60+
static PointF computeDefaultStartOrEndPoint(const Tie* tie, Grip startOrEnd);
61+
static double noteOpticalCenterForTie(const Note* note, bool up);
6262
static void correctForCrossStaff(Tie* tie, SlurTiePos& sPos);
6363
static void forceHorizontal(Tie* tie, SlurTiePos& sPos);
6464
static void adjustX(TieSegment* tieSegment, SlurTiePos& sPos, Grip startOrEnd);

0 commit comments

Comments
 (0)