2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "pointer-group-interface.hh"
22 #include "side-position-interface.hh"
23 #include "axis-group-interface.hh"
24 #include "align-interface.hh"
25 #include "text-interface.hh"
28 #include "translator.icc"
30 class Instrument_name_engraver : public Engraver
33 TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
36 Spanner *text_spanner_;
41 vector<Grob *> axis_groups_;
43 virtual void finalize ();
44 DECLARE_ACKNOWLEDGER (axis_group);
45 void process_music ();
46 void start_spanner ();
47 void consider_start_spanner ();
51 Instrument_name_engraver::Instrument_name_engraver ()
56 short_text_ = SCM_EOL;
60 Instrument_name_engraver::process_music ()
62 consider_start_spanner ();
66 Instrument_name_engraver::consider_start_spanner ()
68 SCM long_text = get_property ("instrumentName");
69 SCM short_text = get_property ("shortInstrumentName");
71 if (!(Text_interface::is_markup (long_text)
72 || Text_interface::is_markup (short_text)))
74 long_text = get_property ("vocalName");
75 short_text = get_property ("shortVocalName");
78 if ((Text_interface::is_markup (long_text)
79 || Text_interface::is_markup (short_text))
81 || short_text_ != short_text
82 || long_text_ != long_text))
87 short_text_ = short_text;
88 long_text_ = long_text;
95 Instrument_name_engraver::start_spanner ()
97 text_spanner_ = make_spanner ("InstrumentName", SCM_EOL);
99 Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
100 text_spanner_->set_bound (LEFT, col);
101 text_spanner_->set_property ("text", short_text_);
102 text_spanner_->set_property ("long-text", long_text_);
105 UGH, should handle this in Score_engraver.
107 Grob *system = unsmob_grob (get_property ("rootSystem"));
109 Axis_group_interface::add_element (system, text_spanner_);
111 text_spanner_->programming_error ("cannot find root system");
115 Instrument_name_engraver::acknowledge_axis_group (Grob_info info)
117 if (dynamic_cast<Spanner *> (info.grob ())
118 && Axis_group_interface::has_axis (info.grob (), Y_AXIS)
122 && !info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
123 && !info.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))
124 && !info.grob ()->internal_has_interface (ly_symbol2scm ("volta-interface"))
125 && (!Align_interface::has_interface (info.grob ())))
127 axis_groups_.push_back (info.grob ());
132 Instrument_name_engraver::finalize ()
139 Instrument_name_engraver::stop_spanner ()
141 for (vsize i = 0; i < axis_groups_.size (); i++)
142 Pointer_group_interface::add_grob (text_spanner_,
143 ly_symbol2scm ("elements"),
146 text_spanner_->set_bound (RIGHT,
147 unsmob_grob (get_property ("currentCommandColumn")));
149 Pointer_group_interface::set_ordered (text_spanner_,
150 ly_symbol2scm ("elements"),
157 ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group);
159 ADD_TRANSLATOR (Instrument_name_engraver,
161 "Create a system start text for instrument or vocal names.",
167 "currentCommandColumn "
169 "shortInstrumentName "