2 instrument-name-engraver.cc -- implement Instrument_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
11 #include "pointer-group-interface.hh"
12 #include "side-position-interface.hh"
13 #include "axis-group-interface.hh"
14 #include "align-interface.hh"
15 #include "text-interface.hh"
18 #include "translator.icc"
20 class Instrument_name_engraver : public Engraver
23 TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
26 Spanner *text_spanner_;
28 virtual void finalize ();
29 DECLARE_ACKNOWLEDGER (axis_group);
30 void process_music ();
33 Instrument_name_engraver::Instrument_name_engraver ()
39 Instrument_name_engraver::process_music ()
43 SCM long_text = get_property ("instrument");
44 SCM short_text = get_property ("instr");
46 if (!(Text_interface::is_markup (long_text)
47 || Text_interface::is_markup (short_text)))
49 long_text = get_property ("vocalName");
50 short_text = get_property ("vocNam");
53 if (Text_interface::is_markup (long_text)
54 || Text_interface::is_markup (short_text))
56 text_spanner_ = make_spanner ("InstrumentName", SCM_EOL);
58 Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
59 text_spanner_->set_bound (LEFT, col);
60 text_spanner_->set_property ("text", short_text);
61 text_spanner_->set_property ("long-text", long_text);
67 Instrument_name_engraver::acknowledge_axis_group (Grob_info info)
70 && dynamic_cast<Spanner *> (info.grob ())
71 && Axis_group_interface::has_axis (info.grob (), Y_AXIS)
72 && (!Align_interface::has_interface (info.grob ())))
74 Grob *staff = info.grob();
75 Pointer_group_interface::add_grob (text_spanner_, ly_symbol2scm ("elements"), staff);
76 Side_position_interface::add_support (text_spanner_, staff);
81 Instrument_name_engraver::finalize ()
85 text_spanner_->set_bound (RIGHT,
86 unsmob_grob (get_property ("currentCommandColumn")));
88 Pointer_group_interface::set_ordered (text_spanner_, ly_symbol2scm ("elements"), false);
90 System *system = get_root_system (text_spanner_);
93 UGH, should handle this in Score_engraver.
96 Axis_group_interface::add_element (system, text_spanner_);
98 text_spanner_->programming_error ("can't find root system");
102 #include "translator.icc"
104 ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group);
106 ADD_TRANSLATOR (Instrument_name_engraver,
109 "Creates a system start text for instrument or vocal names.",
118 "vocNam vocalName instrument instr "
119 "currentCommandColumn",