2 new-staff-margin-engraver.cc -- implement Instrument_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
13 #include "system-start-delimiter.hh"
14 #include "side-position-interface.hh"
15 #include "align-interface.hh"
16 #include "axis-group-interface.hh"
17 #include "translator-group.hh"
19 class Instrument_name_engraver : public Engraver
24 void create_text (SCM s);
26 VIRTUAL_COPY_CONS (Translator);
27 Instrument_name_engraver ();
28 virtual void initialize ();
29 virtual void acknowledge_grob (Grob_info);
30 virtual void stop_translation_timestep ();
33 ADD_THIS_TRANSLATOR (Instrument_name_engraver);
35 Instrument_name_engraver::Instrument_name_engraver ()
43 Instrument_name_engraver::initialize ()
45 daddy_trans_l_->set_property ("instrumentSupport", SCM_EOL);
49 Instrument_name_engraver::stop_translation_timestep ()
53 text_->set_grob_property ("side-support-elements",
54 get_property ("instrumentSupport"));
61 Instrument_name_engraver::create_text (SCM txt)
65 text_ = new Item (get_property ("InstrumentName"));
67 if (text_->get_grob_property ("text") != txt)
68 text_->set_grob_property ("text", txt);
71 text_->set_parent (delim_, Y_AXIS);
73 announce_grob (text_,0);
78 Instrument_name_engraver::acknowledge_grob (Grob_info i)
80 if (Bar::has_interface (i.elem_l_))
82 SCM s = get_property ("instrument");
84 if (now_mom () > Moment (0))
85 s = get_property ("instr");
88 FIXME: use markup_p () to check type.
90 if (gh_string_p (s) || gh_pair_p (s))
95 if (dynamic_cast<Spanner*> (i.elem_l_)
96 && i.elem_l_->has_interface (ly_symbol2scm ("dynamic-interface")))
99 if (dynamic_cast<Spanner*> (i.elem_l_)
100 && ((Axis_group_interface::has_interface (i.elem_l_)
101 && Axis_group_interface::axis_b (i.elem_l_, Y_AXIS))
102 || (Align_interface::has_interface (i.elem_l_)
103 && Align_interface::axis (i.elem_l_) == Y_AXIS)))
105 SCM nl = gh_cons (i.elem_l_->self_scm (),
106 get_property ("instrumentSupport"));
108 daddy_trans_l_->set_property ("instrumentSupport", nl);