lilypond-1.3.121
[lilypond.git] / lily / instrument-name-engraver.cc
blobad7051f04c9422051fa7b3e6686b1e7aa12109c3
1 /*
2 new-staff-margin-engraver.cc -- implement Instrument_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "item.hh"
12 #include "bar.hh"
13 #include "system-start-delimiter.hh"
14 #include "side-position-interface.hh"
15 #include "align-interface.hh"
17 class Instrument_name_engraver : public Engraver
19 Item *text_;
20 Grob * delim_ ;
22 void create_text (SCM s);
23 public:
24 VIRTUAL_COPY_CONS(Translator);
25 Instrument_name_engraver ();
27 virtual void acknowledge_grob (Grob_info);
28 virtual void stop_translation_timestep ();
31 ADD_THIS_TRANSLATOR(Instrument_name_engraver);
33 Instrument_name_engraver::Instrument_name_engraver ()
35 text_ = 0;
36 delim_ =0;
40 void
41 Instrument_name_engraver::stop_translation_timestep ()
43 if (text_)
45 typeset_grob (text_);
46 text_ = 0;
50 void
51 Instrument_name_engraver::create_text (SCM txt)
53 if(!text_)
55 text_ = new Item (get_property ("InstrumentName"));
57 if (text_->get_grob_property ("text") != txt)
58 text_->set_grob_property ("text", txt);
60 if (delim_)
61 text_->set_parent (delim_, Y_AXIS);
63 announce_grob (text_,0);
67 void
68 Instrument_name_engraver::acknowledge_grob (Grob_info i)
70 if (Bar::has_interface (i.elem_l_))
72 SCM s = get_property ("instrument");
74 if (now_mom () > Moment (0))
75 s = get_property ("instr");
78 FIXME: use markup_p () to check type.
80 if (gh_string_p (s))
81 create_text (s);
85 if (Align_interface::has_interface (i.elem_l_)
86 && Align_interface::axis (i.elem_l_) == Y_AXIS
87 //System_start_delimiter::has_interface (i.elem_l_)
88 && i.origin_trans_l_->daddy_trans_l_ == daddy_trans_l_)
90 delim_ = i.elem_l_;