]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-engraver.cc
(process_music): use is_markup()
[lilypond.git] / lily / stanza-number-engraver.cc
1 /*
2   lyric-number-engraver.cc -- implement Stanza_number_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>, Glen Prideaux <glenprideaux@iname.com>
7 */
8
9 #include "engraver.hh"
10 #include "side-position-interface.hh"
11
12 class Stanza_number_engraver : public Engraver
13 {
14   Item *text_;
15
16   SCM last_stanza_;
17 public:
18   TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
19   void process_music ();
20   virtual void derived_mark () const;
21   void stop_translation_timestep ();
22   DECLARE_ACKNOWLEDGER (lyric_syllable);
23 };
24
25 void
26 Stanza_number_engraver::derived_mark () const
27 {
28   scm_gc_mark (last_stanza_);
29 }
30
31 /*
32   TODO: should make engraver that collects all the stanzas on a higher
33   level, and then groups them to the side. Stanza numbers should be
34   all aligned.
35 */
36
37 Stanza_number_engraver::Stanza_number_engraver ()
38 {
39   text_ = 0;
40   last_stanza_ = SCM_EOL;
41 }
42
43 void
44 Stanza_number_engraver::process_music ()
45 {
46   SCM stanza = get_property ("stanza");
47
48   if (Text_interface::is_markup (stanza)
49       && stanza != last_stanza_)
50     {
51       last_stanza_ = stanza;
52
53       text_ = make_item ("StanzaNumber", SCM_EOL);
54       text_->set_property ("text", stanza);
55     }
56 }
57
58 void
59 Stanza_number_engraver::acknowledge_lyric_syllable (Grob_info inf)
60 {
61   if (text_)
62     Side_position_interface::add_support (text_, inf.grob ());
63 }
64
65 void
66 Stanza_number_engraver::stop_translation_timestep ()
67 {
68   text_ = 0;
69 }
70
71 #include "translator.icc"
72
73 ADD_ACKNOWLEDGER (Stanza_number_engraver, lyric_syllable);
74 ADD_TRANSLATOR (Stanza_number_engraver,
75                 /* doc */ "",
76                 /* create */ "StanzaNumber",
77                 /* accept */ "",
78                 /* read */ "stanza",
79                 /* write */ "");