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

fix #301259: wrong text offset for non-default text styles #5947

Merged
merged 3 commits into from
Apr 28, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions libmscore/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,6 @@ QString Dynamic::propertyUserValue(Pid pid) const
return TextBase::propertyUserValue(pid);
}

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

Sid Dynamic::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::dynamicsPosAbove : Sid::dynamicsPosBelow;
return TextBase::getPropertyStyle(pid);
}

//---------------------------------------------------------
// accessibleInfo
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion libmscore/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class Dynamic final : public TextBase {
Speed _velChangeSpeed { Speed::NORMAL };

QRectF drag(EditData&) override;
Sid getPropertyStyle(Pid) const override;

public:
Dynamic(Score*);
Expand Down
11 changes: 0 additions & 11 deletions libmscore/lyrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,17 +574,6 @@ QVariant Lyrics::propertyDefault(Pid id) const
}
}

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

Sid Lyrics::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::lyricsPosAbove : Sid::lyricsPosBelow;
return TextBase::getPropertyStyle(pid);
}

//---------------------------------------------------------
// forAllLyrics
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion libmscore/lyrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class Lyrics 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;
};

//---------------------------------------------------------
Expand Down
11 changes: 0 additions & 11 deletions libmscore/rehearsalmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,5 @@ QVariant RehearsalMark::propertyDefault(Pid id) const
}
}

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

Sid RehearsalMark::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::rehearsalMarkPosAbove : Sid::rehearsalMarkPosBelow;
return TextBase::getPropertyStyle(pid);
}

} // namespace Ms

1 change: 0 additions & 1 deletion libmscore/rehearsalmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Ms {
//---------------------------------------------------------

class RehearsalMark final : public TextBase {
Sid getPropertyStyle(Pid) const override;

public:
RehearsalMark(Score* score);
Expand Down
11 changes: 0 additions & 11 deletions libmscore/stafftext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,5 @@ QVariant StaffText::propertyDefault(Pid id) const
}
}

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

Sid StaffText::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::staffTextPosAbove : Sid::staffTextPosBelow;
return TextBase::getPropertyStyle(pid);
}

}

1 change: 0 additions & 1 deletion libmscore/stafftext.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace Ms {

class StaffText final : public StaffTextBase {

Sid getPropertyStyle(Pid) const override;
QVariant propertyDefault(Pid id) const override;

public:
Expand Down
10 changes: 0 additions & 10 deletions libmscore/sticking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,5 @@ QVariant Sticking::propertyDefault(Pid id) const
}
}

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

Sid Sticking::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::stickingPosAbove : Sid::stickingPosBelow;
return TextBase::getPropertyStyle(pid);
}
}

1 change: 0 additions & 1 deletion libmscore/sticking.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace Ms {
//-----------------------------------------------------------------------------

class Sticking final : public TextBase {
Sid getPropertyStyle(Pid) const override;
QVariant propertyDefault(Pid id) const override;

public:
Expand Down
11 changes: 0 additions & 11 deletions libmscore/systemtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,5 @@ void SystemText::layout()
autoplaceSegmentElement();
}

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

Sid SystemText::getPropertyStyle(Pid pid) const
{
if (pid == Pid::OFFSET)
return placeAbove() ? Sid::systemTextPosAbove : Sid::systemTextPosBelow;
return TextBase::getPropertyStyle(pid);
}

} // namespace Ms

1 change: 0 additions & 1 deletion libmscore/systemtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Ms {

class SystemText final : public StaffTextBase {
void layout() override;
Sid getPropertyStyle(Pid) const override;
QVariant propertyDefault(Pid id) const override;

public:
Expand Down
11 changes: 0 additions & 11 deletions libmscore/tempotext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,5 @@ 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: 0 additions & 1 deletion libmscore/tempotext.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ 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;
QString accessibleInfo() const override;
};

Expand Down
37 changes: 37 additions & 0 deletions libmscore/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,12 +2476,49 @@ int TextBase::getPropertyFlagsIdx(Pid id) const
return -1;
}

//---------------------------------------------------------
// offsetSid
//---------------------------------------------------------

Sid TextBase::offsetSid() const
{
Tid defaultTid = Tid(propertyDefault(Pid::SUB_STYLE).toInt());
if (tid() != defaultTid)
return Sid::NOSTYLE;
bool above = placeAbove();
switch (tid()) {
case Tid::DYNAMICS:
return above ? Sid::dynamicsPosAbove : Sid::dynamicsPosBelow;
case Tid::LYRICS_ODD:
case Tid::LYRICS_EVEN:
return above ? Sid::lyricsPosAbove : Sid::lyricsPosBelow;
case Tid::REHEARSAL_MARK:
return above ? Sid::rehearsalMarkPosAbove : Sid::rehearsalMarkPosBelow;
case Tid::STAFF:
return above ? Sid::staffTextPosAbove : Sid::staffTextPosBelow;
case Tid::STICKING:
return above ? Sid::stickingPosAbove : Sid::stickingPosBelow;
case Tid::SYSTEM:
return above ? Sid::systemTextPosAbove : Sid::systemTextPosBelow;
case Tid::TEMPO:
return above ? Sid::tempoPosAbove : Sid::tempoPosBelow;
default:
break;
}
return Sid::NOSTYLE;
}

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

Sid TextBase::getPropertyStyle(Pid id) const
{
if (id == Pid::OFFSET) {
Sid sid = offsetSid();
if (sid != Sid::NOSTYLE)
return sid;
}
for (const StyledProperty& p : *_elementStyle) {
if (p.pid == id)
return p.sid;
Expand Down
1 change: 1 addition & 0 deletions libmscore/textbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class TextBase : public Element {
void genText() const;
virtual int getPropertyFlagsIdx(Pid id) const override;
QString stripText(bool, bool, bool) const;
Sid offsetSid() const;

protected:
QColor textColor() const;
Expand Down