diff --git a/libmscore/property.cpp b/libmscore/property.cpp index a5d882bac5..5f62e17acf 100644 --- a/libmscore/property.cpp +++ b/libmscore/property.cpp @@ -210,6 +210,7 @@ static const PropertyData propertyList[] = { { P_ID::LYRIC_TICKS, true, "ticks", P_TYPE::INT }, { P_ID::VOLTA_ENDING, true, "endings", P_TYPE::INT_LIST }, + { P_ID::LINE_VISIBLE, true, "lineVisible", P_TYPE::BOOL }, { P_ID::END, false, "", P_TYPE::INT } }; diff --git a/libmscore/property.h b/libmscore/property.h index c8a6eabab3..3703233446 100644 --- a/libmscore/property.h +++ b/libmscore/property.h @@ -207,6 +207,7 @@ enum class P_ID : unsigned char { LYRIC_TICKS, VOLTA_ENDING, + LINE_VISIBLE, END }; diff --git a/libmscore/textline.cpp b/libmscore/textline.cpp index ab7959dacf..98a413e40d 100644 --- a/libmscore/textline.cpp +++ b/libmscore/textline.cpp @@ -103,48 +103,53 @@ void TextLineSegment::draw(QPainter* painter) const painter->translate(-_endText->pos()); } } - QPen pen(normalColor ? tl->lineColor() : color, textlineLineWidth, tl->lineStyle()); - painter->setPen(pen); - QPointF pp1(l, 0.0); + if (tl->lineVisible() || !score()->printing()) { + QPen pen(normalColor ? tl->lineColor() : color, textlineLineWidth, tl->lineStyle()); + if (!tl->lineVisible()) + pen.setColor(Qt::gray); + painter->setPen(pen); - qreal beginHookWidth; - qreal endHookWidth; + QPointF pp1(l, 0.0); - if (tl->beginHook() && tl->beginHookType() == HookType::HOOK_45) { - beginHookWidth = fabs(tl->beginHookHeight().val() * _spatium * .4); - pp1.rx() += beginHookWidth; - } - else - beginHookWidth = 0; + qreal beginHookWidth; + qreal endHookWidth; - if (tl->endHook() && tl->endHookType() == HookType::HOOK_45) { - endHookWidth = fabs(tl->endHookHeight().val() * _spatium * .4); - pp2.rx() -= endHookWidth; - } - else - endHookWidth = 0; + if (tl->beginHook() && tl->beginHookType() == HookType::HOOK_45) { + beginHookWidth = fabs(tl->beginHookHeight().val() * _spatium * .4); + pp1.rx() += beginHookWidth; + } + else + beginHookWidth = 0; - // don't draw backwards lines (or hooks) if text is longer than nominal line length - bool backwards = _text && pp1.x() > pp2.x() && !tl->diagonal(); + if (tl->endHook() && tl->endHookType() == HookType::HOOK_45) { + endHookWidth = fabs(tl->endHookHeight().val() * _spatium * .4); + pp2.rx() -= endHookWidth; + } + else + endHookWidth = 0; - if (!backwards) - painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y())); + // don't draw backwards lines (or hooks) if text is longer than nominal line length + bool backwards = _text && pp1.x() > pp2.x() && !tl->diagonal(); - if (tl->beginHook() - && (spannerSegmentType() == SpannerSegmentType::SINGLE - || spannerSegmentType() == SpannerSegmentType::BEGIN) - ) { - qreal hh = tl->beginHookHeight().val() * _spatium; - painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x() - beginHookWidth, pp1.y() + hh)); - } + if (!backwards) + painter->drawLine(QLineF(pp1.x(), pp1.y(), pp2.x(), pp2.y())); - if (tl->endHook() && !backwards - && (spannerSegmentType() == SpannerSegmentType::SINGLE - || spannerSegmentType() == SpannerSegmentType::END) - ) { - qreal hh = tl->endHookHeight().val() * _spatium; - painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x() + endHookWidth, pp2.y() + hh)); + if (tl->beginHook() + && (spannerSegmentType() == SpannerSegmentType::SINGLE + || spannerSegmentType() == SpannerSegmentType::BEGIN) + ) { + qreal hh = tl->beginHookHeight().val() * _spatium; + painter->drawLine(QLineF(pp1.x(), pp1.y(), pp1.x() - beginHookWidth, pp1.y() + hh)); + } + + if (tl->endHook() && !backwards + && (spannerSegmentType() == SpannerSegmentType::SINGLE + || spannerSegmentType() == SpannerSegmentType::END) + ) { + qreal hh = tl->endHookHeight().val() * _spatium; + painter->drawLine(QLineF(pp2.x(), pp2.y(), pp2.x() + endHookWidth, pp2.y() + hh)); + } } } @@ -297,6 +302,7 @@ QVariant TextLineSegment::getProperty(P_ID id) const case P_ID::BEGIN_TEXT: case P_ID::CONTINUE_TEXT: case P_ID::END_TEXT: + case P_ID::LINE_VISIBLE: case P_ID::LINE_COLOR: case P_ID::LINE_WIDTH: return textLine()->getProperty(id); @@ -324,6 +330,7 @@ bool TextLineSegment::setProperty(P_ID id, const QVariant& v) case P_ID::BEGIN_TEXT: case P_ID::CONTINUE_TEXT: case P_ID::END_TEXT: + case P_ID::LINE_VISIBLE: case P_ID::LINE_COLOR: case P_ID::LINE_WIDTH: return textLine()->setProperty(id, v); @@ -351,6 +358,7 @@ QVariant TextLineSegment::propertyDefault(P_ID id) const case P_ID::BEGIN_TEXT: case P_ID::CONTINUE_TEXT: case P_ID::END_TEXT: + case P_ID::LINE_VISIBLE: case P_ID::LINE_COLOR: case P_ID::LINE_WIDTH: return textLine()->propertyDefault(id); @@ -372,6 +380,7 @@ TextLine::TextLine(Score* s) _beginHookHeight = Spatium(1.5); _endHookHeight = Spatium(1.5); + _lineVisible = true; _beginHook = false; _endHook = false; _beginHookType = HookType::HOOK_90; @@ -389,6 +398,7 @@ TextLine::TextLine(const TextLine& e) _continueTextPlace = e._continueTextPlace; _endTextPlace = e._endTextPlace; + _lineVisible = e._lineVisible; _beginHook = e._beginHook; _endHook = e._endHook; _beginHookType = e._beginHookType; @@ -639,6 +649,7 @@ QString TextLine::endText() const void TextLine::writeProperties(Xml& xml) const { + writeProperty(xml, P_ID::LINE_VISIBLE); writeProperty(xml, P_ID::BEGIN_HOOK); writeProperty(xml, P_ID::BEGIN_HOOK_HEIGHT); writeProperty(xml, P_ID::BEGIN_HOOK_TYPE); @@ -712,7 +723,9 @@ bool TextLine::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); - if (tag == "beginHook") + if (tag == "lineVisible") + _lineVisible = e.readBool(); + else if (tag == "beginHook") _beginHook = e.readBool(); else if (tag == "beginHookHeight") { _beginHookHeight = Spatium(e.readDouble()); @@ -821,6 +834,8 @@ QVariant TextLine::getProperty(P_ID id) const return continueText(); case P_ID::END_TEXT: return endText(); + case P_ID::LINE_VISIBLE: + return lineVisible(); default: return SLine::getProperty(id); } @@ -869,6 +884,9 @@ bool TextLine::setProperty(P_ID id, const QVariant& v) case P_ID::END_TEXT: setEndText(v.toString()); break; + case P_ID::LINE_VISIBLE: + setLineVisible(v.toBool()); + break; default: return SLine::setProperty(id, v); } @@ -899,6 +917,8 @@ QVariant TextLine::propertyDefault(P_ID id) const case P_ID::CONTINUE_TEXT: case P_ID::END_TEXT: return QString(""); + case P_ID::LINE_VISIBLE: + return true; default: return SLine::propertyDefault(id); diff --git a/libmscore/textline.h b/libmscore/textline.h index dc64014d01..c9dfcf859f 100644 --- a/libmscore/textline.h +++ b/libmscore/textline.h @@ -67,6 +67,7 @@ class TextLine : public SLine { PlaceText _beginTextPlace, _continueTextPlace, _endTextPlace; + bool _lineVisible; bool _beginHook, _endHook; HookType _beginHookType, _endHookType; Spatium _beginHookHeight, _endHookHeight; @@ -91,6 +92,8 @@ class TextLine : public SLine { virtual void writeProperties(Xml& xml) const override; virtual bool readProperties(XmlReader& node) override; + bool lineVisible() const { return _lineVisible; } + void setLineVisible(bool v) { _lineVisible = v; } bool beginHook() const { return _beginHook; } bool endHook() const { return _endHook; } void setBeginHook(bool v) { _beginHook = v; } diff --git a/mscore/inspector/inspectorOttava.cpp b/mscore/inspector/inspectorOttava.cpp index 98a8e3222c..9f9b8b6a4e 100644 --- a/mscore/inspector/inspectorOttava.cpp +++ b/mscore/inspector/inspectorOttava.cpp @@ -32,14 +32,15 @@ InspectorOttava::InspectorOttava(QWidget* parent) o.setupUi(addWidget()); iList = { - { P_ID::COLOR, 0, 0, e.color, e.resetColor }, - { P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible }, - { P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX }, - { P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY }, - { P_ID::DIAGONAL, 0, 0, l.diagonal, l.resetDiagonal }, - { P_ID::LINE_COLOR, 0, 0, l.lineColor, l.resetLineColor }, - { P_ID::LINE_WIDTH, 0, 0, l.lineWidth, l.resetLineWidth }, - { P_ID::LINE_STYLE, 0, 0, l.lineStyle, l.resetLineStyle }, + { P_ID::COLOR, 0, 0, e.color, e.resetColor }, + { P_ID::VISIBLE, 0, 0, e.visible, e.resetVisible }, + { P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX }, + { P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY }, + { P_ID::DIAGONAL, 0, 0, l.diagonal, l.resetDiagonal }, + { P_ID::LINE_VISIBLE, 0, 0, l.lineVisible, l.resetLineVisible }, + { P_ID::LINE_COLOR, 0, 0, l.lineColor, l.resetLineColor }, + { P_ID::LINE_WIDTH, 0, 0, l.lineWidth, l.resetLineWidth }, + { P_ID::LINE_STYLE, 0, 0, l.lineStyle, l.resetLineStyle }, // tl missing { P_ID::OTTAVA_TYPE, 0, 0, o.ottavaType, o.resetOttavaType }, { P_ID::PLACEMENT, 0, 0, o.placement, o.resetPlacement }, diff --git a/mscore/inspector/inspectorTextLine.cpp b/mscore/inspector/inspectorTextLine.cpp index 4c2722fb91..7bb5598b54 100644 --- a/mscore/inspector/inspectorTextLine.cpp +++ b/mscore/inspector/inspectorTextLine.cpp @@ -35,6 +35,7 @@ InspectorTextLine::InspectorTextLine(QWidget* parent) { P_ID::USER_OFF, 0, 0, e.offsetX, e.resetX }, { P_ID::USER_OFF, 1, 0, e.offsetY, e.resetY }, { P_ID::DIAGONAL, 0, 0, l.diagonal, l.resetDiagonal }, + { P_ID::LINE_VISIBLE, 0, 0, l.lineVisible, l.resetLineVisible }, { P_ID::LINE_COLOR, 0, 0, l.lineColor, l.resetLineColor }, { P_ID::LINE_WIDTH, 0, 0, l.lineWidth, l.resetLineWidth }, { P_ID::LINE_STYLE, 0, 0, l.lineStyle, l.resetLineStyle }, diff --git a/mscore/inspector/inspector_element.ui b/mscore/inspector/inspector_element.ui index c0afc0e5fb..5bd11cb697 100644 --- a/mscore/inspector/inspector_element.ui +++ b/mscore/inspector/inspector_element.ui @@ -6,8 +6,8 @@ 0 0 - 208 - 143 + 303 + 133 @@ -63,25 +63,6 @@ - - - - - 0 - 0 - - - - QFrame::HLine - - - QFrame::Raised - - - 2 - - - @@ -232,22 +213,6 @@ - - - - - 0 - 0 - - - - Reset Visible value - - - ... - - - @@ -334,6 +299,22 @@ + + + + + 0 + 0 + + + + Reset Visible value + + + ... + + + diff --git a/mscore/inspector/inspector_line.ui b/mscore/inspector/inspector_line.ui index df15750f4c..1474499e3f 100644 --- a/mscore/inspector/inspector_line.ui +++ b/mscore/inspector/inspector_line.ui @@ -7,7 +7,7 @@ 0 0 284 - 124 + 154 @@ -48,25 +48,12 @@ - - - - QFrame::HLine - - - QFrame::Raised - - - 2 - - - 0 - + @@ -79,7 +66,7 @@ - + Reset value @@ -92,21 +79,21 @@ - + Line thickness - + Line style - + Qt::TabFocus @@ -119,7 +106,7 @@ - + Reset value @@ -132,7 +119,7 @@ - + @@ -148,7 +135,7 @@ - + Line thickness @@ -161,7 +148,7 @@ - + Line style @@ -193,7 +180,7 @@ - + Reset value @@ -206,7 +193,7 @@ - + Reset value @@ -219,6 +206,29 @@ + + + + + 0 + 0 + + + + Reset Visible value + + + ... + + + + + + + Line Visible + + +