Skip to content

Commit edee571

Browse files
iveshenry18Jojo-Schmitz
authored andcommitted
ENG-14: Fix barlines on multi-staff parts
This commit fixes the handling of (non-repeat) barlines on grand staves by creating a barline for each staff in the part, and setting the _spanStaff property of the first barline of each multi-staff part. Also updates the relevant tests. picpickk Port of musescore#8175, part 2
1 parent f66cb50 commit edee571

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

importexport/musicxml/importmxmlpass2.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,12 +3264,12 @@ static bool determineBarLineType(const QString& barStyle, const QString& repeat,
32643264
* Create a barline of the specified type.
32653265
*/
32663266

3267-
static std::unique_ptr<BarLine> createBarline(Score* score, const int track, const BarLineType type, const bool visible, const QString& barStyle)
3267+
static std::unique_ptr<BarLine> createBarline(Score* score, const int track, const BarLineType type, const bool visible, const QString& barStyle, bool spanStaff)
32683268
{
32693269
std::unique_ptr<BarLine> barline(new BarLine(score));
32703270
barline->setTrack(track);
32713271
barline->setBarLineType(type);
3272-
barline->setSpanStaff(0);
3272+
barline->setSpanStaff(spanStaff);
32733273
barline->setVisible(visible);
32743274
if (barStyle == "tick") {
32753275
barline->setSpanFrom(BARLINE_SPAN_TICK1_FROM);
@@ -3384,8 +3384,15 @@ void MusicXMLParserPass2::barline(const QString& partId, Measure* measure, const
33843384
|| barStyle == "dotted"
33853385
|| barStyle == "light-light"
33863386
|| barStyle == "regular") {
3387-
auto b = createBarline(measure->score(), track, type, visible, barStyle);
3388-
addBarlineToMeasure(measure, tick, std::move(b));
3387+
// Add barline to the first voice of every staff in the part,
3388+
// and span every barline except the last
3389+
int nstaves = _pass1.getPart(partId)->nstaves();
3390+
for (int i = 0; i < nstaves; ++i ) {
3391+
bool spanStaff = i < nstaves - 1;
3392+
int currentTrack = track + (i * VOICES);
3393+
auto b = createBarline(measure->score(), currentTrack, type, visible, barStyle, spanStaff);
3394+
addBarlineToMeasure(measure, tick, std::move(b));
3395+
}
33893396
}
33903397
}
33913398
}

mtest/musicxml/io/testBarlinesGrandStaff_ref.mscx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
</Rest>
191191
<BarLine>
192192
<subtype>dotted</subtype>
193-
<span>0</span>
193+
<span>1</span>
194194
</BarLine>
195195
</voice>
196196
</Measure>
@@ -218,7 +218,7 @@
218218
</Rest>
219219
<BarLine>
220220
<subtype>double</subtype>
221-
<span>0</span>
221+
<span>1</span>
222222
</BarLine>
223223
</voice>
224224
</Measure>
@@ -296,7 +296,7 @@
296296
</Rest>
297297
<BarLine>
298298
<subtype>double</subtype>
299-
<span>0</span>
299+
<span>1</span>
300300
</BarLine>
301301
</voice>
302302
</Measure>
@@ -474,6 +474,9 @@
474474
<durationType>measure</durationType>
475475
<duration>1/1</duration>
476476
</Rest>
477+
<BarLine>
478+
<subtype>dotted</subtype>
479+
</BarLine>
477480
</voice>
478481
</Measure>
479482
<Measure>
@@ -498,6 +501,9 @@
498501
<durationType>measure</durationType>
499502
<duration>1/1</duration>
500503
</Rest>
504+
<BarLine>
505+
<subtype>double</subtype>
506+
</BarLine>
501507
</voice>
502508
</Measure>
503509
<Measure>
@@ -572,6 +578,9 @@
572578
<durationType>measure</durationType>
573579
<duration>1/1</duration>
574580
</Rest>
581+
<BarLine>
582+
<subtype>double</subtype>
583+
</BarLine>
575584
</voice>
576585
</Measure>
577586
<Measure>

0 commit comments

Comments
 (0)