]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-switch-engraver.cc
91072976771a04263005314e29bdd6ca636aec2c
[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--2007 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 /*
35   TODO: should use an event.
36  */
37 void
38 Instrument_switch_engraver::process_music ()
39 {
40   SCM cue_text = get_property ("instrumentCueName");
41   
42   if (!scm_is_eq (cue_name_, cue_text))
43     {
44       text_ = make_item ("InstrumentSwitch", SCM_EOL);
45       text_->set_property ("text", cue_text);
46       cue_name_ = cue_text;
47     }
48 }
49
50 void
51 Instrument_switch_engraver::stop_translation_time_step ()
52 {
53   text_ = 0;
54 }
55
56 ADD_TRANSLATOR (Instrument_switch_engraver,
57                 /* doc */
58                 "Create a cue text for taking instrument.",
59                         
60                 /* create */
61                 "InstrumentSwitch ",
62
63                 /* read */
64                 "instrumentCueName ",
65                         
66                 /* write */
67                 ""
68                 );