2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2015 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/>.
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"
31 class Stanza_number_align_engraver : public Engraver
34 TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver);
37 vector<Grob *> lyrics_;
38 vector<Grob *> stanza_numbers_;
40 DECLARE_ACKNOWLEDGER (lyric_syllable);
41 DECLARE_ACKNOWLEDGER (stanza_number);
42 void stop_translation_timestep ();
45 Stanza_number_align_engraver::Stanza_number_align_engraver ()
50 Stanza_number_align_engraver::acknowledge_lyric_syllable (Grob_info gi)
53 lyrics_.push_back (h);
57 Stanza_number_align_engraver::acknowledge_stanza_number (Grob_info gi)
60 stanza_numbers_.push_back (h);
64 Stanza_number_align_engraver::stop_translation_timestep ()
66 for (vsize i = lyrics_.size (); i--;)
67 for (vsize j = stanza_numbers_.size (); j--;)
68 Side_position_interface::add_support (stanza_numbers_[j], lyrics_[i]);
70 stanza_numbers_.clear ();
74 ADD_ACKNOWLEDGER (Stanza_number_align_engraver, lyric_syllable);
75 ADD_ACKNOWLEDGER (Stanza_number_align_engraver, stanza_number);
77 ADD_TRANSLATOR (Stanza_number_align_engraver,
79 "This engraver ensures that stanza numbers are neatly"