Skip to content

Commit 87a1af7

Browse files
committed
Allow edit line style for Hold
1 parent cb1a7c7 commit 87a1af7

File tree

6 files changed

+116
-26
lines changed

6 files changed

+116
-26
lines changed

src/engraving/dom/guitarbend.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ void GuitarBend::setBendType(GuitarBendType t)
979979
GuitarBendHold::GuitarBendHold(GuitarBend* parent)
980980
: SLine(ElementType::GUITAR_BEND_HOLD, parent, ElementFlag::MOVABLE)
981981
{
982+
resetProperty(Pid::LINE_STYLE);
982983
}
983984

984985
GuitarBendHold::GuitarBendHold(const GuitarBendHold& h)
@@ -994,6 +995,16 @@ LineSegment* GuitarBendHold::createLineSegment(System* parent)
994995
return seg;
995996
}
996997

998+
PropertyValue GuitarBendHold::propertyDefault(Pid id) const
999+
{
1000+
switch (id) {
1001+
case Pid::LINE_STYLE:
1002+
return LineType::DASHED;
1003+
default:
1004+
return SLine::propertyDefault(id);
1005+
}
1006+
}
1007+
9971008
Note* GuitarBendHold::startNote() const
9981009
{
9991010
EngravingItem* startEl = startElement();

src/engraving/dom/guitarbend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ class GuitarBendHold final : public SLine
258258

259259
LineSegment* createLineSegment(System* parent) override;
260260

261+
PropertyValue propertyDefault(Pid id) const override;
262+
261263
bool allowTimeAnchor() const override { return false; }
262264

263265
Note* startNote() const;

src/engraving/rendering/score/tdraw.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,9 +1648,23 @@ void TDraw::draw(const GuitarBendHoldSegment* item, Painter* painter, const Pain
16481648
}
16491649

16501650
pen.setWidthF(item->lineWidth());
1651-
double dash = item->dashLength();
1652-
pen.setDashPattern(distributedDashPattern(dash, dash, item->pos2().x() / pen.widthF()));
16531651
pen.setCapStyle(PenCapStyle::FlatCap);
1652+
1653+
switch (item->getProperty(Pid::LINE_STYLE).value<LineType>()) {
1654+
case LineType::DASHED:
1655+
{
1656+
double dash = item->dashLength();
1657+
pen.setDashPattern(distributedDashPattern(dash, dash, item->pos2().x() / pen.widthF()));
1658+
break;
1659+
}
1660+
case LineType::DOTTED:
1661+
pen.setCapStyle(PenCapStyle::RoundCap); // True dots
1662+
pen.setDashPattern({ 0.01, 1.99 });
1663+
break;
1664+
default:
1665+
break;
1666+
}
1667+
16541668
pen.setJoinStyle(PenJoinStyle::MiterJoin);
16551669
painter->setPen(pen);
16561670

src/inspector/qml/MuseScore/Inspector/notation/bends/BendSettings.qml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,32 @@ Column {
113113
]
114114
}
115115

116+
FlatRadioButtonGroupPropertyView {
117+
id: holdLineStyle
118+
visible: root.model && root.model.isHoldLine
119+
titleText: qsTrc("inspector", "Line style")
120+
propertyItem: root.model ? root.model.lineStyle : null
121+
122+
navigationName: "HoldLineStyle"
123+
navigationPanel: root.navigationPanel
124+
navigationRowStart: tabStaffLayout.navigationRowEnd + 1
125+
126+
model: [
127+
{ iconCode: IconCode.LINE_NORMAL, value: LineTypes.LINE_STYLE_SOLID, title: qsTrc("inspector", "Normal", "line type") },
128+
{ iconCode: IconCode.LINE_DASHED, value: LineTypes.LINE_STYLE_DASHED, title: qsTrc("inspector", "Dashed", "line type") },
129+
{ iconCode: IconCode.LINE_DOTTED, value: LineTypes.LINE_STYLE_DOTTED, title: qsTrc("inspector", "Dotted", "line type") },
130+
]
131+
}
132+
116133
InspectorPropertyView {
117134
id: bend
118135
titleText: root.model && root.model.isDive ? qsTrc("inspector", "Customize dive") : qsTrc("inspector", "Customize bend")
119136

120137
enabled: root.model ? root.model.isBendCurveEnabled : false
121-
visible: true
138+
visible: root.model ? !root.model.isHoldLine : false
122139

123140
navigationPanel: root.navigationPanel
124-
navigationRowStart: tabStaffLayout.navigationRowEnd + 1
141+
navigationRowStart: holdLineStyle.navigationRowEnd + 1
125142

126143
spacing: 0
127144

src/inspector/qml/MuseScore/Inspector/notation/bends/bendsettingsmodel.cpp

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void BendSettingsModel::createProperties()
7070
m_showHoldLine = buildPropertyItem(mu::engraving::Pid::BEND_SHOW_HOLD_LINE);
7171
m_diveTabPos = buildPropertyItem(mu::engraving::Pid::GUITAR_DIVE_TAB_POS);
7272
m_dipVibratoType = buildPropertyItem(mu::engraving::Pid::VIBRATO_LINE_TYPE);
73+
m_lineStyle = buildPropertyItem(mu::engraving::Pid::LINE_STYLE);
7374

7475
loadBendCurve();
7576
}
@@ -92,7 +93,9 @@ void BendSettingsModel::loadProperties()
9293
loadPropertyItem(m_showHoldLine);
9394
loadPropertyItem(m_diveTabPos);
9495
loadPropertyItem(m_dipVibratoType);
96+
loadPropertyItem(m_lineStyle);
9597

