Skip to content

Commit 16499d9

Browse files
mike-spacbjeukendrup
authored andcommitted
Code review corrections
Code review corrections - 2 Code review corrections - 3 Code review corrections - 4 Code review corrections - 5
1 parent c630193 commit 16499d9

File tree

16 files changed

+164
-137
lines changed

16 files changed

+164
-137
lines changed

src/engraving/dom/tie.cpp

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void TieSegment::changeAnchor(EditData& ed, EngravingItem* element)
136136

137137
void TieSegment::editDrag(EditData& ed)
138138
{
139-
consolidateAdjustOffsetIntoUserOffset();
139+
consolidateAdjustmentOffsetIntoUserOffset();
140140
Grip g = ed.curGrip;
141141
ups(g).off += ed.delta;
142142

@@ -197,61 +197,61 @@ void TieSegment::computeMidThickness(double tieLengthInSp)
197197

198198
void TieSegment::computeBezier(PointF shoulderOffset)
199199
{
200-
PointF tieStart = ups(Grip::START).p + ups(Grip::START).off;
201-
PointF tieEnd = ups(Grip::END).p + ups(Grip::END).off;
200+
const PointF tieStart = ups(Grip::START).p + ups(Grip::START).off;
201+
const PointF tieEnd = ups(Grip::END).p + ups(Grip::END).off;
202202

203203
PointF tieEndNormalized = tieEnd - tieStart; // normalize to zero
204204
if (RealIsNull(tieEndNormalized.x())) {
205205
return;
206206
}
207207

208-
double tieAngle = atan(tieEndNormalized.y() / tieEndNormalized.x()); // angle required from tie start to tie end--zero if horizontal
208+
const double tieAngle = atan(tieEndNormalized.y() / tieEndNormalized.x()); // angle required from tie start to tie end--zero if horizontal
209209
Transform t;
210210
t.rotateRadians(-tieAngle); // rotate so that we are working with horizontal ties regardless of endpoint height difference
211211
tieEndNormalized = t.map(tieEndNormalized); // apply that rotation
212212
shoulderOffset = t.map(shoulderOffset); // also apply to shoulderOffset
213213

214-
double _spatium = spatium();
214+
const double _spatium = spatium();
215215
double tieLengthInSp = tieEndNormalized.x() / _spatium;
216216

217-
double minShoulderHeight = style().styleMM(Sid::tieMinShoulderHeight);
218-
double maxShoulderHeight = style().styleMM(Sid::tieMaxShoulderHeight);
217+
const double minShoulderHeight = style().styleMM(Sid::tieMinShoulderHeight);
218+
const double maxShoulderHeight = style().styleMM(Sid::tieMaxShoulderHeight);
219219
double shoulderH = minShoulderHeight + _spatium * 0.3 * sqrt(abs(tieLengthInSp - 1));
220220
shoulderH = std::clamp(shoulderH, minShoulderHeight, maxShoulderHeight);
221221

222222
shoulderH -= shoulderOffset.y();
223223

224224
PointF shoulderAdjustOffset = tie()->up() ? PointF(0.0, shoulderOffset.y()) : PointF(0.0, -shoulderOffset.y());
225-
addAdjustOffset(shoulderAdjustOffset, Grip::BEZIER1);
226-
addAdjustOffset(shoulderAdjustOffset, Grip::BEZIER2);
225+
addAdjustmentOffset(shoulderAdjustOffset, Grip::BEZIER1);
226+
addAdjustmentOffset(shoulderAdjustOffset, Grip::BEZIER2);
227227

228228
if (!tie()->up()) {
229229
shoulderH = -shoulderH;
230230
}
231231

232232
double shoulderW = 0.6; // TODO: style
233233

234-
double tieWidth = tieEndNormalized.x();
235-
double bezier1X = (tieWidth - tieWidth * shoulderW) * .5 + shoulderOffset.x();
236-
double bezier2X = bezier1X + tieWidth * shoulderW + shoulderOffset.x();
234+
const double tieWidth = tieEndNormalized.x();
235+
const double bezier1X = (tieWidth - tieWidth * shoulderW) * .5 + shoulderOffset.x();
236+
const double bezier2X = bezier1X + tieWidth * shoulderW + shoulderOffset.x();
237237

238-
PointF tieDrag = PointF(tieWidth * .5, 0.0);
238+
const PointF tieDrag = PointF(tieWidth * .5, 0.0);
239239

240-
PointF bezier1(bezier1X, -shoulderH);
241-
PointF bezier2(bezier2X, -shoulderH);
240+
const PointF bezier1(bezier1X, -shoulderH);
241+
const PointF bezier2(bezier2X, -shoulderH);
242242

243243
computeMidThickness(tieLengthInSp);
244244

245245
PointF tieThickness(0.0, m_midThickness);
246246

247-
PointF bezier1Offset = t.map(ups(Grip::BEZIER1).off);
248-
PointF bezier2Offset = t.map(ups(Grip::BEZIER2).off);
247+
const PointF bezier1Offset = t.map(ups(Grip::BEZIER1).off);
248+
const PointF bezier2Offset = t.map(ups(Grip::BEZIER2).off);
249249

250250
//-----------------------------------calculate p6
251-
PointF bezier1Final = bezier1 + bezier1Offset;
252-
PointF bezier2Final = bezier2 + bezier2Offset;
251+
const PointF bezier1Final = bezier1 + bezier1Offset;
252+
const PointF bezier2Final = bezier2 + bezier2Offset;
253253

254-
PointF tieShoulder = 0.5 * (bezier1Final + bezier2Final);
254+
const PointF tieShoulder = 0.5 * (bezier1Final + bezier2Final);
255255
//-----------------------------------
256256

257257
m_path = PainterPath();
@@ -751,17 +751,17 @@ void TieSegment::adjustX()
751751
}
752752
}
753753

