2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2010 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 ();
50 virtual void derived_mark () const;
54 Instrument_name_engraver::derived_mark () const
56 scm_gc_mark (long_text_
);
57 scm_gc_mark (short_text_
);
60 Instrument_name_engraver::Instrument_name_engraver ()
65 short_text_
= SCM_EOL
;
69 Instrument_name_engraver::process_music ()
71 consider_start_spanner ();
75 Instrument_name_engraver::consider_start_spanner ()
77 SCM long_text
= get_property ("instrumentName");
78 SCM short_text
= get_property ("shortInstrumentName");
80 if (!(Text_interface::is_markup (long_text
)
81 || Text_interface::is_markup (short_text
)))
83 long_text
= get_property ("vocalName");
84 short_text
= get_property ("shortVocalName");
87 if ((Text_interface::is_markup (long_text
)
88 || Text_interface::is_markup (short_text
))
90 || short_text_
!= short_text
91 || long_text_
!= long_text
))
96 short_text_
= short_text
;
97 long_text_
= long_text
;
104 Instrument_name_engraver::start_spanner ()
106 text_spanner_
= make_spanner ("InstrumentName", SCM_EOL
);
108 Grob
*col
= unsmob_grob (get_property ("currentCommandColumn"));
109 text_spanner_
->set_bound (LEFT
, col
);
110 text_spanner_
->set_property ("text", short_text_
);
111 text_spanner_
->set_property ("long-text", long_text_
);
114 UGH, should handle this in Score_engraver.
116 Grob
*system
= unsmob_grob (get_property ("rootSystem"));
118 Axis_group_interface::add_element (system
, text_spanner_
);
120 text_spanner_
->programming_error ("cannot find root system");
124 Instrument_name_engraver::acknowledge_axis_group (Grob_info info
)
126 if (dynamic_cast<Spanner
*> (info
.grob ())
127 && Axis_group_interface::has_axis (info
.grob (), Y_AXIS
)
131 && !info
.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
132 && !info
.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))
133 && !info
.grob ()->internal_has_interface (ly_symbol2scm ("volta-interface"))
134 && (!Align_interface::has_interface (info
.grob ())))
136 axis_groups_
.push_back (info
.grob ());
141 Instrument_name_engraver::finalize ()
148 Instrument_name_engraver::stop_spanner ()
150 for (vsize i
= 0; i
< axis_groups_
.size (); i
++)
151 Pointer_group_interface::add_grob (text_spanner_
,
152 ly_symbol2scm ("elements"),
155 text_spanner_
->set_bound (RIGHT
,
156 unsmob_grob (get_property ("currentCommandColumn")));
158 Pointer_group_interface::set_ordered (text_spanner_
,
159 ly_symbol2scm ("elements"),
166 ADD_ACKNOWLEDGER (Instrument_name_engraver
, axis_group
);
168 ADD_TRANSLATOR (Instrument_name_engraver
,
170 "Create a system start text for instrument or vocal names.",
176 "currentCommandColumn "
178 "shortInstrumentName "