Skip to content

Commit

Permalink
Acknowledge color attribute in MusicXML for some elements (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilios authored Oct 22, 2024
1 parent 529a3df commit 2067a01
Show file tree
Hide file tree
Showing 2 changed files with 418 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/parser/mxl/lomse_mxl_analyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,14 @@ class MxlElementAnalyser

Color get_attribute_color()
{
if (has_attribute(&m_analysedNode, "color"))
return get_attribute_color(&m_analysedNode);
}

Color get_attribute_color(XmlNode* node)
{
if (has_attribute(node, "color"))
{
string value = m_analysedNode.attribute_value("color");
string value = node->attribute_value("color");
bool fError = false;
ImoColorDto color;
if (value.length() == 7)
Expand Down Expand Up @@ -2561,8 +2566,12 @@ class BarlineMxlAnalyser : public MxlElementAnalyser

//@ bar-style?
string barStyle = "";
Color color = Color(0,0,0);
if (get_optional("bar-style"))
{
barStyle = m_childToAnalyse.value();
color = get_attribute_color(&m_childToAnalyse);
}
if (barStyle.empty())
barStyle = (location == "left" ? "none" : "regular");

Expand All @@ -2586,6 +2595,7 @@ class BarlineMxlAnalyser : public MxlElementAnalyser

EBarline type = find_barline_type(barStyle);
combine_barlines(m_pBarline, type);
m_pBarline->set_color(color);
set_num_repeats();

//TODO: do anything with m_wings
Expand Down Expand Up @@ -3494,6 +3504,9 @@ class DynamicsMxlAnalyser : public MxlElementAnalyser
// attrib: %placement;
pImo->set_placement(get_attribute_placement());

//attrib: %print-style-align;
get_attributes_for_print_style_align(pImo);

//inherit placement from parent <direction> if not set in this <dynamics>
if (pImo->get_placement() == k_placement_default && m_pAnchor->is_direction())
pImo->set_placement( (static_cast<ImoDirection*>(m_pAnchor))->get_placement() );
Expand Down Expand Up @@ -4179,7 +4192,7 @@ class KeyMxlAnalyser : public MxlElementAnalyser
}

//attrb: %print-style;
//TODO
get_attributes_for_print_style(pKey);

//attrb: %print-object;
//TODO
Expand Down Expand Up @@ -4614,7 +4627,7 @@ class MetronomeMxlAnalyser : public MxlElementAnalyser
ImFactory::inject(k_imo_metronome_mark, pDoc) );

//attrb: %print-style;
//TODO
//get_attributes_for_print_style(pMtr);

//attrb: parentheses %yes-no; #IMPLIED
//TODO
Expand Down Expand Up @@ -5067,6 +5080,9 @@ class NoteRestMxlAnalyser : public MxlElementAnalyser
{
//attribs

//attrb: color
Color color = get_attribute_color();

//attrb: print-object
bool fVisible = get_optional_yes_no_attribute("print-object", "yes");

Expand Down Expand Up @@ -5123,6 +5139,7 @@ class NoteRestMxlAnalyser : public MxlElementAnalyser
else
analyse_mandatory("pitch", pNote);
}
pNR->set_color(color);

// <duration>, except for grace notes
int duration = 0;
Expand Down Expand Up @@ -5185,6 +5202,7 @@ class NoteRestMxlAnalyser : public MxlElementAnalyser
// [<notehead>]
if (get_optional("notehead"))
{
pNR->set_color( get_attribute_color(&m_childToAnalyse) );
}

// [<notehead-text>]
Expand Down Expand Up @@ -8346,8 +8364,11 @@ class TimeMxlAnalyser : public MxlElementAnalyser
if (has_attribute("symbol"))
set_symbol(pTime);

//TODO attrib: %time-separator;
//TODO attrib: %print-style-align;
//attrib: %time-separator;
//TODO

//attrib: %print-style-align;
get_attributes_for_print_style_align(pTime);

//attrb: %print-object;
bool fVisible = get_optional_yes_no_attribute("print-object", "yes");
Expand Down Expand Up @@ -8957,9 +8978,13 @@ class WedgeMxlAnalyser : public MxlElementAnalyser
// attrib: %line-type;
// attrib: %dashed-formatting;
// attrib: %position;
//TODO

// attrib: %color;
m_pInfo1->set_color(get_attribute_color());

// attrib: %optional-unique-id;
//TODO
//TODO

set_wedge_type_and_id(type, num);

Expand Down
Loading

0 comments on commit 2067a01

Please sign in to comment.