2 hyphen-engraver.cc -- implement Hyphen_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 Glen Prideaux <glenprideaux@iname.com>,
7 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
8 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "engraver.hh"
16 class Hyphen_engraver : public Engraver
20 Spanner *finished_hyphen_;
22 TRANSLATOR_DECLARATIONS (Hyphen_engraver);
25 virtual void acknowledge_grob (Grob_info);
26 virtual void finalize ();
27 virtual bool try_music (Music*);
28 virtual void stop_translation_timestep ();
29 virtual void process_music ();
37 Hyphen_engraver::Hyphen_engraver ()
45 Hyphen_engraver::acknowledge_grob (Grob_info i)
47 Item * item = dynamic_cast<Item*> (i.grob_);
49 if (item && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
52 hyphen_->set_bound (LEFT, item);
55 finished_hyphen_->set_bound (RIGHT, item);
61 Hyphen_engraver::try_music (Music* r)
71 completize_hyphen (Spanner* sp)
73 if (!sp->get_bound (RIGHT))
75 SCM heads = sp->get_property ("heads");
76 if (ly_c_pair_p (heads))
78 Item* it = dynamic_cast<Item*> (unsmob_grob (ly_car (heads)));
80 sp->set_bound (RIGHT, it);
88 Hyphen_engraver::finalize ()
92 completize_hyphen (hyphen_);
94 if (!hyphen_->get_bound (RIGHT))
96 hyphen_->warning (_ ("removing unterminated hyphen"));
100 typeset_grob (hyphen_);
104 if (finished_hyphen_)
106 completize_hyphen (finished_hyphen_);
108 if (!finished_hyphen_->get_bound (RIGHT))
110 finished_hyphen_->warning (_("unterminated hyphen; removing"));
111 finished_hyphen_->suicide ();
113 typeset_grob (finished_hyphen_);
119 Hyphen_engraver::process_music ()
123 hyphen_ = make_spanner ("LyricHyphen");
124 announce_grob (hyphen_, ev_->self_scm ());
130 Hyphen_engraver::stop_translation_timestep ()
132 if (finished_hyphen_ && finished_hyphen_->get_bound (RIGHT))
134 typeset_grob (finished_hyphen_);
135 finished_hyphen_ = 0;
138 if (finished_hyphen_ && hyphen_)
140 programming_error ("Haven't finished hyphen yet.");
141 typeset_grob (finished_hyphen_);
146 finished_hyphen_ = hyphen_;
155 ENTER_DESCRIPTION (Hyphen_engraver,
156 /* descr */ "Create lyric hyphens",
157 /* creats*/ "LyricHyphen",
158 /* accepts */ "hyphen-event",
159 /* acks */ "lyric-syllable-interface",