Skip to content

Commit

Permalink
fix grace note layout
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jul 6, 2017
1 parent dfa6ed0 commit d0a4afc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 43 deletions.
6 changes: 0 additions & 6 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,6 @@ void Chord::layoutStem()
// NON-TAB (or TAB with stems through staff)
//
if (_stem) {
// if (isGrace())
// abort();
if (_hook) {
_hook->layout();
QPointF p(_stem->hookPos());
Expand Down Expand Up @@ -2053,10 +2051,6 @@ void Chord::layoutPitched()

for (Note* note : _notes)
note->layout2();

// QRectF bb;
// processSiblings([&bb] (Element* e) { bb |= e->bbox().translated(e->pos()); } );
// setbbox(bb.translated(_spatium*2, 0));
}

//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ QVariant ChordRest::propertyDefault(P_ID propertyId) const

bool ChordRest::isGrace() const
{
return isChord() && toChord(this)->noteType() != NoteType::NORMAL;
return isChord() && toChord(this)->isGrace();
}

//---------------------------------------------------------
Expand Down
69 changes: 34 additions & 35 deletions libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,8 +2313,7 @@ void Score::getNextMeasure(LayoutContext& lc)
Staff* staff = Score::staff(staffIdx);
const Drumset* drumset = staff->part()->instrument()->useDrumset() ? staff->part()->instrument()->drumset() : 0;
AccidentalState as; // list of already set accidentals for this measure
int tick = measure->tick();
as.init(staff->keySigEvent(tick), staff->clef(tick));
as.init(staff->keySigEvent(measure->tick()), staff->clef(measure->tick()));

for (Segment& segment : measure->segments()) {
if (segment.isKeySigType()) {
Expand All @@ -2331,43 +2330,43 @@ void Score::getNextMeasure(LayoutContext& lc)

for (int t = track; t < endTrack; ++t) {
ChordRest* cr = segment.cr(t);
if (cr) {
qreal m = staff->mag(segment.tick());
if (cr->small())
m *= score()->styleD(StyleIdx::smallNoteMag);

if (cr->isChord()) {
Chord* chord = toChord(cr);
for (Chord* c : chord->graceNotes()) {
c->setMag(m * score()->styleD(StyleIdx::graceNoteMag));
c->computeUp();
if (c->stemDirection() != Direction::AUTO)
c->setUp(c->stemDirection() == Direction::UP);
else
c->setUp(!(t % 2));
c->layoutStem1();
}
chord->cmdUpdateNotes(&as);
if (drumset) {
for (Note* note : chord->notes()) {
int pitch = note->pitch();
if (!drumset->isValid(pitch)) {
// qDebug("unmapped drum note %d", pitch);
}
else if (!note->fixed()) {
note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch)));
// note->setHeadGroup(drumset->noteHead(pitch));
note->setLine(drumset->line(pitch));
continue;
}
if (!cr)
continue;
qreal m = staff->mag(segment.tick());
if (cr->small())
m *= score()->styleD(StyleIdx::smallNoteMag);

if (cr->isChord()) {
Chord* chord = toChord(cr);
chord->cmdUpdateNotes(&as);
for (Chord* c : chord->graceNotes()) {
c->setMag(m * score()->styleD(StyleIdx::graceNoteMag));
c->computeUp();
if (c->stemDirection() != Direction::AUTO)
c->setUp(c->stemDirection() == Direction::UP);
else
c->setUp(!(t % 2));
c->layoutStem1();
}
if (drumset) {
for (Note* note : chord->notes()) {
int pitch = note->pitch();
if (!drumset->isValid(pitch)) {
// qDebug("unmapped drum note %d", pitch);
}
else if (!note->fixed()) {
note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch)));
// note->setHeadGroup(drumset->noteHead(pitch));
note->setLine(drumset->line(pitch));
continue;
}
}
chord->computeUp();
chord->layoutStem1(); // create stems needed to calculate spacing
// stem direction can change later during beam processing
}
cr->setMag(m);
chord->computeUp();
chord->layoutStem1(); // create stems needed to calculate spacing
// stem direction can change later during beam processing
}
cr->setMag(m);
}
}
else if (segment.isClefType()) {
Expand Down
1 change: 0 additions & 1 deletion libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ void MeasureBaseList::insert(MeasureBase* fm, MeasureBase* lm)

void MeasureBaseList::remove(MeasureBase* fm, MeasureBase* lm)
{
printf("remove measures %p %p\n", fm, lm);
--_size;
for (MeasureBase* m = fm; m != lm; m = m->next())
--_size;
Expand Down

0 comments on commit d0a4afc

Please sign in to comment.