X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhyphen-engraver.cc;h=db20eb02b69b8d7bd9dee8828a0655bb2b69afb6;hb=b9955d706ca6f136b160f0611db85c6bdf0fea9b;hp=44eb9298053fe18fbb10a5f31fd674740caef1f1;hpb=07a5ed85c189a97d04c550679826dfc5eca2eb18;p=lilypond.git diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index 44eb929805..db20eb02b6 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -1,11 +1,13 @@ /* hyphen-engraver.cc -- implement Hyphen_engraver - (c) 1999 Glen Prideaux + source file of the GNU LilyPond music typesetter + + (c) 1999--2003 Glen Prideaux */ #include "flower-proto.hh" -#include "musical-request.hh" +#include "event.hh" #include "hyphen-spanner.hh" #include "paper-column.hh" #include "item.hh" @@ -17,52 +19,51 @@ gap between syllables. We remember the last Item that come across. When we get a - request, we create the spanner, and attach the left point to the + event, we create the spanner, and attach the left point to the last lyrics, and the right point to any lyrics we receive by then. */ class Hyphen_engraver : public Engraver { - Grob *last_lyric_l_; - Grob *current_lyric_l_; - Hyphen_req* req_l_; - Spanner* hyphen_p_; + Grob *last_lyric_; + Grob *current_lyric_; + Music* req_; + Spanner* hyphen_; public: - Hyphen_engraver (); - VIRTUAL_COPY_CONS (Translator); + TRANSLATOR_DECLARATIONS(Hyphen_engraver); protected: virtual void acknowledge_grob (Grob_info); - virtual void finalize(); + virtual void finalize (); virtual bool try_music (Music*); - virtual void stop_translation_timestep(); + virtual void stop_translation_timestep (); virtual void start_translation_timestep (); - virtual void create_grobs (); + virtual void process_acknowledged_grobs (); private: }; -ADD_THIS_TRANSLATOR (Hyphen_engraver); + Hyphen_engraver::Hyphen_engraver () { - current_lyric_l_ = 0; - last_lyric_l_ = 0; - hyphen_p_ = 0; - req_l_ = 0; + current_lyric_ = 0; + last_lyric_ = 0; + hyphen_ = 0; + req_ = 0; } void Hyphen_engraver::acknowledge_grob (Grob_info i) { // -> text-item - if (i.elem_l_->has_interface (ly_symbol2scm ("lyric-syllable-interface"))) + if (i.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) { - current_lyric_l_ = i.elem_l_; - if (hyphen_p_ - && !hyphen_p_->get_bound (RIGHT) + current_lyric_ = i.grob_; + if (hyphen_ + && !hyphen_->get_bound (RIGHT) ) { - Hyphen_spanner (hyphen_p_).set_textitem (RIGHT, i.elem_l_); + Hyphen_spanner (hyphen_).set_textitem (RIGHT, i.grob_); } } } @@ -71,42 +72,38 @@ Hyphen_engraver::acknowledge_grob (Grob_info i) bool Hyphen_engraver::try_music (Music* r) { - if (Hyphen_req* p = dynamic_cast (r)) - { - if (req_l_) + if (req_) return false; - req_l_ = p; + req_ = r; return true; - } - return false; } void Hyphen_engraver::finalize () { - if (hyphen_p_) + if (hyphen_) { - req_l_->origin ()->warning (_ ("unterminated hyphen")); - hyphen_p_->set_bound(RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); + req_->origin ()->warning (_ ("unterminated hyphen")); + hyphen_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); } } void -Hyphen_engraver::create_grobs () +Hyphen_engraver::process_acknowledged_grobs () { - if (req_l_ &&! hyphen_p_) + if (req_ &&! hyphen_) { - if (!last_lyric_l_) + if (!last_lyric_) { - req_l_->origin ()->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request.")); + req_->origin ()->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen event.")); return; } - hyphen_p_ = new Spanner (get_property ("LyricHyphen")); + hyphen_ = new Spanner (get_property ("LyricHyphen")); - Hyphen_spanner (hyphen_p_).set_textitem (LEFT, last_lyric_l_); - announce_grob (hyphen_p_, req_l_); + Hyphen_spanner (hyphen_).set_textitem (LEFT, last_lyric_); + announce_grob(hyphen_, req_->self_scm()); } } @@ -114,23 +111,30 @@ Hyphen_engraver::create_grobs () void Hyphen_engraver::stop_translation_timestep () { - if (hyphen_p_) + if (hyphen_) { - typeset_grob (hyphen_p_); - hyphen_p_ = 0; + typeset_grob (hyphen_); + hyphen_ = 0; } - if (current_lyric_l_) + if (current_lyric_) { - last_lyric_l_ = current_lyric_l_; - current_lyric_l_ =0; + last_lyric_ = current_lyric_; + current_lyric_ =0; } } void Hyphen_engraver::start_translation_timestep () { - req_l_ = 0; + req_ = 0; } +ENTER_DESCRIPTION(Hyphen_engraver, +/* descr */ "Create lyric hyphens", +/* creats*/ "LyricHyphen", +/* accepts */ "hyphen-event", +/* acks */ "lyric-syllable-interface", +/* reads */ "", +/* write */ "");