Skip to content

Commit

Permalink
fix #272366 There are no System Text properties
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 28, 2018
1 parent caf2af6 commit 6f6e86a
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 88 deletions.
9 changes: 9 additions & 0 deletions libmscore/scoreElement.h
Expand Up @@ -130,6 +130,8 @@ class VibratoSegment;
class PalmMute;
class PalmMuteSegment;

class StaffTextBase;

enum class Pid : int;
enum class PropertyFlags : char;
enum class Sid : int;
Expand Down Expand Up @@ -387,6 +389,9 @@ class ScoreElement {
|| isSLine()
;
}
bool isStaffTextBase() const {
return isStaffText() || isSystemText();
}
};

//---------------------------------------------------
Expand Down Expand Up @@ -461,6 +466,10 @@ static inline TextBase* toTextBase(ScoreElement* e) {
Q_ASSERT(e == 0 || e->isTextBase());
return (TextBase*)e;
}
static inline StaffTextBase* toStaffTextBase(ScoreElement* e) {
Q_ASSERT(e == 0 || e->isStaffTextBase());
return (StaffTextBase*)e;
}

#define CONVERT(a) \
static inline a* to##a(ScoreElement* e) { Q_ASSERT(e == 0 || e->is##a()); return (a*)e; } \
Expand Down
50 changes: 30 additions & 20 deletions libmscore/stafftext.cpp
Expand Up @@ -20,20 +20,15 @@
namespace Ms {

//---------------------------------------------------------
// StaffText
// StaffTextBase
//---------------------------------------------------------

StaffText::StaffText(Score* s)
: TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)
{
initSubStyle(SubStyleId::STAFF);
setSwingParameters(MScore::division / 2, 60);
}
// : TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)

StaffText::StaffText(SubStyleId ss, Score* s)
: TextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)
StaffTextBase::StaffTextBase(Score* s, ElementFlags flags)
: TextBase(s, flags)
{
initSubStyle(ss);
// initSubStyle(ss);
setPlacement(Placement::ABOVE); // default
setSwingParameters(MScore::division / 2, 60);
}
Expand All @@ -42,7 +37,7 @@ StaffText::StaffText(SubStyleId ss, Score* s)
// write
//---------------------------------------------------------

