Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors in header distances calculation #26840

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/engraving/dom/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2847,13 +2847,17 @@ bool Segment::goesBefore(const Segment* nextSegment) const
}

if (thisIsClef && (nextIsKeySig || nextIsTimeSig)
&& rtick() == Fraction(0, 1) && nextSegment->rtick() == Fraction(0, 1) && !nextIsHeader) {
&& rtick()
== Fraction(0,
1) && nextSegment->rtick() == Fraction(0, 1) && !nextIsHeader && thisMeasureIsStartRepeat && prevMeasureIsEndRepeat) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something happened here in terms of formatting...

// Between repeats
return true;
}

if ((thisIsKeySig || thisIsTimeSig) && nextIsClef
&& rtick() == Fraction(0, 1) && nextSegment->rtick() == Fraction(0, 1) && !thisIsHeader) {
&& rtick()
== Fraction(0,
1) && nextSegment->rtick() == Fraction(0, 1) && !thisIsHeader && thisMeasureIsStartRepeat && prevMeasureIsEndRepeat) {
// Between repeats
return false;
}
Expand Down
20 changes: 16 additions & 4 deletions src/engraving/rendering/score/horizontalspacing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,7 @@ double HorizontalSpacing::minHorizontalDistance(const Segment* f, const Segment*
return f->minRight() + ns->minLeft() + f->style().styleMM(Sid::headerToLineStartDistance);
}

bool systemHeaderGap = f->segmentType() != SegmentType::ChordRest && f->segmentType() != SegmentType::StartRepeatBarLine
&& f->rtick().isZero() && !f->hasTimeSigAboveStaves()
&& (ns->measure()->isFirstInSystem() || ns->measure()->prev()->isHBox())
&& (ns->isStartRepeatBarLineType() || ns->isChordRestType() || (ns->isClefType() && !ns->header()));
bool systemHeaderGap = needsHeaderSpacingExceptions(f, ns);

double ww = -DBL_MAX; // can remain negative
double d = 0.0;
Expand Down Expand Up @@ -1280,6 +1277,21 @@ double HorizontalSpacing::minHorizontalDistance(const Segment* f, const Segment*
return w;
}

bool HorizontalSpacing::needsHeaderSpacingExceptions(const Segment* seg, const Segment* nextSeg)
{
static const std::unordered_set<SegmentType> HEADER_SEGMENT_TYPES = { SegmentType::HeaderClef,
SegmentType::KeySig,
SegmentType::KeySigStartRepeatAnnounce,
SegmentType::Ambitus,
SegmentType::TimeSig,
SegmentType::TimeSigStartRepeatAnnounce };

return muse::contains(HEADER_SEGMENT_TYPES, seg->segmentType())
&& seg->rtick().isZero() && !seg->hasTimeSigAboveStaves()
&& (nextSeg->measure()->isFirstInSystem() || nextSeg->measure()->prev()->isHBox())
&& (nextSeg->isStartRepeatBarLineType() || nextSeg->isChordRestType());
}

//---------------------------------------------------------
// minLeft
// Calculate minimum distance needed to the left shape
Expand Down
1 change: 1 addition & 0 deletions src/engraving/rendering/score/horizontalspacing.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class HorizontalSpacing
static double durationStretchForMMRests(const Segment* segment);
static double durationStretchForTicks(double slope, const Fraction& ticks);
static bool needsCueSizeSpacing(const Segment* segment);
static bool needsHeaderSpacingExceptions(const Segment* seg, const Segment* nextSeg);

static void applyCrossBeamSpacingCorrection(Segment* thisSeg, Segment* nextSeg, double& width);
static CrossBeamSpacing computeCrossBeamSpacing(Segment* thisSeg, Segment* nextSeg);
Expand Down
Binary file added vtest/scores/clefPosition.mscz
Binary file not shown.
Loading