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

Several corrections to rests with ledger lines #16880

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/engraving/libmscore/engravingitem.cpp
Expand Up @@ -55,6 +55,7 @@
#include "mscore.h"
#include "note.h"
#include "page.h"
#include "rest.h"
#include "score.h"
#include "segment.h"
#include "shape.h"
Expand Down Expand Up @@ -2704,6 +2705,16 @@ double EngravingItem::computePadding(const EngravingItem* nextItem) const
double scaling = (mag() + nextItem->mag()) / 2;
double padding = score()->paddingTable().at(type()).at(nextItem->type());
padding *= scaling;
if (!isLedgerLine() && nextItem->isRest()) {
const Rest* rest = toRest(nextItem);
SymId symbol = rest->sym();
if (symbol == SymId::restWholeLegerLine
|| symbol == SymId::restDoubleWholeLegerLine
|| symbol == SymId::restHalfLegerLine) {
// In this case the ledgerLine is included in the glyph itself, so we must ignore it
padding += rest->bbox().left();
}
}
return padding;
}
}
20 changes: 19 additions & 1 deletion src/engraving/libmscore/rest.cpp
Expand Up @@ -414,7 +414,7 @@ void Rest::layout()
void Rest::layoutDots()
{
checkDots();
double x = symWidth(m_sym) + score()->styleMM(Sid::dotNoteDistance) * mag();
double x = symWidthNoLedgerLines() + score()->styleMM(Sid::dotNoteDistance) * mag();
double dx = score()->styleMM(Sid::dotDotDistance) * mag();
double y = m_dotline * spatium() * .5;
for (NoteDot* dot : m_dots) {
Expand All @@ -424,6 +424,20 @@ void Rest::layoutDots()
}
}

double Rest::symWidthNoLedgerLines() const
{
if (m_sym == SymId::restHalfLegerLine) {
return symWidth(SymId::restHalf);
}
if (m_sym == SymId::restWholeLegerLine) {
return symWidth(SymId::restWhole);
}
if (m_sym == SymId::restDoubleWholeLegerLine) {
return symWidth(SymId::restDoubleWhole);
}
return symWidth(m_sym);
}

//---------------------------------------------------------
// checkDots
//---------------------------------------------------------
Expand Down Expand Up @@ -477,6 +491,10 @@ int Rest::getDotline(DurationType durationType)
case DurationType::V_128TH:
dl = -5;
break;
case DurationType::V_MEASURE:
case DurationType::V_WHOLE:
dl = 1;
break;
default:
dl = -1;
break;
Expand Down
1 change: 1 addition & 0 deletions src/engraving/libmscore/rest.h
Expand Up @@ -77,6 +77,7 @@ class Rest : public ChordRest

void checkDots();
void layoutDots();
double symWidthNoLedgerLines() const;
NoteDot* dot(int n);
const std::vector<NoteDot*>& dotList() const;
int getDotline() const { return m_dotline; }
Expand Down
Binary file added vtest/scores/rests-4.mscz
Binary file not shown.