Skip to content

Commit a8e1c85

Browse files
authored
Merge pull request #25374 from mike-spa/restCorrections
Breve-rest corrections
2 parents ee1a654 + 39d2fc3 commit a8e1c85

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

src/engraving/dom/rest.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,20 @@ int Rest::computeVoiceOffset(int lines, LayoutData* ldata) const
484484
return voiceLineOffset * upSign;
485485
}
486486

487-
int Rest::computeWholeRestOffset(int voiceOffset, int lines) const
487+
int Rest::computeWholeOrBreveRestOffset(int voiceOffset, int lines) const
488488
{
489-
if (!isWholeRest()) {
490-
return 0;
491-
}
492489
int lineMove = 0;
493-
bool moveToLineAbove = (lines > 5)
494-
|| ((lines > 1 || voiceOffset == -1 || voiceOffset == 2) && !(voiceOffset == -2 || voiceOffset == 1));
495-
if (moveToLineAbove) {
496-
lineMove = -1;
490+
if (isWholeRest()) {
491+
bool moveToLineAbove = (lines > 5)
492+
|| ((lines > 1 || voiceOffset == -1 || voiceOffset == 2) && !(voiceOffset == -2 || voiceOffset == 1));
493+
if (moveToLineAbove) {
494+
lineMove = -1;
495+
}
496+
} else if (isBreveRest() && lines == 1) {
497+
lineMove = 1;
497498
}
498499

499-
if (!isFullMeasureRest()) {
500+
if (!isFullMeasureRest() || !measure()) {
500501
return lineMove;
501502
}
502503

@@ -529,7 +530,7 @@ int Rest::computeWholeRestOffset(int voiceOffset, int lines) const
529530
}
530531
}
531532

532-
if (hasNotesAbove && hasNotesBelow) {
533+
if (hasNotesAbove == hasNotesBelow) {
533534
return lineMove; // Don't do anything
534535
}
535536

@@ -546,6 +547,10 @@ int Rest::computeWholeRestOffset(int voiceOffset, int lines) const
546547
lineMove = std::min(lineMove, topLine - centerLine);
547548
}
548549

550+
if (isBreveRest()) {
551+
lineMove++;
552+
}
553+
549554
return lineMove;
550555
}
551556

@@ -556,6 +561,13 @@ bool Rest::isWholeRest() const
556561
|| (durType == DurationType::V_MEASURE && measure() && measure()->ticks() < Fraction(2, 1));
557562
}
558563

564+
bool Rest::isBreveRest() const
565+
{
566+
TDuration durType = durationType();
567+
return durType == DurationType::V_BREVE
568+
|| (durType == DurationType::V_MEASURE && measure() && measure()->ticks() >= Fraction(2, 1));
569+
}
570+
559571
int Rest::computeNaturalLine(int lines) const
560572
{
561573
int line = (lines % 2) ? floor(double(lines) / 2) : ceil(double(lines) / 2);

src/engraving/dom/rest.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class Rest : public ChordRest
106106
void setAccent(bool flag);
107107

108108
bool isWholeRest() const;
109+
bool isBreveRest() const;
109110

110111
DeadSlapped* deadSlapped() const { return m_deadSlapped; }
111112

@@ -142,7 +143,7 @@ class Rest : public ChordRest
142143

143144
int computeNaturalLine(int lines) const; // Natural rest vertical position
144145
int computeVoiceOffset(int lines, LayoutData* ldata) const; // Vertical displacement in multi-voice cases
145-
int computeWholeRestOffset(int voiceOffset, int lines) const;
146+
int computeWholeOrBreveRestOffset(int voiceOffset, int lines) const;
146147

147148
SymId getSymbol(DurationType type, int line, int lines) const;
148149
void updateSymbol(int line, int lines, LayoutData* ldata) const;

src/engraving/rendering/score/tlayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4632,7 +4632,7 @@ void TLayout::layoutRest(const Rest* item, Rest::LayoutData* ldata, const Layout
46324632

46334633
int naturalLine = item->computeNaturalLine(lines); // Measured in 1sp steps
46344634
int voiceOffset = item->computeVoiceOffset(lines, ldata); // Measured in 1sp steps
4635-
int wholeRestOffset = item->computeWholeRestOffset(voiceOffset, lines);
4635+
int wholeRestOffset = item->computeWholeOrBreveRestOffset(voiceOffset, lines);
46364636
int finalLine = naturalLine + voiceOffset + wholeRestOffset;
46374637

46384638
ldata->sym = item->getSymbol(item->durationType().type(), finalLine + userLine, lines);

vtest/scores/rests-10.mscz

17.3 KB
Binary file not shown.

vtest/scores/rests-9.mscz

17.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)