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
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 process_acknowledged_grobs ();
45 Hyphen_engraver::Hyphen_engraver ()
54 Hyphen_engraver::acknowledge_grob (Grob_info i)
57 if (i.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
59 current_lyric_ = i.grob_;
61 && !hyphen_->get_bound (RIGHT)
64 Hyphen_spanner (hyphen_).set_textitem (RIGHT, i.grob_);
71 Hyphen_engraver::try_music (Music* r)
73 if (Hyphen_req* p = dynamic_cast <Hyphen_req *> (r))
85 Hyphen_engraver::finalize ()
89 req_->origin ()->warning (_ ("unterminated hyphen"));
90 hyphen_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
95 Hyphen_engraver::process_acknowledged_grobs ()
101 req_->origin ()->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request."));
105 hyphen_ = new Spanner (get_property ("LyricHyphen"));
107 Hyphen_spanner (hyphen_).set_textitem (LEFT, last_lyric_);
108 announce_grob(hyphen_, req_->self_scm());
114 Hyphen_engraver::stop_translation_timestep ()
118 typeset_grob (hyphen_);
124 last_lyric_ = current_lyric_;
130 Hyphen_engraver::start_translation_timestep ()
136 ENTER_DESCRIPTION(Hyphen_engraver,
137 /* descr */ "Create lyric hyphens",
138 /* creats*/ "LyricHyphen",
139 /* acks */ "lyric-syllable-interface",