diff --git a/libmscore/line.cpp b/libmscore/line.cpp index 2f3ac3063b..6d5f1c5848 100644 --- a/libmscore/line.cpp +++ b/libmscore/line.cpp @@ -405,7 +405,7 @@ void LineSegment::localSpatiumChanged(qreal ov, qreal nv) Element* LineSegment::propertyDelegate(Pid pid) { if (pid == Pid::DIAGONAL - || pid == Pid::LINE_COLOR + || pid == Pid::COLOR || pid == Pid::LINE_WIDTH || pid == Pid::LINE_STYLE || pid == Pid::DASH_LINE_LEN @@ -959,7 +959,7 @@ void SLine::writeProperties(XmlWriter& xml) const xml.tag("diagonal", _diagonal); writeProperty(xml, Pid::LINE_WIDTH); writeProperty(xml, Pid::LINE_STYLE); - writeProperty(xml, Pid::LINE_COLOR); + writeProperty(xml, Pid::COLOR); writeProperty(xml, Pid::ANCHOR); writeProperty(xml, Pid::DASH_LINE_LEN); writeProperty(xml, Pid::DASH_GAP_LEN); @@ -1040,6 +1040,8 @@ bool SLine::readProperties(XmlReader& e) _dashGapLen = e.readDouble(); else if (tag == "lineColor") _lineColor = e.readColor(); + else if (tag == "color") + _lineColor = e.readColor(); else if (!Element::readProperties(e)) return false; return true; @@ -1110,7 +1112,7 @@ QVariant SLine::getProperty(Pid id) const switch (id) { case Pid::DIAGONAL: return _diagonal; - case Pid::LINE_COLOR: + case Pid::COLOR: return _lineColor; case Pid::LINE_WIDTH: return _lineWidth; @@ -1135,7 +1137,7 @@ bool SLine::setProperty(Pid id, const QVariant& v) case Pid::DIAGONAL: _diagonal = v.toBool(); break; - case Pid::LINE_COLOR: + case Pid::COLOR: _lineColor = v.value(); break; case Pid::LINE_WIDTH: @@ -1166,7 +1168,7 @@ QVariant SLine::propertyDefault(Pid pid) const switch (pid) { case Pid::DIAGONAL: return false; - case Pid::LINE_COLOR: + case Pid::COLOR: return MScore::defaultColor; case Pid::LINE_WIDTH: if (propertyFlags(pid) != PropertyFlags::NOSTYLE) diff --git a/libmscore/property.cpp b/libmscore/property.cpp index 6f295d7813..e31795daf7 100644 --- a/libmscore/property.cpp +++ b/libmscore/property.cpp @@ -167,7 +167,6 @@ static constexpr PropertyMetaData propertyList[] = { { Pid::DIAGONAL, false, 0, P_TYPE::BOOL, DUMMY_QT_TRANSLATE_NOOP("propertyName", "diagonal") }, { Pid::GROUPS, false, 0, P_TYPE::GROUPS, DUMMY_QT_TRANSLATE_NOOP("propertyName", "groups") }, { Pid::LINE_STYLE, false, "lineStyle", P_TYPE::INT, DUMMY_QT_TRANSLATE_NOOP("propertyName", "line style") }, - { Pid::LINE_COLOR, false, 0, P_TYPE::COLOR, DUMMY_QT_TRANSLATE_NOOP("propertyName", "line color") }, { Pid::LINE_WIDTH, false, "lineWidth", P_TYPE::SP_REAL, DUMMY_QT_TRANSLATE_NOOP("propertyName", "line width") }, { Pid::LASSO_POS, false, 0, P_TYPE::POINT_MM, DUMMY_QT_TRANSLATE_NOOP("propertyName", "lasso position") }, { Pid::LASSO_SIZE, false, 0, P_TYPE::SIZE_MM, DUMMY_QT_TRANSLATE_NOOP("propertyName", "lasso size") }, diff --git a/libmscore/property.h b/libmscore/property.h index a8061b6561..355176707b 100644 --- a/libmscore/property.h +++ b/libmscore/property.h @@ -185,7 +185,6 @@ enum class Pid { DIAGONAL, GROUPS, LINE_STYLE, - LINE_COLOR, LINE_WIDTH, LASSO_POS, LASSO_SIZE, diff --git a/mscore/inspector/inspectorTextLineBase.cpp b/mscore/inspector/inspectorTextLineBase.cpp index 68853869c5..75ca8c3794 100644 --- a/mscore/inspector/inspectorTextLineBase.cpp +++ b/mscore/inspector/inspectorTextLineBase.cpp @@ -57,7 +57,7 @@ InspectorTextLineBase::InspectorTextLineBase(QWidget* parent) const std::vector iiList = { { Pid::DIAGONAL, 0, l.diagonal, l.resetDiagonal }, { Pid::LINE_VISIBLE, 0, l.lineVisible, l.resetLineVisible }, - { Pid::LINE_COLOR, 0, l.lineColor, l.resetLineColor }, + { Pid::COLOR, 0, l.lineColor, l.resetLineColor }, { Pid::LINE_WIDTH, 0, l.lineWidth, l.resetLineWidth }, { Pid::LINE_STYLE, 0, l.lineStyle, l.resetLineStyle }, { Pid::DASH_LINE_LEN, 0, l.dashLineLength, l.resetDashLineLength }, @@ -196,6 +196,8 @@ void InspectorTextLineBase::valueChanged(int idx) updateBeginHookType(); else if (iList[idx].t == Pid::END_HOOK_TYPE) updateEndHookType(); + else if (iList[idx].t == Pid::COLOR) + inspector->update(); } diff --git a/mscore/plugin/api/elements.h b/mscore/plugin/api/elements.h index 23aaf1c904..4172818d4d 100644 --- a/mscore/plugin/api/elements.h +++ b/mscore/plugin/api/elements.h @@ -159,7 +159,7 @@ class Element : public Ms::PluginAPI::ScoreElement { API_PROPERTY( diagonal, DIAGONAL ) API_PROPERTY( groups, GROUPS ) API_PROPERTY( lineStyle, LINE_STYLE ) - API_PROPERTY( lineColor, LINE_COLOR ) + API_PROPERTY( lineColor, COLOR ) API_PROPERTY( lineWidth, LINE_WIDTH ) API_PROPERTY( lassoPos, LASSO_POS ) API_PROPERTY( lassoSize, LASSO_SIZE ) diff --git a/mtest/libmscore/spanners/linecolor01-ref.mscx b/mtest/libmscore/spanners/linecolor01-ref.mscx new file mode 100644 index 0000000000..0bef295aab --- /dev/null +++ b/mtest/libmscore/spanners/linecolor01-ref.mscx @@ -0,0 +1,148 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + stdNormal + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 150 + 100 + + + 150 + 50 + + + 120 + 50 + + + 120 + 100 + + + + + + + + + + + 4 + 4 + + + + 1 + 1 + + + + + + 1 + + + + + measure + 4/4 + + + + + + + + + -1 + + + + + measure + 4/4 + + + + + + + measure + 4/4 + + + + + + + measure + 4/4 + + + + + + diff --git a/mtest/libmscore/spanners/linecolor01.mscx b/mtest/libmscore/spanners/linecolor01.mscx new file mode 100644 index 0000000000..1544d7197f --- /dev/null +++ b/mtest/libmscore/spanners/linecolor01.mscx @@ -0,0 +1,157 @@ + + + 3.1.0 + 3543170 + + + 0 + + + 480 + + 1 + 1 + 1 + 0 + + + + 2019-02-18 + + + + Linux + + + + + + + + + stdNormal + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 150 + 100 + + + 150 + 50 + + + 120 + 50 + + + 120 + 100 + + + + Fluid + + + + + + + + + 4 + 4 + + + + 1 + 1 + + + + 1 + + + + + measure + 4/4 + + + + + + + + + + -1 + + + + + measure + 4/4 + + + + + + + + measure + 4/4 + + + + + + + + measure + 4/4 + + + + + + diff --git a/mtest/libmscore/spanners/tst_spanners.cpp b/mtest/libmscore/spanners/tst_spanners.cpp index 80e1700081..e7d02d38ab 100644 --- a/mtest/libmscore/spanners/tst_spanners.cpp +++ b/mtest/libmscore/spanners/tst_spanners.cpp @@ -23,6 +23,7 @@ #include "libmscore/score.h" #include "libmscore/system.h" #include "libmscore/undo.h" +#include "libmscore/line.h" #define DIR QString("libmscore/spanners/") @@ -52,6 +53,7 @@ class TestSpanners : public QObject, public MTest void spanners12(); // remove a measure containing the middle portion of a LyricsLine and undo // void spanners13(); // drop a line break at the middle of a LyricsLine and check LyricsLineSegments void spanners14(); // creating part from an existing grand staff containing a cross staff glissando + void spanners15(); // change the color of a line and save it }; //--------------------------------------------------------- @@ -621,6 +623,26 @@ void TestSpanners::spanners14() delete score; } +//--------------------------------------------------------- +/// spanners15 +/// set the color of a spanner and save +//--------------------------------------------------------- + +void TestSpanners::spanners15() + { + MasterScore* score = readScore(DIR + "linecolor01.mscx"); + QVERIFY(score); + + for (auto it = score->spanner().cbegin(); it != score->spanner().cend(); ++it) { + Spanner* spanner = (*it).second; + SLine* sl = static_cast(spanner); + sl->setProperty(Pid::COLOR, QVariant::fromValue(QColor(255, 0, 0, 255))); + } + + QVERIFY(saveCompareScore(score, "linecolor01.mscx", DIR + "linecolor01-ref.mscx")); + delete score; + } + QTEST_MAIN(TestSpanners)