Skip to content

Commit 8dad5d4

Browse files
authored
Merge pull request #26143 from sammik/sectionBreak-showCourtesy
add option to unhide courtesy clefs and signatures in section break
2 parents 1afc290 + 94c0e26 commit 8dad5d4

File tree

10 files changed

+74
-6
lines changed

10 files changed

+74
-6
lines changed

src/engraving/dom/layoutbreak.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ LayoutBreak::LayoutBreak(MeasureBase* parent)
5252
m_startWithLongNames = false;
5353
m_startWithMeasureOne = false;
5454
m_firstSystemIndentation = false;
55+
m_showCourtesy = false;
5556
m_layoutBreakType = LayoutBreakType(propertyDefault(Pid::LAYOUT_BREAK).toInt());
5657

5758
initElementStyle(&sectionBreakStyle);
@@ -60,6 +61,7 @@ LayoutBreak::LayoutBreak(MeasureBase* parent)
6061
resetProperty(Pid::START_WITH_LONG_NAMES);
6162
resetProperty(Pid::START_WITH_MEASURE_ONE);
6263
resetProperty(Pid::FIRST_SYSTEM_INDENTATION);
64+
resetProperty(Pid::SHOW_COURTESY);
6365
}
6466

6567
LayoutBreak::LayoutBreak(const LayoutBreak& lb)
@@ -70,6 +72,7 @@ LayoutBreak::LayoutBreak(const LayoutBreak& lb)
7072
m_startWithLongNames = lb.m_startWithLongNames;
7173
m_startWithMeasureOne = lb.m_startWithMeasureOne;
7274
m_firstSystemIndentation = lb.m_firstSystemIndentation;
75+
m_showCourtesy = lb.m_showCourtesy;
7376
}
7477

7578
void LayoutBreak::setParent(MeasureBase* parent)
@@ -140,6 +143,8 @@ PropertyValue LayoutBreak::getProperty(Pid propertyId) const
140143
return m_startWithMeasureOne;
141144
case Pid::FIRST_SYSTEM_INDENTATION:
142145
return m_firstSystemIndentation;
146+
case Pid::SHOW_COURTESY:
147+
return m_showCourtesy;
143148
default:
144149
return EngravingItem::getProperty(propertyId);
145150
}
@@ -168,6 +173,9 @@ bool LayoutBreak::setProperty(Pid propertyId, const PropertyValue& v)
168173
case Pid::FIRST_SYSTEM_INDENTATION:
169174
setFirstSystemIndentation(v.toBool());
170175
break;
176+
case Pid::SHOW_COURTESY:
177+
setShowCourtesy(v.toBool());
178+
break;
171179
default:
172180
if (!EngravingItem::setProperty(propertyId, v)) {
173181
return false;
@@ -205,6 +213,8 @@ PropertyValue LayoutBreak::propertyDefault(Pid id) const
205213
return true;
206214
case Pid::FIRST_SYSTEM_INDENTATION:
207215
return true;
216+
case Pid::SHOW_COURTESY:
217+
return false;
208218
default:
209219
return EngravingItem::propertyDefault(id);
210220
}

src/engraving/dom/layoutbreak.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class LayoutBreak final : public EngravingItem
6161
void setStartWithMeasureOne(bool v) { m_startWithMeasureOne = v; }
6262
bool firstSystemIndentation() const { return m_firstSystemIndentation; }
6363
void setFirstSystemIndentation(bool v) { m_firstSystemIndentation = v; }
64+
bool showCourtesy() const { return m_showCourtesy; }
65+
void setShowCourtesy(bool v) { m_showCourtesy = v; }
6466

6567
bool isPageBreak() const { return m_layoutBreakType == LayoutBreakType::PAGE; }
6668
bool isLineBreak() const { return m_layoutBreakType == LayoutBreakType::LINE; }
@@ -88,6 +90,7 @@ class LayoutBreak final : public EngravingItem
8890
bool m_startWithLongNames = false;
8991
bool m_startWithMeasureOne = false;
9092
bool m_firstSystemIndentation = false;
93+
bool m_showCourtesy = false;
9194
LayoutBreakType m_layoutBreakType = LayoutBreakType::NOBREAK;
9295
};
9396
} // namespace mu::engraving

src/engraving/dom/measure.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,21 @@ bool Measure::isFinalMeasureOfSection() const
19701970
return false;
19711971
}
19721972

1973+
LayoutBreak* Measure::sectionBreakElement(bool includeNextFrames)
1974+
{
1975+
const MeasureBase* mb = static_cast<const MeasureBase*>(this);
1976+
1977+
do {
1978+
if (LayoutBreak* sectionBreak = mb->sectionBreakElement()) {
1979+
return sectionBreak;
1980+
}
1981+
1982+
mb = mb->next();
1983+
} while (includeNextFrames && mb && !mb->isMeasure()); // loop until reach next actual measure or end of score
1984+
1985+
return nullptr;
1986+
}
1987+
19731988
//---------------------------------------------------------
19741989
// isAnacrusis
19751990
//---------------------------------------------------------

