Skip to content

Commit

Permalink
fix #289148: lyrics offset issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed May 17, 2019
1 parent a18d446 commit df26e39
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
25 changes: 25 additions & 0 deletions libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ void Lyrics::read(XmlReader& e)
if (!readProperties(e))
e.unknown();
}
if (!isStyled(Pid::OFFSET) && !e.pasteMode()) {
// fix offset for pre-3.1 scores
// 3.0: y offset was meaningless if autoplace is set
if (autoplace() && score()->mscoreVersion() < "3.1") {
QPointF off = propertyDefault(Pid::OFFSET).toPointF();
ryoffset() = off.y();
}
}
}

//---------------------------------------------------------
Expand Down Expand Up @@ -604,6 +612,23 @@ void Lyrics::undoChangeProperty(Pid id, const QVariant& v, PropertyFlags ps)
TextBase::undoChangeProperty(id, v, ps);
return;
}
else if (id == Pid::AUTOPLACE && v.toBool() != autoplace()) {
if (v.toBool()) {
// setting autoplace
// reset offset
undoResetProperty(Pid::OFFSET);
}
else {
// unsetting autoplace
// rebase offset
QPointF off = offset();
qreal y = pos().y() - propertyDefault(Pid::OFFSET).toPointF().y();
off.ry() = placeAbove() ? y : y - staff()->height();
undoChangeProperty(Pid::OFFSET, off, PropertyFlags::UNSTYLED);
}
TextBase::undoChangeProperty(id, v, ps);
return;
}
#if 0
// TODO: create new command to do this
if (id == Pid::PLACEMENT) {
Expand Down
12 changes: 10 additions & 2 deletions libmscore/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,16 @@ static void readLyrics(Lyrics* lyrics, XmlReader& e)
delete _verseNumber;
}
lyrics->setAutoplace(true);
lyrics->setOffset(QPointF());
//TODO-offset lyrics->setOffset(QPointF());
if (!lyrics->isStyled(Pid::OFFSET) && !e.pasteMode()) {
// fix offset for pre-3.1 scores
// 2.x and earlier: y offset was relative to staff; x offset was relative to center of notehead
lyrics->rxoffset() -= lyrics->symWidth(SymId::noteheadBlack) * 0.5;
//lyrics->ryoffset() -= lyrics->placeBelow() && lyrics->staff() ? lyrics->staff()->height() : 0.0;
// temporarily set placement to above, since the original offset is relative to top of staff
// depend on adjustPlacement() to change the placement if appropriate
lyrics->setPlacement(Placement::ABOVE);
adjustPlacement(lyrics);
}
}

//---------------------------------------------------------
Expand Down

0 comments on commit df26e39

Please sign in to comment.