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