Skip to content

Commit

Permalink
fix #277995: use tempoPosAbove/Below instead of tempoOffset in styles
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed Nov 26, 2018
1 parent 972e2ae commit 5c9f185
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
26 changes: 24 additions & 2 deletions libmscore/style.cpp
Expand Up @@ -713,7 +713,6 @@ static const StyleType styleTypes[] {
{ Sid::tempoFontItalic, "tempoFontItalic", false },
{ Sid::tempoFontUnderline, "tempoFontUnderline", false },
{ Sid::tempoAlign, "tempoAlign", QVariant::fromValue(Align::LEFT | Align::BASELINE) },
{ Sid::tempoOffset, "tempoOffset", QPointF(0.0, 0.0) },
{ Sid::tempoSystemFlag, "tempoSystemFlag", true },
{ Sid::tempoPlacement, "tempoPlacement", int(Placement::ABOVE) },
{ Sid::tempoPosAbove, "tempoPosAbove", QPointF(.0, -2.0) },
Expand Down Expand Up @@ -1382,7 +1381,7 @@ const TextStyle tempoTextStyle {{
{ Sid::tempoFontItalic, Pid::FONT_ITALIC },
{ Sid::tempoFontUnderline, Pid::FONT_UNDERLINE },
{ Sid::tempoAlign, Pid::ALIGN },
{ Sid::tempoOffset, Pid::OFFSET },
{ Sid::tempoPosAbove, Pid::OFFSET },
{ Sid::tempoFrameType, Pid::FRAME_TYPE },
{ Sid::tempoFramePadding, Pid::FRAME_PADDING },
{ Sid::tempoFrameWidth, Pid::FRAME_WIDTH },
Expand Down Expand Up @@ -2228,6 +2227,29 @@ bool MStyle::readProperties(XmlReader& e)
return true;
}
}
if (readStyleValCompat(e))
return true;
return false;
}

//---------------------------------------------------------
// readStyleValCompat
// Read obsolete style values which may appear in files
// produced by older versions of MuseScore.
//---------------------------------------------------------

bool MStyle::readStyleValCompat(XmlReader& e)
{
const QStringRef tag(e.name());
if (tag == "tempoOffset") { // pre-3.0-beta
const qreal x = e.doubleAttribute("x", 0.0);
const qreal y = e.doubleAttribute("y", 0.0);
const QPointF val(x, y);
set(Sid::tempoPosAbove, val);
set(Sid::tempoPosBelow, val);
e.readElementText();
return true;
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/style.h
Expand Up @@ -695,7 +695,6 @@ enum class Sid {
tempoFontItalic,
tempoFontUnderline,
tempoAlign,
tempoOffset,
tempoSystemFlag,
tempoPlacement,
tempoPosAbove,
Expand Down Expand Up @@ -1166,6 +1165,7 @@ class MStyle {
void load(XmlReader& e);
void save(XmlWriter& xml, bool optimize);
bool readProperties(XmlReader&);
bool readStyleValCompat(XmlReader&);

void reset(Score*);

Expand Down
11 changes: 11 additions & 0 deletions libmscore/tempotext.cpp
Expand Up @@ -473,5 +473,16 @@ QString TempoText::accessibleInfo() const
return TextBase::accessibleInfo();
}

//---------------------------------------------------------
// getPropertyStyle
//---------------------------------------------------------

Sid TempoText::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::tempoPosAbove : Sid::tempoPosBelow;
return TextBase::getPropertyStyle(pid);
}

}

1 change: 1 addition & 0 deletions libmscore/tempotext.h
Expand Up @@ -68,6 +68,7 @@ class TempoText final : public TextBase {
QVariant getProperty(Pid propertyId) const override;
bool setProperty(Pid propertyId, const QVariant&) override;
QVariant propertyDefault(Pid id) const override;
Sid getPropertyStyle(Pid) const override;
virtual QString accessibleInfo() const override;
};

Expand Down

0 comments on commit 5c9f185

Please sign in to comment.