2 instrument-name-engraver.cc -- implement Instrument_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
11 #include "bar-line.hh"
12 #include "system-start-delimiter.hh"
13 #include "side-position-interface.hh"
14 #include "align-interface.hh"
15 #include "axis-group-interface.hh"
17 #include "text-item.hh"
19 class Instrument_name_engraver : public Engraver
23 TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
28 virtual void create_text ();
29 virtual void initialize ();
30 virtual void acknowledge_grob (Grob_info);
31 virtual void stop_translation_timestep ();
32 virtual void process_music ();
35 Instrument_name_engraver::Instrument_name_engraver ()
42 Instrument_name_engraver::initialize ()
44 context ()->set_property ("instrumentSupport", SCM_EOL);
48 Instrument_name_engraver::stop_translation_timestep ()
52 text_->set_property ("side-support-elements",
53 get_property ("instrumentSupport"));
60 Instrument_name_engraver::create_text ()
65 SCM txt = get_property ("instrument");
67 if (now_mom () > Moment (0))
68 txt = get_property ("instr");
76 text_ = make_item ("InstrumentName", SCM_EOL);
78 if (text_->get_property ("text") != txt)
79 text_->set_property ("text", txt);
84 Instrument_name_engraver::acknowledge_grob (Grob_info i)
86 if (Bar_line::has_interface (i.grob_))
91 if (dynamic_cast<Spanner*> (i.grob_)
92 && i.grob_->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
96 Hang the instrument names on the staves, but not on the alignment
97 groups enclosing that staff. The alignment has no real location,
98 but is only a vehicle for the placement routine it contains, and
99 therefore the location of its refpoint won't be very useful.
101 We could also just use stavesFound, but lets keep this working
102 without staffs as well.
104 if (dynamic_cast<Spanner*> (i.grob_)
105 && ((Axis_group_interface::has_interface (i.grob_)
106 && Axis_group_interface::has_axis (i.grob_, Y_AXIS)))
107 && !Align_interface::has_interface (i.grob_))
109 SCM nl = scm_cons (i.grob_->self_scm (),
110 get_property ("instrumentSupport"));
112 context ()->set_property ("instrumentSupport", nl);
117 Instrument_name_engraver::process_music ()
120 Also create text if barlines in other groups. This allows
121 a name to be attached to lyrics or chords.
123 if (scm_is_string (get_property ("whichBar")))
127 ADD_TRANSLATOR (Instrument_name_engraver,
128 /* descr */ " Prints the name of the instrument (specified by "
129 " @code{Staff.instrument} and @code{Staff.instr}) "
130 "at the left of the staff. ",
131 /* creats*/ "InstrumentName",
133 /* acks */ "bar-line-interface axis-group-interface",
134 /* reads */ "instrument instr",
137 /****************************************************************/
140 class Vocal_name_engraver : public Instrument_name_engraver
143 TRANSLATOR_DECLARATIONS (Vocal_name_engraver);
144 virtual void create_text ();
148 Vocal_name_engraver::Vocal_name_engraver ()
154 Vocal_name_engraver::create_text ()
159 SCM txt = get_property ("vocalName");
161 if (now_mom () > Moment (0))
162 txt = get_property ("vocNam");
170 text_ = make_item ("VocalName", SCM_EOL);
172 if (text_->get_property ("text") != txt)
173 text_->set_property ("text", txt);
179 ADD_TRANSLATOR (Vocal_name_engraver,
180 /* descr */ " Prints the name of the a lyric voice (specified by "
181 " @code{Staff.vocalName} and @code{Staff.vocNam}) "
182 "at the left of the staff. ",
183 /* creats*/ "VocalName",
185 /* acks */ "bar-line-interface axis-group-interface",
186 /* reads */ "vocNam vocalName",