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_;
31 VIRTUAL_COPY_CONS (Translator);
34 virtual void acknowledge_grob (Grob_info);
35 virtual void do_removal_processing();
36 void deprecated_process_music();
37 virtual bool try_music (Music*);
38 virtual void stop_translation_timestep();
39 virtual void start_translation_timestep ();
40 virtual void create_grobs ();
45 ADD_THIS_TRANSLATOR (Hyphen_engraver);
47 Hyphen_engraver::Hyphen_engraver ()
56 Hyphen_engraver::acknowledge_grob (Grob_info i)
59 if (i.elem_l_->has_interface (ly_symbol2scm ("lyric-syllable-interface")))
61 current_lyric_l_ = i.elem_l_;
63 && !hyphen_p_->get_bound (RIGHT)
66 Hyphen_spanner (hyphen_p_).set_textitem (RIGHT, i.elem_l_);
73 Hyphen_engraver::try_music (Music* r)
75 if (Hyphen_req* p = dynamic_cast <Hyphen_req *> (r))
87 Hyphen_engraver::do_removal_processing ()
91 req_l_->origin ()->warning (_ ("unterminated hyphen"));
92 hyphen_p_->set_bound(RIGHT, unsmob_element (get_property ("currentCommandColumn")));
97 Hyphen_engraver::create_grobs ()
99 deprecated_process_music ();
103 Hyphen_engraver::deprecated_process_music ()
105 if (req_l_ &&! hyphen_p_)
109 req_l_->origin ()->warning (_ ("Nothing to connect hyphen to on the left. Ignoring hyphen request."));
113 hyphen_p_ = new Spanner (get_property ("LyricHyphen"));
115 Hyphen_spanner (hyphen_p_).set_textitem (LEFT, last_lyric_l_);
116 announce_grob (hyphen_p_, req_l_);
122 Hyphen_engraver::stop_translation_timestep ()
126 typeset_grob (hyphen_p_);
130 if (current_lyric_l_)
132 last_lyric_l_ = current_lyric_l_;
138 Hyphen_engraver::start_translation_timestep ()