]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-switch-engraver.cc
Update source file headers. Fixes using standard GNU package conventions.
[lilypond.git] / lily / instrument-switch-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2006--2009 Han-Wen Nienhuys <hanwen@lilypond.org>
5
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "engraver.hh"
22 #include "item.hh"
23 #include "text-interface.hh"
24 #include "translator.icc"
25
26
27 class Instrument_switch_engraver : public Engraver
28 {
29
30   TRANSLATOR_DECLARATIONS (Instrument_switch_engraver);
31 protected:
32   Grob *text_;
33   SCM cue_name_;
34
35   void stop_translation_time_step ();
36   void process_music ();
37 };
38
39
40 Instrument_switch_engraver::Instrument_switch_engraver ()
41 {
42   cue_name_ = SCM_EOL;
43   text_ = 0;
44 }
45
46 /*
47   TODO: should use an event.
48  */
49 void
50 Instrument_switch_engraver::process_music ()
51 {
52   SCM cue_text = get_property ("instrumentCueName");
53   
54   if (!scm_is_eq (cue_name_, cue_text))
55     {
56       if (Text_interface::is_markup (cue_text))
57         {
58           text_ = make_item ("InstrumentSwitch", SCM_EOL);
59           text_->set_property ("text", cue_text);
60         }
61       cue_name_ = cue_text;
62     }
63 }
64
65 void
66 Instrument_switch_engraver::stop_translation_time_step ()
67 {
68   text_ = 0;
69 }
70
71 ADD_TRANSLATOR (Instrument_switch_engraver,
72                 /* doc */
73                 "Create a cue text for taking instrument.",
74                         
75                 /* create */
76                 "InstrumentSwitch ",
77
78                 /* read */
79                 "instrumentCueName ",
80                         
81                 /* write */
82                 ""
83                 );