X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fvolta-engraver.cc;h=604c53c573493721796b068f66db084b4ae0c5ba;hb=f9214bac21e9926dc3248416f58190c98c4167a9;hp=531c6fa02a9bbd6da648f849b66985c829a2ac98;hpb=58bcc84c9480dae1b21bc24d8396b91fe19e0131;p=lilypond.git diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index 531c6fa02a..604c53c573 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -3,21 +3,27 @@ source file of the GNU LilyPond music typesetter - (c) 2000--2005 Han-Wen Nienhuys + (c) 2000--2007 Han-Wen Nienhuys */ #include "engraver.hh" + +#include "bar-line.hh" #include "context.hh" -#include "volta-bracket.hh" +#include "international.hh" #include "note-column.hh" -#include "bar-line.hh" +#include "item.hh" #include "side-position-interface.hh" -#include "warn.hh" #include "staff-symbol.hh" +#include "text-interface.hh" +#include "volta-bracket.hh" +#include "warn.hh" + +#include "translator.icc" /* Create Volta spanners, by reading repeatCommands property, usually - set by Unfolded_repeat_iterator. + set by Volta_repeat_iterator. */ class Volta_engraver : public Engraver { @@ -25,10 +31,15 @@ public: TRANSLATOR_DECLARATIONS (Volta_engraver); protected: - virtual void acknowledge_grob (Grob_info); + DECLARE_END_ACKNOWLEDGER (staff_symbol); + DECLARE_ACKNOWLEDGER (staff_symbol); + DECLARE_ACKNOWLEDGER (note_column); + DECLARE_ACKNOWLEDGER (bar_line); + virtual void finalize (); - virtual void stop_translation_timestep (); - virtual void process_music (); + virtual void derived_mark () const; + void stop_translation_timestep (); + void process_music (); Moment started_mom_; Spanner *volta_span_; @@ -37,12 +48,19 @@ protected: SCM start_string_; bool staff_eligible (); - }; +void +Volta_engraver::derived_mark () const +{ + scm_gc_mark (staff_); + scm_gc_mark (start_string_); +} + Volta_engraver::Volta_engraver () { staff_ = SCM_EOL; + start_string_ = SCM_EOL; volta_span_ = 0; end_volta_span_ = 0; } @@ -59,9 +77,7 @@ Volta_engraver::staff_eligible () { SCM doit = get_property ("voltaOnThisStaff"); if (scm_is_bool (doit)) - { - return to_boolean (doit); - } + return to_boolean (doit); if (!unsmob_grob (staff_)) return false; @@ -72,22 +88,16 @@ Volta_engraver::staff_eligible () */ SCM staffs = get_property ("stavesFound"); - /* - only put a volta on the top staff. - - May be this is a bit convoluted, and we should have a single - volta engraver in score context or somesuch. - - */ + /* Only put a volta on the top staff. + Maybe this is a bit convoluted, and we should have a single + volta engraver in score context or somesuch. */ if (!scm_is_pair (staffs)) { - programming_error ("Huh? Volta engraver can't find staffs?"); + programming_error ("volta engraver can't find staffs"); return false; } else if (scm_car (scm_last_pair (staffs)) != staff_) - { - return false; - } + return false; return true; } @@ -130,9 +140,8 @@ Volta_engraver::process_music () } if (end && !volta_span_) - { - warning (_ ("No volta spanner to end")); // fixme: be more verbose. - } + /* fixme: be more verbose. */ + warning (_ ("cannot end volta spanner")); else if (end) { end_volta_span_ = volta_span_; @@ -142,11 +151,12 @@ Volta_engraver::process_music () if (volta_span_ && (scm_is_string (start_string_) || scm_is_pair (start_string_))) { - warning (_ ("Already have a volta spanner. Stopping that one prematurely.")); + warning (_ ("already have a volta spanner, ending that one prematurely")); if (end_volta_span_) { - warning (_ ("Also have a stopped spanner. Giving up.")); + warning (_ ("also already have an ended spanner")); + warning (_ ("giving up")); return; } @@ -155,7 +165,7 @@ Volta_engraver::process_music () } if (!volta_span_ - && (scm_is_string (start_string_) || scm_is_pair (start_string_))) + && Text_interface::is_markup (start_string_)) { started_mom_ = now_mom (); @@ -166,36 +176,42 @@ Volta_engraver::process_music () } void -Volta_engraver::acknowledge_grob (Grob_info i) +Volta_engraver::acknowledge_note_column (Grob_info i) { - if (Item *item = dynamic_cast (i.grob_)) - { - if (Note_column::has_interface (item)) - { - if (volta_span_) - Volta_bracket_interface::add_column (volta_span_, item); - } - if (Bar_line::has_interface (item)) - { - if (volta_span_) - Volta_bracket_interface::add_bar (volta_span_, item); - if (end_volta_span_) - Volta_bracket_interface::add_bar (end_volta_span_, item); - } - } - else if (Staff_symbol::has_interface (i.grob_)) - { - /* - We only want to know about a single staff: then we add to the - support. */ - if (staff_ != SCM_EOL) - staff_ = SCM_UNDEFINED; + if (volta_span_) + Volta_bracket_interface::add_column (volta_span_, i.grob ()); +} - if (staff_ != SCM_UNDEFINED) - staff_ = i.grob_->self_scm (); - } +void +Volta_engraver::acknowledge_bar_line (Grob_info i) +{ + if (volta_span_) + Volta_bracket_interface::add_bar (volta_span_, i.item ()); + if (end_volta_span_) + Volta_bracket_interface::add_bar (end_volta_span_, i.item ()); } +void +Volta_engraver::acknowledge_end_staff_symbol (Grob_info i) +{ + if (i.grob ()->self_scm () == staff_) + staff_ = SCM_EOL; +} + +void +Volta_engraver::acknowledge_staff_symbol (Grob_info i) +{ + /* + We only want to know about a single staff: then we add to the + support. */ + if (staff_ != SCM_EOL) + staff_ = SCM_UNDEFINED; + + if (staff_ != SCM_UNDEFINED) + staff_ = i.grob ()->self_scm (); +} + + void Volta_engraver::finalize () { @@ -232,17 +248,17 @@ Volta_engraver::stop_translation_timestep () Item *ci = dynamic_cast (cc); volta_span_->set_bound (LEFT, ci); } - } /* TODO: should attach volta to paper-column if no bar is found. */ - +ADD_ACKNOWLEDGER (Volta_engraver, staff_symbol); +ADD_END_ACKNOWLEDGER (Volta_engraver, staff_symbol); +ADD_ACKNOWLEDGER (Volta_engraver, note_column); +ADD_ACKNOWLEDGER (Volta_engraver, bar_line); ADD_TRANSLATOR (Volta_engraver, - /* descr */ "Make volta brackets.", - /* creats*/ "VoltaBracket", - /* accepts */ "", - /* acks */ "bar-line-interface staff-symbol-interface note-column-interface", - /* reads */ "repeatCommands voltaSpannerDuration stavesFound", + /* doc */ "Make volta brackets.", + /* create */ "VoltaBracket", + /* read */ "repeatCommands voltaSpannerDuration stavesFound", /* write */ "");