make sure it works with the updated stem code

This commit is contained in:
Nick Mazuk 2021-12-07 21:28:41 -08:00
parent 091e188b11
commit 3a9fe6dcf7
No known key found for this signature in database
GPG key ID: B123C6432D2444F6
3 changed files with 20 additions and 30 deletions

View file

@ -511,8 +511,8 @@ void Beam::layout()
int Beam::getMiddleStaffLine(ChordRest* startChord, ChordRest* endChord, int staffLines) const
{
bool useWideBeams = score()->styleB(Sid::useWideBeams);
int startMiddleLine = Chord::minStaffOverlap(_up, staffLines, startChord->beams(), false, _beamSpacing / 4.0, useWideBeams) * 2;
int endMiddleLine = Chord::minStaffOverlap(_up, staffLines, endChord->beams(), false, _beamSpacing / 4.0, useWideBeams) * 2;
int startMiddleLine = Chord::minStaffOverlap(_up, staffLines, startChord->beams(), false, _beamSpacing / 4.0, useWideBeams);
int endMiddleLine = Chord::minStaffOverlap(_up, staffLines, endChord->beams(), false, _beamSpacing / 4.0, useWideBeams);
// offset middle line by 1 or -1 since the anchor is at the middle of the beam,
// not at the tip of the stem
@ -960,7 +960,7 @@ void Beam::setValidBeamPositions(int& dictator, int& pointer, int beamCount, int
void Beam::addMiddleLineSlant(int& dictator, int& pointer, int beamCount, int middleLine, int interval)
{
if (interval == 0 || (beamCount > 2 && _beamSpacing != 4) || beamCount >= 4 || score()->styleB(Sid::beamNoSlope)) {
if (interval == 0 || (beamCount > 2 && _beamSpacing != 4) || score()->styleB(Sid::beamNoSlope)) {
return;
}
bool isOnMiddleLine = pointer == middleLine && (qAbs(pointer - dictator) < 2);
@ -1008,17 +1008,12 @@ void Beam::layout2(std::vector<ChordRest*> chordRests, SpannerSegmentType, int f
LayoutBeams::respace(&chordRests);
}
// FIXME
if (!chordRests.front()->isChord() || !chordRests.back()->isChord()) {
NOT_IMPL_RETURN;
}
_beamSpacing = score()->styleB(Sid::useWideBeams) ? 4 : 3;
// todo: add edge case for when a beam starts or ends on a rest
Chord* startChord = toChord(chordRests.front());
Chord* endChord = toChord(chordRests.back());
_beamSpacing = score()->styleD(Sid::beamDistance) == 1.0 ? 4 : 3;
// anchor represents the middle of the beam, not the tip of the stem
PointF startAnchor = chordBeamAnchor(startChord);
PointF endAnchor = chordBeamAnchor(endChord);

View file

@ -1369,9 +1369,9 @@ int Chord::calcMinStemLength()
static const int minInnerStemLengths[4] = { 10, 9, 8, 7 };
minStemLength = qMax(minStemLength, minInnerStemLengths[qMin(beams(), 3)]);
// add beam lengths
minStemLength += beams() * _spatium * (score()->styleB(Sid::useWideBeams) ? 1.0 : 0.75);
minStemLength += beams() * (score()->styleB(Sid::useWideBeams) ? 4 : 3);
if (beams() > 0) {
minStemLength -= 0.25 * _spatium;
minStemLength -= 1;
}
}
return minStemLength;
@ -1392,7 +1392,7 @@ int Chord::stemLengthBeamAddition() const
case 3:
return 2;
default:
return (beamCount - 3) * (score()->styleB(Sid::useWideBeams) ? 1.0 : 0.75);
return (beamCount - 3) * (score()->styleB(Sid::useWideBeams) ? 4 : 3);
}
}
@ -1402,7 +1402,7 @@ int Chord::minStaffOverlap(bool up, int staffLines, int beamCount, bool hasHook,
if (beamCount == 3 && !hasHook) {
beamOverlap = 12;
} else if (beamCount >= 4 && !hasHook) {
beamOverlap = (beamCount - 4) * beamSpacing + (useWideBeams ? 4.0 : 3.5);
beamOverlap = (beamCount - 4) * beamSpacing + (useWideBeams ? 16 : 14);
}
int staffOverlap = qMin(beamOverlap, (staffLines - 1) * 4);
@ -1505,16 +1505,11 @@ qreal Chord::calcDefaultStemLength()
int minStemLengthQuarterSpaces = calcMinStemLength();
_minStemLength = minStemLengthQuarterSpaces / 4.0 * _spatium;
// int staffLineCount = staffItem ? staffItem->lines(tick()) : 5;
// int shortStemStart = score()->styleI(Sid::shortStemStartLocation) * 2 + 1;
// int shortestStem = score()->styleD(Sid::shortestStem) * 4;
// int middleLine = minStaffOverlap(_up, staffLineCount, beams(), !!_hook);
int staffLineCount = staffItem->lines(tick());
int shortStemStart = score()->styleI(Sid::shortStemStartLocation) * 2;
int staffLineCount = staffItem ? staffItem->lines(tick()) : 5;
int shortStemStart = score()->styleI(Sid::shortStemStartLocation) * 2 + 1;
bool useWideBeams = score()->styleB(Sid::useWideBeams);
qreal middleLine = minStaffOverlap(_up, staffLineCount, beams(), !!_hook, useWideBeams ? 1.0 : 0.75, useWideBeams);
qreal shortestStem = score()->styleB(Sid::useWideBeams) ? 3.0 : score()->styleD(Sid::shortestStem);
int middleLine = minStaffOverlap(_up, staffLineCount, beams(), !!_hook, useWideBeams ? 4 : 3, useWideBeams);
int shortestStem = score()->styleB(Sid::useWideBeams) ? 12 : score()->styleD(Sid::shortestStem) * 4;
if (isGrace()) {
stemLength = qMax(static_cast<int>(defaultStemLength * score()->styleD(Sid::graceNoteMag)), minStemLengthQuarterSpaces);
} else if (up()) {

View file

@ -364,7 +364,7 @@
<durationType>16th</durationType>
</Rest>
<Beam>
<l1>2</l1>
<l1>0</l1>
<l2>2</l2>
</Beam>
<Chord>
@ -385,7 +385,7 @@
<durationType>32nd</durationType>
</Rest>
<Beam>
<l1>2</l1>
<l1>-2</l1>
<l2>2</l2>
</Beam>
<Chord>
@ -407,7 +407,7 @@
</Rest>
<Beam>
<l1>2</l1>
<l2>2</l2>
<l2>0</l2>
</Beam>
<Chord>
<durationType>64th</durationType>
@ -428,7 +428,7 @@
</Rest>
<Beam>
<l1>2</l1>
<l2>2</l2>
<l2>-2</l2>
</Beam>
<Chord>
<durationType>64th</durationType>
@ -722,7 +722,7 @@
<durationType>16th</durationType>
</Rest>
<Beam>
<l1>30</l1>
<l1>32</l1>
<l2>30</l2>
</Beam>
<Chord>
@ -743,7 +743,7 @@
<durationType>32nd</durationType>
</Rest>
<Beam>
<l1>30</l1>
<l1>34</l1>
<l2>30</l2>
</Beam>
<Chord>
@ -765,7 +765,7 @@
</Rest>
<Beam>
<l1>30</l1>
<l2>30</l2>
<l2>32</l2>
</Beam>
<Chord>
<durationType>64th</durationType>
@ -786,7 +786,7 @@
</Rest>
<Beam>
<l1>30</l1>
<l2>30</l2>
<l2>34</l2>
</Beam>
<Chord>
<durationType>64th</durationType>