]> git.donarmstrong.com Git - lilypond.git/blob - lily/instrument-name-engraver.cc
the great dash-replace.
[lilypond.git] / lily / instrument-name-engraver.cc
1 /*
2   instrument-name-engraver.cc -- implement Instrument_name_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "engraver.hh"
10 #include "spanner.hh"
11 #include "pointer-group-interface.hh"
12 #include "side-position-interface.hh"
13 #include "axis-group-interface.hh"
14 #include "align-interface.hh"
15
16 #include "translator.icc"
17
18 class Instrument_name_engraver : public Engraver
19 {
20 public:
21   TRANSLATOR_DECLARATIONS (Instrument_name_engraver);
22
23 protected:
24   Spanner *text_spanner_;
25
26   virtual void finalize ();
27   DECLARE_ACKNOWLEDGER (axis_group);
28   void process_music ();
29 };
30
31 Instrument_name_engraver::Instrument_name_engraver ()
32 {
33   text_spanner_ = 0;
34 }
35
36 void
37 Instrument_name_engraver::process_music ()
38 {
39   if (!text_spanner_)
40     {
41       SCM long_text = get_property ("instrument");
42       SCM short_text = get_property ("instr");
43
44       if (! (scm_is_string (long_text)
45              || scm_is_string (short_text)))
46         {
47           long_text = get_property ("vocalName");
48           short_text = get_property ("vocNam");
49         }
50   
51       if (scm_is_string (long_text)
52           || scm_is_string (short_text))
53         {
54           text_spanner_ = make_spanner ("InstrumentName", SCM_EOL);
55           text_spanner_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
56           text_spanner_->set_property ("text", short_text);
57           text_spanner_->set_property ("long-text", long_text);
58         }
59     }
60 }
61
62 void
63 Instrument_name_engraver::acknowledge_axis_group (Grob_info info)
64 {
65   if (text_spanner_ 
66       && dynamic_cast<Spanner *> (info.grob ())
67       && Axis_group_interface::has_axis (info.grob (), Y_AXIS)
68       && (!Align_interface::has_interface (info.grob ())))
69     {
70       Grob *staff = info.grob();
71       Pointer_group_interface::add_grob (text_spanner_, ly_symbol2scm ("elements"), staff);
72       Side_position_interface::add_support (text_spanner_, staff);
73     }
74 }
75
76 void
77 Instrument_name_engraver::finalize ()
78 {
79   if (text_spanner_)
80     {
81       text_spanner_->set_bound (RIGHT,
82                                 unsmob_grob (get_property ("currentCommandColumn")));
83     }
84 }
85
86 #include "translator.icc"
87
88 ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group);
89
90 ADD_TRANSLATOR (Instrument_name_engraver,
91
92                 /* doc */
93                 "Creates a system start text for instrument or vocal names.",
94                 
95                 /* create */
96                 "InstrumentName ",
97                 
98                 /* accept */ "",
99                 
100                 /* read */
101                 "vocNam vocalName instrument instr "
102                 "currentCommandColumn",
103
104                 /* write */ "");