2 instrument-name-engraver.cc -- implement Instrument_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "pointer-group-interface.hh"
11 #include "side-position-interface.hh"
12 #include "axis-group-interface.hh"
13 #include "align-interface.hh"
14 #include "text-interface.hh"
17 #include "translator.icc"
19 class Instrument_name_engraver
: public Engraver
22 TRANSLATOR_DECLARATIONS (Instrument_name_engraver
);
25 Spanner
*text_spanner_
;
30 vector
<Grob
*> axis_groups_
;
32 virtual void finalize ();
33 DECLARE_ACKNOWLEDGER (axis_group
);
34 void process_music ();
35 void start_spanner ();
36 void consider_start_spanner ();
40 Instrument_name_engraver::Instrument_name_engraver ()
45 short_text_
= SCM_EOL
;
49 Instrument_name_engraver::process_music ()
51 consider_start_spanner ();
55 Instrument_name_engraver::consider_start_spanner ()
57 SCM long_text
= get_property ("instrumentName");
58 SCM short_text
= get_property ("shortInstrumentName");
60 if (!(Text_interface::is_markup (long_text
)
61 || Text_interface::is_markup (short_text
)))
63 long_text
= get_property ("vocalName");
64 short_text
= get_property ("shortVocalName");
67 if ((Text_interface::is_markup (long_text
)
68 || Text_interface::is_markup (short_text
))
70 || short_text_
!= short_text
71 || long_text_
!= long_text
))
77 short_text_
= short_text
;
78 long_text_
= long_text
;
85 Instrument_name_engraver::start_spanner ()
87 text_spanner_
= make_spanner ("InstrumentName", SCM_EOL
);
89 Grob
*col
= unsmob_grob (get_property ("currentCommandColumn"));
90 text_spanner_
->set_bound (LEFT
, col
);
91 text_spanner_
->set_property ("text", short_text_
);
92 text_spanner_
->set_property ("long-text", long_text_
);
95 UGH, should handle this in Score_engraver.
97 Grob
*system
= unsmob_grob (get_property ("rootSystem"));
99 Axis_group_interface::add_element (system
, text_spanner_
);
101 text_spanner_
->programming_error ("cannot find root system");
106 Instrument_name_engraver::acknowledge_axis_group (Grob_info info
)
108 if (dynamic_cast<Spanner
*> (info
.grob ())
109 && Axis_group_interface::has_axis (info
.grob (), Y_AXIS
)
113 && !info
.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
114 && !info
.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))
115 && (!Align_interface::has_interface (info
.grob ())))
117 axis_groups_
.push_back (info
.grob ());
122 Instrument_name_engraver::finalize ()
131 Instrument_name_engraver::stop_spanner ()
133 for (vsize i
= 0; i
< axis_groups_
.size (); i
++)
134 Pointer_group_interface::add_grob (text_spanner_
, ly_symbol2scm ("elements"), axis_groups_
[i
]);
136 text_spanner_
->set_bound (RIGHT
,
137 unsmob_grob (get_property ("currentCommandColumn")));
139 Pointer_group_interface::set_ordered (text_spanner_
, ly_symbol2scm ("elements"), false);
144 #include "translator.icc"
146 ADD_ACKNOWLEDGER (Instrument_name_engraver
, axis_group
);
148 ADD_TRANSLATOR (Instrument_name_engraver
,
150 "Create a system start text for instrument or vocal names.",
156 "currentCommandColumn "
157 "shortInstrumentName "