]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-switch-engraver.cc
Allow unsetting Voice.instrumentCueName
[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--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
7
8 */
9
10 #include "engraver.hh"
11 #include "item.hh"
12 #include "text-interface.hh"
13 #include "translator.icc"
14
15
16 class Instrument_switch_engraver : public Engraver
17 {
18
19   TRANSLATOR_DECLARATIONS (Instrument_switch_engraver);
20 protected:
21   Grob *text_;
22   SCM cue_name_;
23
24   void stop_translation_time_step ();
25   void process_music ();
26 };
27
28
29 Instrument_switch_engraver::Instrument_switch_engraver ()
30 {
31   cue_name_ = SCM_EOL;
32   text_ = 0;
33 }
34
35 /*
36   TODO: should use an event.
37  */
38 void
39 Instrument_switch_engraver::process_music ()
40 {
41   SCM cue_text = get_property ("instrumentCueName");
42   
43   if (!scm_is_eq (cue_name_, cue_text))
44     {
45       if (Text_interface::is_markup (cue_text))
46 //       if (!scm_is_null (cue_text))
47         {
48           text_ = make_item ("InstrumentSwitch", SCM_EOL);
49           text_->set_property ("text", cue_text);
50         }
51       cue_name_ = cue_text;
52     }
53 }
54
55 void
56 Instrument_switch_engraver::stop_translation_time_step ()
57 {
58   text_ = 0;
59 }
60
61 ADD_TRANSLATOR (Instrument_switch_engraver,
62                 /* doc */
63                 "Create a cue text for taking instrument.",
64                         
65                 /* create */
66                 "InstrumentSwitch ",
67
68                 /* read */
69                 "instrumentCueName ",
70                         
71                 /* write */
72                 ""
73                 );