X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhyphen-engraver.cc;h=e4f4f3a9918656e9923eabfcb711f44a0e45eecb;hb=a9bf1bb2c745d066d882bbe7f5a92ced8ef1fc35;hp=cbd8d1a2a7e0bffd05f3c647bc7520b3ad124be4;hpb=bdf4ab13203502e7ec7cf9cf5896527643a07c1f;p=lilypond.git diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index cbd8d1a2a7..e4f4f3a991 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -3,53 +3,61 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2005 Glen Prideaux , - Han-Wen Nienhuys , + (c) 1999--2006 Glen Prideaux , + Han-Wen Nienhuys , Jan Nieuwenhuizen */ -#include "warn.hh" -#include "item.hh" #include "engraver.hh" +#include "international.hh" +#include "item.hh" +#include "pointer-group-interface.hh" #include "spanner.hh" +#include "warn.hh" class Hyphen_engraver : public Engraver { Music *ev_; + Music *finished_ev_; + Spanner *hyphen_; Spanner *finished_hyphen_; + public: TRANSLATOR_DECLARATIONS (Hyphen_engraver); protected: - virtual void acknowledge_grob (Grob_info); + + DECLARE_ACKNOWLEDGER (lyric_syllable); + virtual void finalize (); virtual bool try_music (Music *); - virtual void stop_translation_timestep (); - virtual void process_music (); -private: + + void stop_translation_timestep (); + void process_music (); }; Hyphen_engraver::Hyphen_engraver () { hyphen_ = 0; finished_hyphen_ = 0; + finished_ev_ = 0; ev_ = 0; } void -Hyphen_engraver::acknowledge_grob (Grob_info i) +Hyphen_engraver::acknowledge_lyric_syllable (Grob_info i) { - Item *item = dynamic_cast (i.grob_); - // -> Text_item - if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))) - { - if (hyphen_) - hyphen_->set_bound (LEFT, item); + Item *item = i.item (); + + if (!hyphen_) + hyphen_ = make_spanner ("LyricSpace", item->self_scm ()); - if (finished_hyphen_) - finished_hyphen_->set_bound (RIGHT, item); - } + if (hyphen_) + hyphen_->set_bound (LEFT, item); + + if (finished_hyphen_) + finished_hyphen_->set_bound (RIGHT, item); } bool @@ -67,13 +75,9 @@ completize_hyphen (Spanner *sp) { if (!sp->get_bound (RIGHT)) { - SCM heads = sp->get_property ("heads"); - if (scm_is_pair (heads)) - { - Item *it = dynamic_cast (unsmob_grob (scm_car (heads))); - if (it) - sp->set_bound (RIGHT, it); - } + extract_item_set (sp, "heads", heads); + if (heads.size ()) + sp->set_bound (RIGHT, heads.back ()); } } @@ -99,7 +103,8 @@ Hyphen_engraver::finalize () if (!finished_hyphen_->get_bound (RIGHT)) { - finished_hyphen_->warning (_ ("unterminated hyphen; removing")); + if (finished_ev_) + finished_hyphen_->warning (_ ("unterminated hyphen; removing")); finished_hyphen_->suicide (); } finished_hyphen_ = 0; @@ -110,9 +115,7 @@ void Hyphen_engraver::process_music () { if (ev_) - { - hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ()); - } + hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ()); } void @@ -121,25 +124,34 @@ Hyphen_engraver::stop_translation_timestep () if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT)) { finished_hyphen_ = 0; + finished_ev_ = 0; } - + if (finished_hyphen_ && hyphen_) { - programming_error ("Haven't finished hyphen yet."); + programming_error ("hyphen not finished yet"); finished_hyphen_ = 0; + finished_ev_ = 0; } if (hyphen_) - finished_hyphen_ = hyphen_; + { + finished_hyphen_ = hyphen_; + finished_ev_ = ev_; + } + hyphen_ = 0; - ev_ = 0; } +#include "translator.icc" + +ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable); + ADD_TRANSLATOR (Hyphen_engraver, - /* descr */ "Create lyric hyphens", - /* creats*/ "LyricHyphen", - /* accepts */ "hyphen-event", - /* acks */ "lyric-syllable-interface", - /* reads */ "", + /* doc */ "Create lyric hyphens and " + "distance constraints between words.", + /* create */ "LyricHyphen LyricSpace", + /* accept */ "hyphen-event", + /* read */ "", /* write */ "");