Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / instrument-switch-engraver.cc
blob8ae322fae0e7d1c24587b452cb5606ff02839b07
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
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.
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.
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/>.
21 #include "engraver.hh"
22 #include "item.hh"
23 #include "text-interface.hh"
25 #include "translator.icc"
28 class Instrument_switch_engraver : public Engraver
31 TRANSLATOR_DECLARATIONS (Instrument_switch_engraver);
32 protected:
33 Grob *text_;
34 SCM cue_name_;
36 void stop_translation_time_step ();
37 void process_music ();
39 virtual void derived_mark () const;
42 void
43 Instrument_switch_engraver::derived_mark () const
45 scm_gc_mark (cue_name_);
48 Instrument_switch_engraver::Instrument_switch_engraver ()
50 cue_name_ = SCM_EOL;
51 text_ = 0;
55 TODO: should use an event.
57 void
58 Instrument_switch_engraver::process_music ()
60 SCM cue_text = get_property ("instrumentCueName");
62 if (!scm_is_eq (cue_name_, cue_text))
64 if (Text_interface::is_markup (cue_text))
66 text_ = make_item ("InstrumentSwitch", SCM_EOL);
67 text_->set_property ("text", cue_text);
69 cue_name_ = cue_text;
73 void
74 Instrument_switch_engraver::stop_translation_time_step ()
76 text_ = 0;
79 ADD_TRANSLATOR (Instrument_switch_engraver,
80 /* doc */
81 "Create a cue text for taking instrument.",
83 /* create */
84 "InstrumentSwitch ",
86 /* read */
87 "instrumentCueName ",
89 /* write */