Doc & scm/: Music-functions and type-predicates.
[lilypond/mpolesky.git] / lily / stanza-number-engraver.cc
blob11281bbdfeadf4a289fa093ef1b19545cc904a6c
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>, Glen Prideaux <glenprideaux@iname.com>
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 "engraver.hh"
21 #include "side-position-interface.hh"
22 #include "text-interface.hh"
23 #include "item.hh"
25 class Stanza_number_engraver : public Engraver
27 Item *text_;
29 SCM last_stanza_;
30 public:
31 TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
32 void process_music ();
33 virtual void derived_mark () const;
34 void stop_translation_timestep ();
35 DECLARE_ACKNOWLEDGER (lyric_syllable);
38 void
39 Stanza_number_engraver::derived_mark () const
41 scm_gc_mark (last_stanza_);
45 TODO: should make engraver that collects all the stanzas on a higher
46 level, and then groups them to the side. Stanza numbers should be
47 all aligned.
50 Stanza_number_engraver::Stanza_number_engraver ()
52 text_ = 0;
53 last_stanza_ = SCM_EOL;
56 void
57 Stanza_number_engraver::process_music ()
59 SCM stanza = get_property ("stanza");
61 if (Text_interface::is_markup (stanza)
62 && stanza != last_stanza_)
64 last_stanza_ = stanza;
66 text_ = make_item ("StanzaNumber", SCM_EOL);
67 text_->set_property ("text", stanza);
71 void
72 Stanza_number_engraver::acknowledge_lyric_syllable (Grob_info inf)
74 if (text_)
75 Side_position_interface::add_support (text_, inf.grob ());
78 void
79 Stanza_number_engraver::stop_translation_timestep ()
81 text_ = 0;
84 #include "translator.icc"
86 ADD_ACKNOWLEDGER (Stanza_number_engraver, lyric_syllable);
87 ADD_TRANSLATOR (Stanza_number_engraver,
88 /* doc */
89 "Engrave stanza numbers.",
91 /* create */
92 "StanzaNumber ",
94 /* read */
95 "stanza ",
97 /* write */