src/engraving/dom/measure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class Measure final : public MeasureBase
282282
bool visible(staff_idx_t staffIdx) const;
283283
bool stemless(staff_idx_t staffIdx) const;
284284
bool isFinalMeasureOfSection() const;
285+
LayoutBreak* sectionBreakElement(bool includeNextFrames = true);
285286
bool isAnacrusis() const;
286287
bool isFirstInSystem() const;
287288
bool isLastInSystem() const;

src/engraving/rendering/score/measurelayout.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,10 @@ void MeasureLayout::createEndBarLines(Measure* m, bool isLastMeasureInSystem, La
14241424
Segment* seg = m->findSegmentR(SegmentType::EndBarLine, m->ticks());
14251425
Measure* nm = m->nextMeasure();
14261426
double blw = 0.0;
1427+
bool hideCourtesy = false;
1428+
if (LayoutBreak* sectionBreakElement = m->sectionBreakElement()) {
1429+
hideCourtesy = !sectionBreakElement->showCourtesy();
1430+
}
14271431

14281432
if (nm && nm->repeatStart() && !m->repeatEnd() && !isLastMeasureInSystem && m->next() == nm) {
14291433
// we may skip barline at end of a measure immediately before a start repeat:
@@ -1445,7 +1449,7 @@ void MeasureLayout::createEndBarLines(Measure* m, bool isLastMeasureInSystem, La
14451449
// This flag is later used to set a double end bar line and to actually
14461450
// create the courtesy key sig.
14471451

1448-
if (nm && !m->sectionBreak()) {
1452+
if (nm && !hideCourtesy) {
14491453
// Don't change barlines at the end of a section break,
14501454
// and don't create courtesy key/time signatures.
14511455
bool hasKeySig = false;
@@ -1585,8 +1589,9 @@ void MeasureLayout::createEndBarLines(Measure* m, bool isLastMeasureInSystem, La
15851589
bool showCourtesy = ctx.conf().styleB(Sid::genCourtesyClef) && clef->showCourtesy(); // normally show a courtesy clef
15861590
// check if the measure is the last measure of the system or the last measure before a frame
15871591
bool lastMeasure = isLastMeasureInSystem || (nm ? !(m->next() == nm) : true);
1588-
if (!nm || m->isFinalMeasureOfSection() || (lastMeasure && !showCourtesy)) {
1589-
// hide the courtesy clef in the final measure of a section, or if the measure is the final measure of a system
1592+
if (!nm || hideCourtesy || (lastMeasure && !showCourtesy)) {
1593+
// hide the courtesy clef in the final measure of a section,
1594+
// or if the measure is the final measure of a system
15901595
// and the score style or the clef style is set to "not show courtesy clef",
15911596
// or if the clef is at the end of the very last measure of the score
15921597
clef->clear();
@@ -1858,7 +1863,10 @@ void MeasureLayout::removeSystemHeader(Measure* m)
18581863
void MeasureLayout::addSystemTrailer(Measure* m, Measure* nm, LayoutContext& ctx)
18591864
{
18601865
Fraction _rtick = m->ticks();
1861-
bool isFinalMeasure = m->isFinalMeasureOfSection();
1866+
bool hideCourtesy = false;
1867+
if (LayoutBreak* sectionBreakElement = m->sectionBreakElement()) {
1868+
hideCourtesy = !sectionBreakElement->showCourtesy();
1869+
}
18621870

18631871
// locate a time sig. in the next measure and, if found,
18641872
// check if it has court. sig. turned off
@@ -1868,7 +1876,7 @@ void MeasureLayout::addSystemTrailer(Measure* m, Measure* nm, LayoutContext& ctx
18681876
if (s) {
18691877
s->setTrailer(true);
18701878
}
1871-
if (nm && ctx.conf().styleB(Sid::genCourtesyTimesig) && !isFinalMeasure && !ctx.conf().isFloatMode()) {
1879+
if (nm && ctx.conf().styleB(Sid::genCourtesyTimesig) && !hideCourtesy && !ctx.conf().isFloatMode()) {
18721880
Segment* tss = nm->findSegmentR(SegmentType::TimeSig, Fraction(0, 1));
18731881
if (tss) {
18741882
size_t nstaves = ctx.dom().nstaves();

src/engraving/rw/read410/tread.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,8 @@ void TRead::read(LayoutBreak* b, XmlReader& e, ReadContext& ctx)
33043304
TRead::readProperty(b, e, ctx, Pid::START_WITH_MEASURE_ONE);
33053305
} else if (tag == "firstSystemIndentation") {
33063306
TRead::readProperty(b, e, ctx, Pid::FIRST_SYSTEM_INDENTATION);
3307+
} else if (tag == "showCourtesySig") {
3308+
TRead::readProperty(b, e, ctx, Pid::SHOW_COURTESY);
33073309
} else if (!readItemProperties(b, e, ctx)) {
33083310
e.unknown();
33093311
}

src/engraving/rw/write/twrite.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,8 @@ void TWrite::write(const LayoutBreak* item, XmlWriter& xml, WriteContext& ctx)
21382138
writeItemProperties(item, xml, ctx);
21392139

21402140
for (auto id :
2141-
{ Pid::LAYOUT_BREAK, Pid::PAUSE, Pid::START_WITH_LONG_NAMES, Pid::START_WITH_MEASURE_ONE, Pid::FIRST_SYSTEM_INDENTATION }) {
2141+
{ Pid::LAYOUT_BREAK, Pid::PAUSE, Pid::START_WITH_LONG_NAMES, Pid::START_WITH_MEASURE_ONE, Pid::FIRST_SYSTEM_INDENTATION,
2142+
Pid::SHOW_COURTESY }) {
21422143
writeProperty(item, xml, id);
21432144
}
21442145

src/inspector/models/notation/sectionbreaks/sectionbreaksettingsmodel.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void SectionBreakSettingsModel::createProperties()
4141
m_shouldResetBarNums = buildPropertyItem(mu::engraving::Pid::START_WITH_MEASURE_ONE);
4242
m_pauseDuration = buildPropertyItem(mu::engraving::Pid::PAUSE);
4343
m_firstSystemIndent = buildPropertyItem(mu::engraving::Pid::FIRST_SYSTEM_INDENTATION);
44+
m_showCourtesySignatures = buildPropertyItem(mu::engraving::Pid::SHOW_COURTESY);
4445
}
4546

4647
void SectionBreakSettingsModel::requestElements()
@@ -54,6 +55,7 @@ void SectionBreakSettingsModel::loadProperties()
5455
loadPropertyItem(m_shouldResetBarNums);
5556
loadPropertyItem(m_pauseDuration, formatDoubleFunc);
5657
loadPropertyItem(m_firstSystemIndent);
58+
loadPropertyItem(m_showCourtesySignatures);
5759
}
5860

5961
void SectionBreakSettingsModel::resetProperties()
@@ -62,6 +64,7 @@ void SectionBreakSettingsModel::resetProperties()
6264
m_shouldResetBarNums->resetToDefault();
6365
m_pauseDuration->resetToDefault();
6466
m_firstSystemIndent->resetToDefault();
67+
m_showCourtesySignatures->resetToDefault();
6568
}
6669

6770
PropertyItem* SectionBreakSettingsModel::shouldStartWithLongInstrNames() const
@@ -83,3 +86,8 @@ PropertyItem* SectionBreakSettingsModel::firstSystemIndent() const
8386
{
8487
return m_firstSystemIndent;
8588
}
89+
90+
PropertyItem* SectionBreakSettingsModel::showCourtesySignatures() const
91+
{
92+
return m_showCourtesySignatures;
93+
}

src/inspector/models/notation/sectionbreaks/sectionbreaksettingsmodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SectionBreakSettingsModel : public AbstractInspectorModel
3333
Q_PROPERTY(PropertyItem * shouldResetBarNums READ shouldResetBarNums CONSTANT)
3434
Q_PROPERTY(PropertyItem * pauseDuration READ pauseDuration CONSTANT)
3535
Q_PROPERTY(PropertyItem * firstSystemIndent READ firstSystemIndent CONSTANT)
36+
Q_PROPERTY(PropertyItem * showCourtesySignatures READ showCourtesySignatures CONSTANT)
3637

3738
public:
3839
explicit SectionBreakSettingsModel(QObject* parent, IElementRepositoryService* repository);
@@ -46,12 +47,14 @@ class SectionBreakSettingsModel : public AbstractInspectorModel
4647
PropertyItem* shouldResetBarNums() const;
4748
PropertyItem* pauseDuration() const;
4849
PropertyItem* firstSystemIndent() const;
50+
PropertyItem* showCourtesySignatures() const;
4951

5052
private:
5153
PropertyItem* m_shouldStartWithLongInstrNames = nullptr;
5254
PropertyItem* m_shouldResetBarNums = nullptr;
5355
PropertyItem* m_pauseDuration = nullptr;
5456
PropertyItem* m_firstSystemIndent = nullptr;
57+
PropertyItem* m_showCourtesySignatures = nullptr;
5558
};
5659
}
5760

src/inspector/view/qml/MuseScore/Inspector/notation/sectionbreaks/SectionBreakSettings.qml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,21 @@ Column {
8989
navigation.panel: root.navigationPanel
9090
navigation.row: shouldResetBarNums.navigation.row + 1
9191
}
92+
93+
PropertyCheckBox {
94+
id: showCourtesySignatures
95+
text: qsTrc("inspector", "Hide courtesy clefs and signatures")
96+
propertyItem: root.model ? root.model.showCourtesySignatures : null
97+
98+
checked: propertyItem && !Boolean(propertyItem.value)
99+
onClicked: {
100+
if (propertyItem) {
101+
propertyItem.value = checked
102+
}
103+
}
104+
105+
navigation.name: "ShowCourtesySignatures"
106+
navigation.panel: root.navigationPanel
107+
navigation.row: startWithfirstSystemIndented.navigation.row + 1
108+
}
92109
}

0 commit comments

Comments
 (0)