]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-switch-engraver.cc
(Two-pass vertical spacing): add documentation for two-pass spacing
[lilypond.git] / lily / instrument-switch-engraver.cc
1 /*
2   instrument-switch-engraver.cc -- implement
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
7
8 */
9
10 #include "engraver.hh"
11 #include "item.hh"
12 #include "translator.icc"
13
14
15 class Instrument_switch_engraver : public Engraver
16 {
17
18   TRANSLATOR_DECLARATIONS(Instrument_switch_engraver);
19 protected:
20   Grob *text_;
21   SCM cue_name_;
22
23   void stop_translation_time_step ();
24   void process_music ();
25 };
26
27
28 Instrument_switch_engraver::Instrument_switch_engraver ()
29 {
30   cue_name_ = SCM_EOL;
31   text_ = 0;
32 }
33
34 void
35 Instrument_switch_engraver::process_music ()
36 {
37   SCM cue_text = get_property ("instrumentCueName");
38   
39   if (!scm_is_eq (cue_name_, cue_text))
40     {
41       text_ = make_item ("InstrumentSwitch", SCM_EOL);
42       text_->set_property ("text", cue_text);
43       cue_name_ = cue_text;
44     }
45 }
46
47 void
48 Instrument_switch_engraver::stop_translation_time_step ()
49 {
50   text_ = 0;
51 }
52
53 ADD_TRANSLATOR(Instrument_switch_engraver,
54                "Create a cue text for taking instrument.",
55                         
56                "InstrumentSwitch ",
57
58                "",
59
60                "instrumentCueName",
61                         
62                "");