Skip to content

Commit

Permalink
MusicXML: set all note components invisible
Browse files Browse the repository at this point in the history
Backport of musescore#22943
  • Loading branch information
Klaus Rettinghaus authored and Jojo-Schmitz committed May 29, 2024
1 parent d289145 commit f90fe01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "libmscore/slur.h"
#include "libmscore/staff.h"
#include "libmscore/stafftext.h"
#include "libmscore/stem.h"
#include "libmscore/sym.h"
#include "libmscore/system.h"
#include "libmscore/tempo.h"
Expand Down Expand Up @@ -5962,6 +5963,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
NoteHead::Scheme headScheme = NoteHead::Scheme::HEAD_AUTO;
const QColor noteColor { _e.attributes().value("color").toString() };
QColor noteheadColor = QColor::Invalid;
QColor stemColor = QColor::Invalid;
bool noteheadParentheses = false;
QString noteheadFilled;
int velocity = round(_e.attributes().value("dynamics").toDouble() * 0.9);
Expand Down Expand Up @@ -6037,8 +6039,10 @@ Note* MusicXMLParserPass2::note(const QString& partId,
staff = -1;
}
}
else if (_e.name() == "stem")
else if (_e.name() == "stem") {
stemColor.setNamedColor(_e.attributes().value("color").toString());
stem(stemDir, noStem);
}
else if (_e.name() == "tie") {
tieType = _e.attributes().value("type").toString();
_e.skipCurrentElement();
Expand Down Expand Up @@ -6214,14 +6218,24 @@ Note* MusicXMLParserPass2::note(const QString& partId,
note->setHeadScheme(headScheme);
if (noteColor.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
note->setColor(noteColor);
Stem* stem = c->stem();
if (!stem) {
stem = new Stem(_score);
if (stemColor.isValid())
stem->setColor(stemColor);
else if (noteColor.isValid())
stem->setColor(noteColor);
c->add(stem);
}
setNoteHead(note, noteheadColor, noteheadParentheses, noteheadFilled);
note->setVisible(hasHead && printObject); // TODO also set the stem to invisible
stem->setVisible(printObject);

if (!grace) {
handleSmallness(cue || isSmall, note, c);
note->setPlay(!cue); // cue notes don't play
note->setHeadGroup(headGroup);
if (noteColor != QColor::Invalid)
if (noteColor.isValid())
note->setColor(noteColor);
setNoteHead(note, noteheadColor, noteheadParentheses, noteheadFilled);
note->setVisible(hasHead && printObject); // TODO also set the stem to invisible
Expand Down Expand Up @@ -6278,6 +6292,7 @@ Note* MusicXMLParserPass2::note(const QString& partId,
}

if (acc) {
acc->setVisible(printObject);
note->add(acc);
// save alter value for user accidental
if (acc->accidentalType() != AccidentalType::NONE)
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testColors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
<stem color="#2468AC">down</stem>
<notations>
<slur type="start" color="#EFCDAB" number="1"/>
</notations>
Expand Down

0 comments on commit f90fe01

Please sign in to comment.