2 extender-engraver.cc -- implement Extender_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>
12 #include "engraver.hh"
13 #include "group-interface.hh"
15 #include "lyric-extender.hh"
16 #include "note-head.hh"
19 void completize_extender (Spanner *sp);
21 class Extender_engraver : public Engraver
25 Spanner *pending_extender_;
28 TRANSLATOR_DECLARATIONS (Extender_engraver);
31 virtual void acknowledge_grob (Grob_info);
32 virtual void finalize ();
33 virtual bool try_music (Music*);
34 virtual void stop_translation_timestep ();
35 virtual void process_music ();
39 Extender_engraver::Extender_engraver ()
42 pending_extender_ = 0;
47 Extender_engraver::try_music (Music *r)
58 Extender_engraver::process_music ()
61 extender_ = make_spanner ("LyricExtender", ev_->self_scm ());
65 Extender_engraver::acknowledge_grob (Grob_info i)
67 Item *item = dynamic_cast<Item*> (i.grob_);
70 && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
73 extender_->set_bound (LEFT, item);
75 if (pending_extender_)
77 pending_extender_->set_property ("next", item->self_scm ());
78 completize_extender (pending_extender_);
79 pending_extender_ = 0;
85 Extender_engraver::stop_translation_timestep ()
87 if (extender_ || pending_extender_)
89 Context *voice = get_voice_to_lyrics (context ());
90 Grob *h = voice ? get_current_note_head (voice) : 0;
96 Pointer_group_interface::add_grob (extender_,
97 ly_symbol2scm ("heads"), h);
100 if (pending_extender_)
102 Pointer_group_interface::add_grob (pending_extender_,
103 ly_symbol2scm ("heads"), h);
109 pending_extender_ = extender_;
118 completize_extender (Spanner *sp)
120 if (!sp->get_bound (RIGHT))
122 SCM heads = sp->get_property ("heads");
123 if (scm_is_pair (heads))
125 Item *it = dynamic_cast<Item*> (unsmob_grob (scm_car (heads)));
127 sp->set_bound (RIGHT, it);
133 Extender_engraver::finalize ()
137 completize_extender (extender_);
139 if (!extender_->get_bound (RIGHT))
140 extender_->warning (_ ("unterminated extender"));
144 if (pending_extender_)
146 completize_extender (pending_extender_);
148 if (!pending_extender_->get_bound (RIGHT))
149 pending_extender_->warning (_ ("unterminated extender"));
150 pending_extender_ =0;
155 ENTER_DESCRIPTION (Extender_engraver,
156 /* descr */ "Create lyric extenders",
157 /* creats*/ "LyricExtender",
158 /* accepts */ "extender-event",
159 /* acks */ "lyric-syllable-interface",