]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-align-engraver.cc
* stepmake/aclocal.m4 (STEPMAKE_PANGO_FT2): Define HAVE_PANGO16 too.
[lilypond.git] / lily / stanza-number-align-engraver.cc
1
2 /*
3   stanza-number-align-engraver.cc -- implement
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
9
10 #include "context.hh"
11 #include "engraver.hh"
12 #include "note-head.hh"
13 #include "lyric-extender.hh"
14 #include "group-interface.hh"
15 #include "side-position-interface.hh"
16
17 class Stanza_number_align_engraver : public Engraver
18 {
19 public:
20   TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver);
21
22 protected:
23   Link_array<Grob> lyrics_;
24   Link_array<Grob> stanza_numbers_;
25   virtual void acknowledge_grob (Grob_info);
26   virtual void stop_translation_timestep ();
27 };
28
29 Stanza_number_align_engraver::Stanza_number_align_engraver ()
30 {
31 }
32
33 void
34 Stanza_number_align_engraver::acknowledge_grob (Grob_info gi)
35 {
36   Grob *h = gi.grob_;
37
38   if (h->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
39     lyrics_.push (h);
40   else if (h->internal_has_interface (ly_symbol2scm ("stanza-number-interface")))
41     stanza_numbers_.push (h);
42 }
43
44 void
45 Stanza_number_align_engraver::stop_translation_timestep ()
46 {
47   for (int i = lyrics_.size (); i--;)
48     for (int j = stanza_numbers_.size (); j--;)
49       Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]);
50
51   stanza_numbers_.clear ();
52   lyrics_.clear ();
53 }
54
55 ADD_TRANSLATOR (Stanza_number_align_engraver,
56                 "This engraver ensures that stanza numbers are neatly aligned. ",
57                 "",
58                 "",
59                 "stanza-number-interface lyric-syllable-interface ",
60                 "",
61                 "");
62