]> git.donarmstrong.com Git - lilypond.git/blob - lily/stanza-number-engraver.cc
* scm/engraver-documentation-lib.scm
[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--2002 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 "bar-line.hh"
14
15 class Stanza_number_engraver : public Engraver
16 {
17   Item *text_;
18   bool bar_b_;
19
20   void create_text (SCM s);
21 public:
22   TRANSLATOR_DECLARATIONS(Stanza_number_engraver);
23
24   virtual void process_music ();
25   virtual void stop_translation_timestep ();
26 };
27
28
29
30 Stanza_number_engraver::Stanza_number_engraver ()
31 {
32   text_ = 0;
33   bar_b_ = false;
34 }
35
36 void
37 Stanza_number_engraver::process_music ()
38 {
39   if (gh_string_p (get_property ("whichBar")))
40     {
41       SCM s = get_property ("stanza");
42       
43       if (now_mom () > Moment (0))
44         s = get_property ("stz");
45
46
47       // TODO
48       if (gh_string_p (s) || gh_pair_p (s))
49
50         /*
51           if (i.grob_->internal_has_interface (symbol ("lyric-syllable-interface")))
52
53           Tried catching lyric items to generate stanza numbers, but it
54           spoils lyric spacing.
55
56           Works, but requires bar_engraver in LyricsVoice context apart
57           from at beginning.  Is there any score element we can catch
58           that will do the trick?
59
60           What happens if we try anything at all EXCEPT a lyric? Is
61           there anything else?  Not sure what it's catching, but it
62           still mucks up lyrics.
63
64         */
65
66         create_text (s);
67     }
68 }
69
70 void
71 Stanza_number_engraver::stop_translation_timestep ()
72 {
73   if (text_)
74     {
75       typeset_grob (text_);
76       text_ = 0;
77     }
78 }
79
80 void
81 Stanza_number_engraver::create_text (SCM txt)
82 {
83   if (!text_)
84     {
85       text_ = new Item (get_property ("StanzaNumber"));
86       text_->set_grob_property ("text", txt);
87       announce_grob (text_, SCM_EOL);
88     }
89 }
90
91
92
93
94 ENTER_DESCRIPTION(Stanza_number_engraver,
95 /* descr */       "",
96 /* creats*/       "StanzaNumber",
97 /* accepts */     "",
98 /* acks  */      "",
99 /* reads */       "stz stanza",
100 /* write */       "");