2 extender-engraver.cc -- implement Extender_engraver
4 (c) 1999 Glen Prideaux <glenprideaux@iname.com>,
5 Han-Wen Nienhuys, Jan Nieuwenhuizen.
9 #include "flower-proto.hh"
10 #include "musical-request.hh"
11 #include "lyric-extender.hh"
12 #include "paper-column.hh"
14 #include "engraver.hh"
15 #include "drul-array.hh"
16 #include "lyric-extender.hh"
21 Generate an centred extender. Should make a Extender_spanner that
22 typesets a nice centred extender of varying length depending on the
23 gap between syllables.
25 We remember the last Item that come across. When we get a
26 request, we create the spanner, and attach the left point to the
27 last lyrics, and the right point to any lyrics we receive by
29 class Extender_engraver
: public Engraver
32 Grob
*current_lyric_l_
;
37 VIRTUAL_COPY_CONS (Translator
);
40 virtual void acknowledge_grob (Grob_info
);
41 virtual void finalize ();
42 virtual bool try_music (Music
*);
43 virtual void stop_translation_timestep ();
44 virtual void start_translation_timestep ();
45 virtual void process_music ();
51 ADD_THIS_TRANSLATOR (Extender_engraver
);
53 Extender_engraver::Extender_engraver ()
62 Extender_engraver::acknowledge_grob (Grob_info i
)
65 if (i
.elem_l_
->has_interface (ly_symbol2scm ("lyric-syllable-interface")))
67 current_lyric_l_
= i
.elem_l_
;
69 && !extender_p_
->get_bound (RIGHT
)
72 Lyric_extender::set_textitem (extender_p_
, RIGHT
, dynamic_cast<Item
*> (i
.elem_l_
));
79 Extender_engraver::try_music (Music
* r
)
81 if (Extender_req
* p
= dynamic_cast <Extender_req
*> (r
))
93 Extender_engraver::finalize ()
97 req_l_
->origin ()->warning (_ ("unterminated extender"));
98 extender_p_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
103 Extender_engraver::process_music ()
105 if (req_l_
&& ! extender_p_
)
109 req_l_
->origin ()->warning (_ ("Nothing to connect extender to on the left. Ignoring extender request."));
113 extender_p_
= new Spanner (get_property ("LyricExtender"));
116 Lyric_extender::set_textitem (extender_p_
, LEFT
, last_lyric_l_
);
117 announce_grob (extender_p_
, req_l_
);
123 Extender_engraver::stop_translation_timestep ()
127 typeset_grob (extender_p_
);
131 if (current_lyric_l_
)
133 last_lyric_l_
= current_lyric_l_
;
139 Extender_engraver::start_translation_timestep ()