2 hyphen-engraver.cc -- implement Hyphen_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2006 Glen Prideaux <glenprideaux@iname.com>,
7 Han-Wen Nienhuys <hanwen@xs4all.nl>,
8 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "engraver.hh"
12 #include "international.hh"
14 #include "pointer-group-interface.hh"
18 class Hyphen_engraver : public Engraver
24 Spanner *finished_hyphen_;
27 TRANSLATOR_DECLARATIONS (Hyphen_engraver);
31 DECLARE_ACKNOWLEDGER (lyric_syllable);
33 virtual void finalize ();
34 virtual bool try_music (Music *);
36 void stop_translation_timestep ();
37 void process_music ();
40 Hyphen_engraver::Hyphen_engraver ()
49 Hyphen_engraver::acknowledge_lyric_syllable (Grob_info i)
51 Item *item = i.item ();
54 hyphen_ = make_spanner ("LyricSpace", item->self_scm ());
57 hyphen_->set_bound (LEFT, item);
60 finished_hyphen_->set_bound (RIGHT, item);
64 Hyphen_engraver::try_music (Music *r)
74 completize_hyphen (Spanner *sp)
76 if (!sp->get_bound (RIGHT))
78 extract_item_set (sp, "heads", heads);
80 sp->set_bound (RIGHT, heads.back ());
85 Hyphen_engraver::finalize ()
89 completize_hyphen (hyphen_);
91 if (!hyphen_->get_bound (RIGHT))
93 hyphen_->warning (_ ("removing unterminated hyphen"));
100 if (finished_hyphen_)
102 completize_hyphen (finished_hyphen_);
104 if (!finished_hyphen_->get_bound (RIGHT))
107 finished_hyphen_->warning (_ ("unterminated hyphen; removing"));
108 finished_hyphen_->suicide ();
110 finished_hyphen_ = 0;
115 Hyphen_engraver::process_music ()
118 hyphen_ = make_spanner ("LyricHyphen", ev_->self_scm ());
122 Hyphen_engraver::stop_translation_timestep ()
124 if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT))
126 finished_hyphen_ = 0;
130 if (finished_hyphen_ && hyphen_)
132 programming_error ("hyphen not finished yet");
133 finished_hyphen_ = 0;
139 finished_hyphen_ = hyphen_;
147 #include "translator.icc"
149 ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable);
151 ADD_TRANSLATOR (Hyphen_engraver,
152 /* doc */ "Create lyric hyphens and "
153 "distance constraints between words.",
154 /* create */ "LyricHyphen LyricSpace",
155 /* accept */ "hyphen-event",