]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-engraver.cc
release: 1.3.146
[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--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>, Glen Prideaux <glenprideaux@iname.com>
7   
8   Similar to (and derived from) Instrument_name_engraver.
9  */
10
11 #include "engraver.hh"
12 #include "item.hh"
13 //#include "system-start-delimiter.hh"
14 //#include "side-position-interface.hh"
15 //#include "staff-symbol-referencer.hh"
16 #include "bar.hh"
17
18 class Stanza_number_engraver : public Engraver
19 {
20   Item *text_;
21   bool bar_b_;;
22
23   void create_text (SCM s);
24 public:
25   VIRTUAL_COPY_CONS (Translator);
26   Stanza_number_engraver ();
27
28   virtual void acknowledge_grob (Grob_info);
29   virtual void stop_translation_timestep ();
30 };
31
32 ADD_THIS_TRANSLATOR (Stanza_number_engraver);
33
34 Stanza_number_engraver::Stanza_number_engraver ()
35 {
36   text_ = 0;
37   bar_b_ = false;
38 }
39
40 void
41 Stanza_number_engraver::acknowledge_grob (Grob_info i)
42 {
43   if (gh_string_p (get_property ("whichBar")))
44     {
45       SCM s = get_property ("stanza");
46       
47       if (now_mom () > Moment (0))
48         s = get_property ("stz");
49   
50       if (gh_string_p (s))
51
52         /*
53           if (i.elem_l_->has_interface (symbol ("lyric-syllable-interface")))
54
55           Tried catching lyric items to generate stanza numbers, but it
56           spoils lyric spacing.
57
58           Works, but requires bar_engraver in LyricsVoice context apart
59           from at beginning.  Is there any score element we can catch
60           that will do the trick?
61
62           What happens if we try anything at all EXCEPT a lyric? Is
63           there anything else?  Not sure what it's catching, but it
64           still mucks up lyrics.
65
66         */
67
68         create_text (s);
69     }
70 }
71
72 void
73 Stanza_number_engraver::stop_translation_timestep ()
74 {
75   if (text_)
76     {
77       typeset_grob (text_);
78       text_ = 0;
79     }
80 }
81
82 void
83 Stanza_number_engraver::create_text (SCM txt)
84 {
85   if (!text_)
86     {
87       text_ = new Item (get_property ("StanzaNumber"));
88       text_->set_grob_property ("text", txt);
89       announce_grob (text_,0);
90     }
91 }
92
93
94
95