Skip to content

Commit

Permalink
Fix errors in header distances calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Feb 28, 2025
1 parent d49a3f4 commit 435802e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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

0 comments on commit 435802e

Please sign in to comment.