754-
void TieSegment::consolidateAdjustOffsetIntoUserOffset()
754+
void TieSegment::consolidateAdjustmentOffsetIntoUserOffset()
755755
{
756-
for (size_t i = 0; i < m_adjustOffsets.size(); ++i) {
756+
for (size_t i = 0; i < m_adjustmentOffsets.size(); ++i) {
757757
Grip grip = static_cast<Grip>(i);
758-
PointF adjustOffset = m_adjustOffsets[i];
758+
PointF adjustOffset = m_adjustmentOffsets[i];
759759
if (!adjustOffset.isNull()) {
760760
ups(grip).p -= adjustOffset;
761761
ups(grip).off = adjustOffset;
762762
}
763763
}
764-
resetAdjustOffset();
764+
resetAdjustmentOffset();
765765
}
766766

767767
//---------------------------------------------------------
@@ -953,18 +953,18 @@ void Tie::calculateIsInside()
953953
return;
954954
}
955955

956-
Note* startN = startNote();
957-
Chord* startChord = startN ? startN->chord() : nullptr;
958-
Note* endN = endNote();
959-
Chord* endChord = endN ? endN->chord() : nullptr;
956+
const Note* startN = startNote();
957+
const Chord* startChord = startN ? startN->chord() : nullptr;
958+
const Note* endN = endNote();
959+
const Chord* endChord = endN ? endN->chord() : nullptr;
960960

961961
if (!startChord || !endChord) {
962962
setIsInside(false);
963963
return;
964964
}
965965

966-
bool startIsSingleNote = startChord->notes().size() <= 1;
967-
bool endIsSingleNote = endChord->notes().size() <= 1;
966+
const bool startIsSingleNote = startChord->notes().size() <= 1;
967+
const bool endIsSingleNote = endChord->notes().size() <= 1;
968968

969969
if (startIsSingleNote && endIsSingleNote) {
970970
setIsInside(style().styleV(Sid::tiePlacementSingleNote).value<TiePlacement>() == TiePlacement::INSIDE);
@@ -1041,29 +1041,29 @@ bool Tie::isOuterTieOfChord(Grip startOrEnd) const
10411041
return false;
10421042
}
10431043

1044-
bool start = startOrEnd == Grip::START;
1045-
Note* note = start ? startNote() : endNote();
1044+
const bool start = startOrEnd == Grip::START;
1045+
const Note* note = start ? startNote() : endNote();
10461046
if (!note) {
10471047
return false;
10481048
}
10491049

1050-
Chord* chord = note->chord();
1050+
const Chord* chord = note->chord();
10511051

10521052
return (note == chord->upNote() && up()) || (note == chord->downNote() && !up());
10531053
}
10541054

