add lineVisible property to TextLine elements
This commit is contained in:
parent
14bf441995
commit
56abfd71a5
8 changed files with 123 additions and 105 deletions
|
@ -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 }
|
||||
};
|
||||
|
|
|
@ -207,6 +207,7 @@ enum class P_ID : unsigned char {
|
|||
LYRIC_TICKS,
|
||||
|
||||
VOLTA_ENDING,
|
||||
LINE_VISIBLE,
|
||||
|
||||
END
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>208</width>
|
||||
<height>143</height>
|
||||
<width>303</width>
|
||||
<height>133</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -63,25 +63,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
|
@ -232,22 +213,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QToolButton" name="resetVisible">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Reset Visible value</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QToolButton" name="resetColor">
|
||||
<property name="sizePolicy">
|
||||
|
@ -334,6 +299,22 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QToolButton" name="resetVisible">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Reset Visible value</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>284</width>
|
||||
<height>124</height>
|
||||
<height>154</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -48,25 +48,12 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
|
@ -79,7 +66,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="resetLineColor">
|
||||
<property name="toolTip">
|
||||
<string>Reset value</string>
|
||||
|
@ -92,21 +79,21 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Line thickness</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="diagonal">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::TabFocus</enum>
|
||||
|
@ -119,7 +106,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="resetDiagonal">
|
||||
<property name="toolTip">
|
||||
<string>Reset value</string>
|
||||
|
@ -132,7 +119,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="Awl::ColorLabel" name="lineColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
|
||||
|
@ -148,7 +135,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="lineWidth">
|
||||
<property name="accessibleName">
|
||||
<string>Line thickness</string>
|
||||
|
@ -161,7 +148,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="lineStyle">
|
||||
<property name="accessibleName">
|
||||
<string>Line style</string>
|
||||
|
@ -193,7 +180,7 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="resetLineWidth">
|
||||
<property name="toolTip">
|
||||
<string>Reset value</string>
|
||||
|
@ -206,7 +193,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<item row="5" column="2">
|
||||
<widget class="QToolButton" name="resetLineStyle">
|
||||
<property name="toolTip">
|
||||
<string>Reset value</string>
|
||||
|
@ -219,6 +206,29 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="resetLineVisible">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Reset Visible value</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="lineVisible">
|
||||
<property name="text">
|
||||
<string>Line Visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in a new issue