void StaffText::write(XmlWriter& xml) const
void StaffTextBase::write(XmlWriter& xml) const
{
if (!xml.canWrite(this))
return;
Expand Down Expand Up @@ -81,7 +76,7 @@ void StaffText::write(XmlWriter& xml) const
// read
//---------------------------------------------------------

void StaffText::read(XmlReader& e)
void StaffTextBase::read(XmlReader& e)
{
for (int voice = 0; voice < VOICES; ++voice)
_channelNames[voice].clear();
Expand All @@ -96,7 +91,7 @@ void StaffText::read(XmlReader& e)
// readProperties
//---------------------------------------------------------

bool StaffText::readProperties(XmlReader& e)
bool StaffTextBase::readProperties(XmlReader& e)
{
const QStringRef& tag(e.name());

Expand Down Expand Up @@ -164,7 +159,7 @@ bool StaffText::readProperties(XmlReader& e)
// clearAeolusStops
//---------------------------------------------------------

void StaffText::clearAeolusStops()
void StaffTextBase::clearAeolusStops()
{
for (int i = 0; i < 4; ++i)
aeolusStops[i] = 0;
Expand All @@ -174,7 +169,7 @@ void StaffText::clearAeolusStops()
// setAeolusStop
//---------------------------------------------------------

void StaffText::setAeolusStop(int group, int idx, bool val)
void StaffTextBase::setAeolusStop(int group, int idx, bool val)
{
if (val)
aeolusStops[group] |= (1 << idx);
Expand All @@ -186,7 +181,7 @@ void StaffText::setAeolusStop(int group, int idx, bool val)
// getAeolusStop
//---------------------------------------------------------

bool StaffText::getAeolusStop(int group, int idx) const
bool StaffTextBase::getAeolusStop(int group, int idx) const
{
return aeolusStops[group] & (1 << idx);
}
Expand All @@ -195,7 +190,7 @@ bool StaffText::getAeolusStop(int group, int idx) const
// layout
//---------------------------------------------------------

void StaffText::layout()
void StaffTextBase::layout()
{
Staff* s = staff();
qreal y = placeAbove() ? styleP(Sid::staffTextPosAbove) : styleP(Sid::staffTextPosBelow) + (s ? s->height() : 0.0);
Expand All @@ -208,10 +203,10 @@ void StaffText::layout()
// segment
//---------------------------------------------------------

Segment* StaffText::segment() const
Segment* StaffTextBase::segment() const
{
if (!parent()->isSegment()) {
qDebug("StaffText parent %s\n", parent()->name());
qDebug("parent %s", parent()->name());
return 0;
}
Segment* s = toSegment(parent());
Expand All @@ -222,7 +217,7 @@ Segment* StaffText::segment() const
// propertyDefault
//---------------------------------------------------------

QVariant StaffText::propertyDefault(Pid id) const
QVariant StaffTextBase::propertyDefault(Pid id) const
{
switch(id) {
case Pid::SUB_STYLE:
Expand All @@ -236,5 +231,20 @@ QVariant StaffText::propertyDefault(Pid id) const
}
}

//---------------------------------------------------------
// StaffText
//---------------------------------------------------------

StaffText::StaffText(Score* s)
: StaffTextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)
{
initSubStyle(SubStyleId::STAFF);
}

StaffText::StaffText(SubStyleId ss, Score* s)
: StaffTextBase(s, ElementFlag::MOVABLE | ElementFlag::SELECTABLE | ElementFlag::ON_STAFF)
{
initSubStyle(ss);
}
}

22 changes: 16 additions & 6 deletions libmscore/stafftext.h
Expand Up @@ -29,10 +29,10 @@ struct ChannelActions {
};

//---------------------------------------------------------
// @@ StaffText
// StaffTextBase
//---------------------------------------------------------

class StaffText final : public TextBase {
class StaffTextBase : public TextBase {
QString _channelNames[4];
QList<ChannelActions> _channelActions;
SwingParameters _swingParameters;
Expand All @@ -41,10 +41,7 @@ class StaffText final : public TextBase {
bool _swing { false };

public:
StaffText(Score* = 0);
StaffText(SubStyleId, Score* = 0);
virtual StaffText* clone() const { return new StaffText(*this); }
virtual ElementType type() const { return ElementType::STAFF_TEXT; }
StaffTextBase(Score* = 0, ElementFlags = ElementFlag::NOTHING);

virtual void write(XmlWriter& xml) const override;
virtual void read(XmlReader&) override;
Expand All @@ -70,5 +67,18 @@ class StaffText final : public TextBase {
bool swing() const { return _swing; }
};

//---------------------------------------------------------
// SystemText
//---------------------------------------------------------

class StaffText final : public StaffTextBase {
public:
StaffText(Score* score);
StaffText(SubStyleId, Score* = 0);
virtual StaffText* clone() const override { return new StaffText(*this); }
virtual ElementType type() const override { return ElementType::STAFF_TEXT; }
};


} // namespace Ms
#endif
6 changes: 3 additions & 3 deletions libmscore/systemtext.cpp
Expand Up @@ -19,13 +19,13 @@ namespace Ms {
//---------------------------------------------------------

SystemText::SystemText(Score* s)
: TextBase(s, ElementFlag::SYSTEM)
: StaffTextBase(s, ElementFlag::SYSTEM)
{
initSubStyle(SubStyleId::SYSTEM);
}

SystemText::SystemText(SubStyleId ss, Score* s)
: TextBase(s, ElementFlag::SYSTEM)
SystemText::SystemText(SubStyleId ss, Score* s, ElementFlags flags)
: StaffTextBase(s, flags)
{
initSubStyle(ss);
}
Expand Down
4 changes: 2 additions & 2 deletions libmscore/systemtext.h
Expand Up @@ -21,10 +21,10 @@ namespace Ms {
// SystemText
//---------------------------------------------------------

class SystemText final : public TextBase {
class SystemText final : public StaffTextBase {
public:
SystemText(Score* score);
SystemText(SubStyleId, Score* = 0);
SystemText(SubStyleId, Score* = 0, ElementFlags = ElementFlag::NOTHING);
virtual SystemText* clone() const override { return new SystemText(*this); }
virtual ElementType type() const override { return ElementType::SYSTEM_TEXT; }
Segment* segment() const { return (Segment*)parent(); }
Expand Down
2 changes: 1 addition & 1 deletion mscore/events.cpp
Expand Up @@ -400,8 +400,8 @@ void ScoreView::mousePressEvent(QMouseEvent* ev)
}
else {
if (!editData.element->canvasBoundingRect().contains(editData.startMove)) {
editData.element = e;
changeState(ViewState::NORMAL);
editData.element = e;
mousePressEventNormal(ev);
}
else {
Expand Down

0 comments on commit 6f6e86a

Please sign in to comment.