]> 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 #include "text-interface.hh"
12
13 class Stanza_number_engraver : public Engraver
14 {
15   Item *text_;
16
17   SCM last_stanza_;
18 public:
19   TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
20   void process_music ();
21   virtual void derived_mark () const;
22   void stop_translation_timestep ();
23   DECLARE_ACKNOWLEDGER (lyric_syllable);
24 };
25
26 void
27 Stanza_number_engraver::derived_mark () const
28 {
29   scm_gc_mark (last_stanza_);
30 }
31
32 /*
33   TODO: should make engraver that collects all the stanzas on a higher
34   level, and then groups them to the side. Stanza numbers should be
35   all aligned.
36 */
37
38 Stanza_number_engraver::Stanza_number_engraver ()
39 {
40   text_ = 0;
41   last_stanza_ = SCM_EOL;
42 }
43
44 void
45 Stanza_number_engraver::process_music ()
46 {
47   SCM stanza = get_property ("stanza");
48
49   if (Text_interface::is_markup (stanza)
50       && stanza != last_stanza_)
51     {
52       last_stanza_ = stanza;
53
54       text_ = make_item ("StanzaNumber", SCM_EOL);
55       text_->set_property ("text", stanza);
56     }
57 }
58
59 void
60 Stanza_number_engraver::acknowledge_lyric_syllable (Grob_info inf)
61 {
62   if (text_)
63     Side_position_interface::add_support (text_, inf.grob ());
64 }
65
66 void
67 Stanza_number_engraver::stop_translation_timestep ()
68 {
69   text_ = 0;
70 }
71
72 #include "translator.icc"
73
74 ADD_ACKNOWLEDGER (Stanza_number_engraver, lyric_syllable);
75 ADD_TRANSLATOR (Stanza_number_engraver,
76                 /* doc */ "",
77                 /* create */ "StanzaNumber",
78                 /* accept */ "",
79                 /* read */ "stanza",
80                 /* write */ "");