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