Release: update news.
[lilypond/patrick.git] / lily / stanza-number-align-engraver.cc
blob1acf51f362b37921e22d0efc2567a81f3eaf177c
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "context.hh"
21 #include "engraver.hh"
22 #include "note-head.hh"
23 #include "lyric-extender.hh"
24 #include "pointer-group-interface.hh"
25 #include "side-position-interface.hh"
27 #include "translator.icc"
29 class Stanza_number_align_engraver : public Engraver
31 public:
32 TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver);
34 protected:
35 vector<Grob*> lyrics_;
36 vector<Grob*> stanza_numbers_;
38 DECLARE_ACKNOWLEDGER (lyric_syllable);
39 DECLARE_ACKNOWLEDGER (stanza_number);
40 void stop_translation_timestep ();
43 Stanza_number_align_engraver::Stanza_number_align_engraver ()
47 void
48 Stanza_number_align_engraver::acknowledge_lyric_syllable (Grob_info gi)
50 Grob *h = gi.grob ();
51 lyrics_.push_back (h);
54 void
55 Stanza_number_align_engraver::acknowledge_stanza_number (Grob_info gi)
57 Grob *h = gi.grob ();
58 stanza_numbers_.push_back (h);
61 void
62 Stanza_number_align_engraver::stop_translation_timestep ()
64 for (vsize i = lyrics_.size (); i--;)
65 for (vsize j = stanza_numbers_.size (); j--;)
66 Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]);
68 stanza_numbers_.clear ();
69 lyrics_.clear ();
72 ADD_ACKNOWLEDGER (Stanza_number_align_engraver, lyric_syllable);
73 ADD_ACKNOWLEDGER (Stanza_number_align_engraver, stanza_number);
75 ADD_TRANSLATOR (Stanza_number_align_engraver,
76 /* doc */
77 "This engraver ensures that stanza numbers are neatly"
78 " aligned.",
80 /* create */
81 "",
83 /* read */
84 "",
86 /* write */
87 "");