98+
updateIsHoldLine();
9699
updateIsShowHoldLineAvailable();
97100
updateIsDiveTabPosAvailable();
98101
updateIsTabStaff();
@@ -118,16 +121,21 @@ bool BendSettingsModel::areSettingsAvailable() const
118121
void BendSettingsModel::updateIsShowHoldLineAvailable()
119122
{
120123
bool available = true;
121-
for (EngravingItem* item : m_elementList) {
122-
if (!item->isGuitarBendSegment()) {
123-
continue;
124-
}
125124

126-
GuitarBendSegment* seg = toGuitarBendSegment(item);
127-
bool isAvail = seg->staffType() && seg->staffType()->isTabStaff() && seg->guitarBend()->bendType() != GuitarBendType::DIP;
128-
if (!isAvail) {
129-
available = false;
130-
break;
125+
if (m_isHoldLine) {
126+
available = false;
127+
} else {
128+
for (EngravingItem* item : m_elementList) {
129+
if (!item->isGuitarBendSegment()) {
130+
continue;
131+
}
132+
133+
GuitarBendSegment* seg = toGuitarBendSegment(item);
134+
bool isAvail = seg->staffType() && seg->staffType()->isTabStaff() && seg->guitarBend()->bendType() != GuitarBendType::DIP;
135+
if (!isAvail) {
136+
available = false;
137+
break;
138+
}
131139
}
132140
}
133141

@@ -141,19 +149,23 @@ void BendSettingsModel::updateIsDiveTabPosAvailable()
141149
{
142150
bool available = true;
143151

144-
for (EngravingItem* item : m_elementList) {
145-
if (!item->isGuitarBendSegment()) {
146-
continue;
147-
}
148-
149-
GuitarBendSegment* seg = toGuitarBendSegment(item);
150-
GuitarBendType bendType = seg->guitarBend()->bendType();
151-
const StaffType* staffType = seg->staffType();
152-
bool isDiveOnTab = (bendType == GuitarBendType::DIVE || bendType == GuitarBendType::PRE_DIVE)
153-
&& staffType && staffType->isTabStaff();
154-
if (!isDiveOnTab) {
155-
available = false;
156-
break;
152+
if (m_isHoldLine) {
153+
available = false;
154+
} else {
155+
for (EngravingItem* item : m_elementList) {
156+
if (!item->isGuitarBendSegment()) {
157+
continue;
158+
}
159+
160+
GuitarBendSegment* seg = toGuitarBendSegment(item);
161+
GuitarBendType bendType = seg->guitarBend()->bendType();
162+
const StaffType* staffType = seg->staffType();
163+
bool isDiveOnTab = (bendType == GuitarBendType::DIVE || bendType == GuitarBendType::PRE_DIVE)
164+
&& staffType && staffType->isTabStaff();
165+
if (!isDiveOnTab) {
166+
available = false;
167+
break;
168+
}
157169
}
158170
}
159171

@@ -213,6 +225,22 @@ void BendSettingsModel::updateIsDip()
213225
}
214226
}
215227

228+
void BendSettingsModel::updateIsHoldLine()
229+
{
230+
bool isHoldLine = true;
231+
for (EngravingItem* item : m_elementList) {
232+
if (!item->isGuitarBendHoldSegment()) {
233+
isHoldLine = false;
234+
break;
235+
}
236+
}
237+
238+
if (m_isHoldLine != isHoldLine) {
239+
m_isHoldLine = isHoldLine;
240+
emit isHoldLineChanged(m_isHoldLine);
241+
}
242+
}
243+
216244
void BendSettingsModel::loadBendCurve()
217245
{
218246
EngravingItem* item = this->item();
@@ -334,6 +362,11 @@ PropertyItem* BendSettingsModel::dipVibratoType() const
334362
return m_dipVibratoType;
335363
}
336364

365+
PropertyItem* BendSettingsModel::lineStyle() const
366+
{
367+
return m_lineStyle;
368+
}
369+
337370
bool BendSettingsModel::isShowHoldLineAvailable() const
338371
{
339372
return m_isShowHoldLineAvailable;
@@ -359,6 +392,11 @@ bool BendSettingsModel::isDip() const
359392
return m_isDip;
360393
}
361394

395+
bool BendSettingsModel::isHoldLine() const
396+
{
397+
return m_isHoldLine;
398+
}
399+
362400
void BendSettingsModel::setBendCurve(const QVariantList& newBendCurve)
363401
{
364402
CurvePoints points = curvePointsFromQVariant(newBendCurve);

src/inspector/qml/MuseScore/Inspector/notation/bends/bendsettingsmodel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ class BendSettingsModel : public AbstractInspectorModel
3838
Q_PROPERTY(mu::inspector::PropertyItem * showHoldLine READ showHoldLine CONSTANT)
3939
Q_PROPERTY(mu::inspector::PropertyItem * diveTabPos READ diveTabPos CONSTANT)
4040
Q_PROPERTY(mu::inspector::PropertyItem * dipVibratoType READ dipVibratoType CONSTANT)
41+
Q_PROPERTY(mu::inspector::PropertyItem * lineStyle READ lineStyle CONSTANT)
4142

4243
Q_PROPERTY(bool isShowHoldLineAvailable READ isShowHoldLineAvailable NOTIFY isShowHoldLineAvailableChanged)
4344
Q_PROPERTY(bool isDiveTabPosAvailable READ isDiveTabPosAvailable NOTIFY isDiveTabPosAvailableChanged)
4445
Q_PROPERTY(bool isTabStaff READ isTabStaff NOTIFY isTabStaffChanged)
4546
Q_PROPERTY(bool isDive READ isDive NOTIFY isDiveChanged)
4647
Q_PROPERTY(bool isDip READ isDip NOTIFY isDipChanged)
48+
Q_PROPERTY(bool isHoldLine READ isHoldLine NOTIFY isHoldLineChanged)
4749

4850
Q_PROPERTY(bool isBendCurveEnabled READ isBendCurveEnabled NOTIFY isBendCurveEnabledChanged)
4951
Q_PROPERTY(QVariantList bendCurve READ bendCurve WRITE setBendCurve NOTIFY bendCurveChanged)
@@ -62,12 +64,14 @@ class BendSettingsModel : public AbstractInspectorModel
6264
PropertyItem* showHoldLine() const;
6365
PropertyItem* diveTabPos() const;
6466
PropertyItem* dipVibratoType() const;
67+
PropertyItem* lineStyle() const;
6568

6669
bool isShowHoldLineAvailable() const;
6770
bool isDiveTabPosAvailable() const;
6871
bool isTabStaff() const;
6972
bool isDive() const;
7073
bool isDip() const;
74+
bool isHoldLine() const;
7175

7276
QVariantList bendCurve() const;
7377

@@ -84,6 +88,7 @@ class BendSettingsModel : public AbstractInspectorModel
8488
void isTabStaffChanged(bool isTabStaff);
8589
void isDiveChanged(bool isDive);
8690
void isDipChanged(bool isDip);
91+
void isHoldLineChanged(bool isHoldLine);
8792

8893
void isBendCurveEnabledChanged();
8994
void bendCurveChanged();
@@ -94,6 +99,7 @@ class BendSettingsModel : public AbstractInspectorModel
9499
void updateIsTabStaff();
95100
void updateIsDive();
96101
void updateIsDip();
102+
void updateIsHoldLine();
97103

98104
void loadBendCurve();
99105

@@ -106,12 +112,14 @@ class BendSettingsModel : public AbstractInspectorModel
106112
PropertyItem* m_showHoldLine = nullptr;
107113
PropertyItem* m_diveTabPos = nullptr;
108114
PropertyItem* m_dipVibratoType = nullptr;
115+
PropertyItem* m_lineStyle = nullptr;
109116

110117
bool m_isShowHoldLineAvailable = false;
111118
bool m_isDiveTabPosAvailable = false;
112119
bool m_isTabStaff = false;
113120
bool m_isDive = false;
114121
bool m_isDip = false;
122+
bool m_isHoldLine = false;
115123

116124
CurvePoints m_bendCurve;
117125
};

0 commit comments

Comments
 (0)