]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-engraver.cc
release: 1.5.5
[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
51       // TODO
52       if (gh_string_p (s))
53         
54
55         /*
56           if (i.elem_l_->has_interface (symbol ("lyric-syllable-interface")))
57
58           Tried catching lyric items to generate stanza numbers, but it
59           spoils lyric spacing.
60
61           Works, but requires bar_engraver in LyricsVoice context apart
62           from at beginning.  Is there any score element we can catch
63           that will do the trick?
64
65           What happens if we try anything at all EXCEPT a lyric? Is
66           there anything else?  Not sure what it's catching, but it
67           still mucks up lyrics.
68
69         */
70
71         create_text (s);
72     }
73 }
74
75 void
76 Stanza_number_engraver::stop_translation_timestep ()
77 {
78   if (text_)
79     {
80       typeset_grob (text_);
81       text_ = 0;
82     }
83 }
84
85 void
86 Stanza_number_engraver::create_text (SCM txt)
87 {
88   if (!text_)
89     {
90       text_ = new Item (get_property ("StanzaNumber"));
91       text_->set_grob_property ("text", txt);
92       announce_grob (text_,0);
93     }
94 }
95
96
97
98