X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpart-combine-engraver.cc;h=f12cfbad95de5324622307e5c0f4cff712076e6f;hb=fe45a114c91a41aa55198886dccf0489ae729032;hp=d8e1f7640975ca7967d7d077655123670febf9ab;hpb=b7a0cffbf9d1069860368f289a5b50e9d1d90ba8;p=lilypond.git diff --git a/lily/part-combine-engraver.cc b/lily/part-combine-engraver.cc index d8e1f76409..f12cfbad95 100644 --- a/lily/part-combine-engraver.cc +++ b/lily/part-combine-engraver.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2000--2009 Jan Nieuwenhuizen + Copyright (C) 2000--2011 Jan Nieuwenhuizen Han-Wen Nienhuys @@ -20,7 +20,6 @@ */ #include "engraver.hh" -#include "multi-measure-rest.hh" #include "note-head.hh" #include "side-position-interface.hh" #include "stem.hh" @@ -39,46 +38,74 @@ protected: DECLARE_ACKNOWLEDGER (stem); DECLARE_TRANSLATOR_LISTENER (part_combine); + DECLARE_TRANSLATOR_LISTENER (note); void process_music (); void stop_translation_timestep (); + void create_item (Stream_event *ev); + private: Item *text_; - Stream_event *event_; + Stream_event *new_event_; // Event happened at this moment + bool note_found_; + // Event possibly from an earlier moment waiting to create a text: + Stream_event *waiting_event_; }; IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, part_combine); void Part_combine_engraver::listen_part_combine (Stream_event *ev) { - ASSIGN_EVENT_ONCE (event_, ev); + ASSIGN_EVENT_ONCE (new_event_, ev); + // If two events occur at the same moment, discard the second as the + // warning indicates: + waiting_event_ = new_event_; +} + +IMPLEMENT_TRANSLATOR_LISTENER (Part_combine_engraver, note); +void +Part_combine_engraver::listen_note (Stream_event *) +{ + note_found_ = true; } Part_combine_engraver::Part_combine_engraver () { text_ = 0; - event_ = 0; + new_event_ = 0; + waiting_event_ = 0; + note_found_ = false; +} + +void +Part_combine_engraver::create_item (Stream_event *ev) +{ + SCM what = ev->get_property ("class"); + SCM text = SCM_EOL; + if (what == ly_symbol2scm ("solo-one-event")) + text = get_property ("soloText"); + else if (what == ly_symbol2scm ("solo-two-event")) + text = get_property ("soloIIText"); + else if (what == ly_symbol2scm ("unisono-event")) + text = get_property ("aDueText"); + + if (Text_interface::is_markup (text)) + { + text_ = make_item ("CombineTextScript", ev->self_scm ()); + text_->set_property ("text", text); + } } void Part_combine_engraver::process_music () { - if (event_ + if (waiting_event_ && to_boolean (get_property ("printPartCombineTexts"))) { - SCM what = event_->get_property ("class"); - SCM text = SCM_EOL; - if (what == ly_symbol2scm ("solo-one-event")) - text = get_property ("soloText"); - else if (what == ly_symbol2scm ("solo-two-event")) - text = get_property ("soloIIText"); - else if (what == ly_symbol2scm ("unisono-event")) - text = get_property ("aDueText"); - - if (Text_interface::is_markup (text)) - { - text_ = make_item ("CombineTextScript", event_->self_scm ()); - text_->set_property ("text", text); - } + if (note_found_ || !to_boolean (get_property ("partCombineTextsOnNote"))) + { + create_item (waiting_event_); + waiting_event_ = 0; + } } } @@ -106,7 +133,8 @@ void Part_combine_engraver::stop_translation_timestep () { text_ = 0; - event_ = 0; + new_event_ = 0; + note_found_ = false; } ADD_ACKNOWLEDGER (Part_combine_engraver, note_head); @@ -121,6 +149,7 @@ ADD_TRANSLATOR (Part_combine_engraver, /* read */ "printPartCombineTexts " + "partCombineTextsOnNote " "soloText " "soloIIText " "aDueText ",