]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-engraver.cc
*** empty log message ***
[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--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>, Glen Prideaux <glenprideaux@iname.com>
7
8 */
9
10 #include "engraver.hh"
11 #include "side-position-interface.hh"
12
13 class Stanza_number_engraver : public Engraver
14 {
15   Item *text_;
16
17   /*
18     This is naughty, since last_stanza_ may be GCd from under us.  But
19     since we don't look at the contents, we are/should be (knock on
20     wood) OK.
21    */
22   SCM last_stanza_;
23 public:
24   TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
25   virtual void process_music ();
26   virtual void stop_translation_timestep ();
27   virtual void acknowledge_grob (Grob_info);
28 };
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 }
41
42 void
43 Stanza_number_engraver::process_music ()
44 {
45   SCM stanza = get_property ("stanza");
46   
47   if (scm_is_string (stanza) && stanza != last_stanza_)
48     {
49       last_stanza_ = stanza;
50       
51       text_ = make_item ("StanzaNumber", SCM_EOL);
52       text_->set_property ("text", stanza);
53       
54     }
55 }
56
57
58 void
59 Stanza_number_engraver::acknowledge_grob (Grob_info inf)
60 {
61   if (text_
62       && inf.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
63     {
64       Side_position_interface::add_support (text_, inf.grob_);
65     }
66 }
67
68 void
69 Stanza_number_engraver::stop_translation_timestep ()
70 {
71   text_ = 0;
72 }
73
74
75 ADD_TRANSLATOR (Stanza_number_engraver,
76 /* descr */       "",
77 /* creats*/       "StanzaNumber",
78 /* accepts */     "",
79 /* acks  */      "lyric-syllable-interface",
80 /* reads */       "stanza",
81 /* write */       "");