*** empty log message ***
[lilypond.git] / lily / stanza-number-engraver.cc
blob68c09bfa934d3ca537ff0a9053a20703c35e1127
1 /*
2 lyric-number-engraver.cc -- implement Stanza_number_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>, Glen Prideaux <glenprideaux@iname.com>
8 */
10 #include "engraver.hh"
11 #include "item.hh"
12 #include "side-position-interface.hh"
14 class Stanza_number_engraver : public Engraver
16 Item *text_;
19 This is naughty, since last_stanza_ may be GCd from under us. But
20 since we don't look at the contents, we are/should be (knock on
21 wood) OK.
23 SCM last_stanza_;
24 public:
25 TRANSLATOR_DECLARATIONS (Stanza_number_engraver);
26 virtual void process_music ();
27 virtual void stop_translation_timestep ();
28 virtual void acknowledge_grob (Grob_info);
33 TODO: should make engraver that collects all the stanzas on a higher
34 level, and then groups them to the side. Stanza numbers should be
35 all aligned.
38 Stanza_number_engraver::Stanza_number_engraver ()
40 text_ = 0;
43 void
44 Stanza_number_engraver::process_music ()
46 SCM stanza = get_property ("stanza");
48 if (gh_string_p (stanza) && stanza != last_stanza_)
50 last_stanza_ = stanza;
52 text_ = make_item ("StanzaNumber");
53 text_->set_property ("text", stanza);
54 announce_grob (text_, SCM_EOL);
59 void
60 Stanza_number_engraver::acknowledge_grob (Grob_info inf)
62 if (text_
63 && inf.grob_->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
65 Side_position_interface::add_support (text_, inf.grob_);
69 void
70 Stanza_number_engraver::stop_translation_timestep ()
72 if (text_)
74 typeset_grob (text_);
75 text_ = 0;
80 ENTER_DESCRIPTION (Stanza_number_engraver,
81 /* descr */ "",
82 /* creats*/ "StanzaNumber",
83 /* accepts */ "",
84 /* acks */ "lyric-syllable-interface",
85 /* reads */ "stanza",
86 /* write */ "");