10551055
bool Tie::hasTiedSecondInside() const
10561056
{
1057-
Note* note = startNote();
1057+
const Note* note = startNote();
10581058
if (!note) {
10591059
return false;
10601060
}
10611061

1062-
Chord* chord = note->chord();
1063-
int line = note->line();
1064-
int secondInsideLine = up() ? line + 1 : line - 1;
1062+
const Chord* chord = note->chord();
1063+
const int line = note->line();
1064+
const int secondInsideLine = up() ? line + 1 : line - 1;
10651065

1066-
for (Note* otherNote : chord->notes()) {
1066+
for (const Note* otherNote : chord->notes()) {
10671067
if (otherNote->line() == secondInsideLine && otherNote->tieFor() && otherNote->tieFor()->up() == up()) {
10681068
return true;
10691069
}
@@ -1074,8 +1074,8 @@ bool Tie::hasTiedSecondInside() const
10741074

10751075
bool Tie::isCrossStaff() const
10761076
{
1077-
Note* startN = startNote();
1078-
Note* endN = endNote();
1077+
const Note* startN = startNote();
1078+
const Note* endN = endNote();
10791079

10801080
return (startN && startN->chord()->staffMove() != 0) || (endN && endN->chord()->staffMove() != 0);
10811081
}

src/engraving/dom/tie.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TieSegment final : public SlurTieSegment
3838

3939
double m_midThickness = 0.0;
4040

41-
std::array<PointF, static_cast<size_t>(Grip::GRIPS)> m_adjustOffsets = { PointF() };
41+
std::array<PointF, static_cast<size_t>(Grip::GRIPS)> m_adjustmentOffsets;
4242

4343
/*************************
4444
* DEPRECATED
@@ -65,10 +65,10 @@ class TieSegment final : public SlurTieSegment
6565
void adjustY(const PointF& p1, const PointF& p2);
6666
void adjustX();
6767

68-
void addAdjustOffset(const PointF& offset, Grip grip) { m_adjustOffsets[static_cast<size_t>(grip)] += offset; }
69-
void resetAdjustOffset() { m_adjustOffsets.fill(PointF()); }
70-
PointF adjustOffset(Grip grip) { return m_adjustOffsets[static_cast<size_t>(grip)]; }
71-
void consolidateAdjustOffsetIntoUserOffset();
68+
void addAdjustmentOffset(const PointF& offset, Grip grip) { m_adjustmentOffsets[static_cast<size_t>(grip)] += offset; }
69+
void resetAdjustmentOffset() { m_adjustmentOffsets.fill(PointF()); }
70+
PointF adjustmentOffset(Grip grip) { return m_adjustmentOffsets[static_cast<size_t>(grip)]; }
71+
void consolidateAdjustmentOffsetIntoUserOffset();
7272

7373
void finalizeSegment();
7474

src/engraving/rendering/dev/chordlayout.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,16 +658,6 @@ void ChordLayout::layoutSpanners(Chord* item, LayoutContext& ctx)
658658
}
659659
}
660660

661-
void ChordLayout::layoutSpanners(Chord* item, System* system, const Fraction& stick, LayoutContext& ctx)
662-
{
663-
//! REVIEW Needs explanation
664-
for (const Note* note : item->notes()) {
665-
for (Spanner* sp : note->spannerBack()) {
666-
TLayout::layout(sp, ctx);
667-
}
668-
}
669-
}
670-
671661
//---------------------------------------------------------
672662
// layoutArticulations
673663
// layout tenuto and staccato

src/engraving/rendering/dev/chordlayout.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class ChordLayout
4747
static void layout(Chord* item, LayoutContext& ctx);
4848

4949
static void layoutSpanners(Chord* item, LayoutContext& ctx);
50-
static void layoutSpanners(Chord* item, System* system, const Fraction& stick, LayoutContext& ctx);
5150

5251
static void layoutArticulations(Chord* item, LayoutContext& ctx);
5352
static void layoutArticulations2(Chord* item, LayoutContext& ctx, bool layoutOnCrossBeamSide = false);

src/engraving/rendering/dev/measurelayout.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,13 @@ void MeasureLayout::layout2(Measure* item, LayoutContext& ctx)
108108
continue;
109109
}
110110
Chord* chord = toChord(element);
111-
ChordLayout::layoutSpanners(chord, item->system(), stick, ctx);
112111
for (Note* note : chord->notes()) {
113112
Tie* tieFor = note->tieFor();
114113
Tie* tieBack = note->tieBack();
115114
if (tieFor && tieFor->isCrossStaff()) {
116115
SlurTieLayout::tieLayoutFor(tieFor, item->system());
117116
}
118-
if (tieBack && tieBack->tick() < item->system()->tick() && tieBack->isCrossStaff()) {
117+
if (tieBack && tieBack->tick() < stick && tieBack->isCrossStaff()) {
119118
SlurTieLayout::tieLayoutBack(tieBack, item->system());
120119
}
121120
}

0 commit comments

Comments
 (0)