2 hyphen-engraver.cc -- implement Hyphen_engraver
4 (c) 1999 Glen Prideaux <glenprideaux@iname.com>
7 #include "flower-proto.hh"
8 #include "musical-request.hh"
9 #include "hyphen-spanner.hh"
10 #include "paper-column.hh"
12 #include "engraver.hh"
15 Generate an centred hyphen. Should make a Hyphen_spanner that
16 typesets a nice centred hyphen of varying length depending on the
17 gap between syllables.
19 We remember the last Item that come across. When we get a
20 request, we create the spanner, and attach the left point to the
21 last lyrics, and the right point to any lyrics we receive by
23 class Hyphen_engraver : public Engraver
26 Grob *current_lyric_l_;
30 TRANSLATOR_DECLARATIONS(Hyphen_engraver);
33 virtual void acknowledge_grob (Grob_info);
34 virtual void finalize ();
35 virtual bool try_music (Music*);
36 virtual void stop_translation_timestep ();
37 virtual void start_translation_timestep ();
38 virtual void create_grobs ();
45 Hyphen_engraver::Hyphen_engraver ()
54 Hyphen_engraver::acknowledge_grob (Grob_info i)
57 if (i.grob_l_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
59 current_lyric_l_ = i.grob_l_;
61 && !hyphen_p_->get_bound (RIGHT)
64 Hyphen_spanner (hyphen_p_).set_textitem (RIGHT, i.grob_l_);
71 Hyphen_engraver::try_music (Music* r)
73 if (Hyphen_req* p = dynamic_cast <Hyphen_req *> (r))
85 Hyphen_engraver::finalize ()
89 req_l_->origin ()->warning (_ ("unterminated hyphen"));
90 hyphen_p_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
95 Hyphen_engraver::create_grobs ()
97 if (req_l_ &&! hyphen_p_)
101 req_l_->origin ()->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request."));
105 hyphen_p_ = new Spanner (get_property ("LyricHyphen"));
107 Hyphen_spanner (hyphen_p_).set_textitem (LEFT, last_lyric_l_);
108 announce_grob(hyphen_p_, req_l_->self_scm());
114 Hyphen_engraver::stop_translation_timestep ()
118 typeset_grob (hyphen_p_);
122 if (current_lyric_l_)
124 last_lyric_l_ = current_lyric_l_;
130 Hyphen_engraver::start_translation_timestep ()
136 ENTER_DESCRIPTION(Hyphen_engraver,
137 /* descr */ "Create lyric hyphens",
138 /* creats*/ "LyricHyphen",
139 /* acks */ "lyric-syllable-interface",