]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-switch-engraver.cc
Web-ja: update introduction
[lilypond.git] / lily / instrument-switch-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2006--2015 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
25 #include "translator.icc"
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   virtual void derived_mark () const;
39 };
40
41 void
42 Instrument_switch_engraver::derived_mark () const
43 {
44   scm_gc_mark (cue_name_);
45 }
46
47 Instrument_switch_engraver::Instrument_switch_engraver (Context *c)
48   : Engraver (c)
49 {
50   cue_name_ = SCM_EOL;
51   text_ = 0;
52 }
53
54 /*
55   TODO: should use an event.
56  */
57 void
58 Instrument_switch_engraver::process_music ()
59 {
60   SCM cue_text = get_property ("instrumentCueName");
61
62   if (!scm_is_eq (cue_name_, cue_text))
63     {
64       if (Text_interface::is_markup (cue_text))
65         {
66           text_ = make_item ("InstrumentSwitch", SCM_EOL);
67           text_->set_property ("text", cue_text);
68         }
69       cue_name_ = cue_text;
70     }
71 }
72
73 void
74 Instrument_switch_engraver::stop_translation_time_step ()
75 {
76   text_ = 0;
77 }
78
79 void
80 Instrument_switch_engraver::boot ()
81 {
82
83 }
84
85 ADD_TRANSLATOR (Instrument_switch_engraver,
86                 /* doc */
87                 "Create a cue text for taking instrument.",
88
89                 /* create */
90                 "InstrumentSwitch ",
91
92                 /* read */
93                 "instrumentCueName ",
94
95                 /* write */
96                 ""
97                );