Skip to content

Commit

Permalink
ENG-54: Default HideMode::INSTRUMENT XML import
Browse files Browse the repository at this point in the history
Since HideMode::AUTO behaves in uncommon ways for most scores (hiding
empty staves in a grand staff), this changes the hideWhenEmpty to
INSTRUMENT when creating the Staffs upon import. In the case that a
score part has a variable number of staves, it uses this to infer that
we do truly want HideMode::AUTO.

Duplicate of musescore#8430, part 1
  • Loading branch information
iveshenry18 authored and Jojo-Schmitz committed Jun 29, 2021
1 parent 833c0b2 commit 820cc1c
Show file tree
Hide file tree
Showing 19 changed files with 3,462 additions and 1 deletion.
17 changes: 16 additions & 1 deletion importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ static void createPart(Score* score, const QString& id, PartMap& pm)
score->appendPart(part);
Staff* staff = new Staff(score);
staff->setPart(part);
staff->setHideWhenEmpty(Staff::HideMode::INSTRUMENT);
part->staves()->push_back(staff);
score->staves().push_back(staff);
// TODO TBD tuplets.resize(VOICES); // part now contains one staff, thus VOICES voices
Expand Down Expand Up @@ -2018,13 +2019,27 @@ void MusicXMLParserPass1::midiInstrument(const QString& partId)
/**
Set number of staves for part \a partId to the max value
of the current value \a staves.
Also handle HideMode.
*/

static void setNumberOfStavesForPart(Part* const part, const int staves)
{
Q_ASSERT(part);
if (staves > part->nstaves())
int prevnstaves = part->nstaves();
if (staves > part->nstaves()) {
part->setStaves(staves);
// New staves default to INSTRUMENT hide mode
for (int i = prevnstaves; i < staves; ++i)
part->staff(i)->setHideWhenEmpty(Staff::HideMode::INSTRUMENT);
}
if (staves != 0 && prevnstaves != 1 && prevnstaves != staves ) {
for (int i = 0; i < part->nstaves(); ++i) {
// A "staves" value different from the existing nstaves means
// staves in a part will sometimes be hidden.
// We can approximate this with the AUTO hide mode.
part->staff(i)->setHideWhenEmpty(Staff::HideMode::AUTO);
}
}
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testArticulationsCombined_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
2 changes: 2 additions & 0 deletions mtest/musicxml/io/testBarlinesGrandStaff_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
<bracket type="1" span="2" col="1"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testCueNotes3_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Voice</trackName>
<Instrument id="voice">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testFretDiagramLayoutOrder_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testFretboardDiagrams_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testLyricExtensions_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
2 changes: 2 additions & 0 deletions mtest/musicxml/io/testNegativeOffset_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
<bracket type="1" span="2" col="1"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
4 changes: 4 additions & 0 deletions mtest/musicxml/io/testPartNames_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
<bracket type="1" span="2" col="1"/>
<barLineSpan>2</barLineSpan>
</Staff>
<Staff id="2">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down Expand Up @@ -126,6 +128,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Voice</trackName>
<Instrument id="voice">
Expand Down Expand Up @@ -187,6 +190,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>P3</trackName>
<Instrument id="bass">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testPedalChangesBroken_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
1 change: 1 addition & 0 deletions mtest/musicxml/io/testPedalChanges_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
Expand Down
Loading

0 comments on commit 820cc1c

Please sign in to comment.