Markup command name changes.
[lilypond.git] / lily / phrasing-slur-engraver.cc
blobb0ef2b2d74ab69a63aca41b1dc3e49692bbdf85e
1 /*
2 phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "engraver.hh"
11 #include "context.hh"
12 #include "directional-element-interface.hh"
13 #include "international.hh"
14 #include "note-column.hh"
15 #include "slur.hh"
16 #include "spanner.hh"
17 #include "stream-event.hh"
18 #include "warn.hh"
20 #include "translator.icc"
23 It is possible that a slur starts and ends on the same note. At
24 least, it is for phrasing slurs: a note can be both beginning and
25 ending of a phrase.
30 NOTE NOTE NOTE
32 This is largely similar to Slur_engraver. Check if fixes apply there too.
34 (on principle, engravers don't use inheritance for code sharing)
37 class Phrasing_slur_engraver : public Engraver
39 Drul_array<Stream_event *> events_;
40 Stream_event *running_slur_start_;
41 vector<Grob*> slurs_;
42 vector<Grob*> end_slurs_;
44 protected:
45 void acknowledge_extra_object (Grob_info);
46 DECLARE_ACKNOWLEDGER (accidental);
47 DECLARE_ACKNOWLEDGER (fingering);
48 DECLARE_ACKNOWLEDGER (note_column);
49 DECLARE_ACKNOWLEDGER (slur);
50 DECLARE_ACKNOWLEDGER (script);
51 DECLARE_ACKNOWLEDGER (text_script);
52 DECLARE_ACKNOWLEDGER (tie);
53 DECLARE_TRANSLATOR_LISTENER (phrasing_slur);
55 void stop_translation_timestep ();
56 virtual void finalize ();
57 void process_music ();
59 public:
60 TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver);
63 Phrasing_slur_engraver::Phrasing_slur_engraver ()
65 events_[START] = events_[STOP] = 0;
68 IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver, phrasing_slur);
69 void
70 Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev)
73 Let's not start more than one slur per moment.
75 Direction d = to_dir (ev->get_property ("span-direction"));
76 if (d == START)
77 ASSIGN_EVENT_ONCE (events_[START], ev);
78 else if (d == STOP && !slurs_.empty ())
79 ASSIGN_EVENT_ONCE (events_[STOP], ev);
82 void
83 Phrasing_slur_engraver::acknowledge_note_column (Grob_info info)
85 Grob *e = info.grob ();
86 for (vsize i = slurs_.size (); i--;)
87 Slur::add_column (slurs_[i], e);
88 for (vsize i = end_slurs_.size (); i--;)
89 Slur::add_column (end_slurs_[i], e);
92 void
93 Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info)
95 Slur::auxiliary_acknowledge_extra_object (info, slurs_, end_slurs_);
98 void
99 Phrasing_slur_engraver::acknowledge_accidental (Grob_info info)
101 acknowledge_extra_object (info);
104 void
105 Phrasing_slur_engraver::acknowledge_fingering (Grob_info info)
107 acknowledge_extra_object (info);
110 void
111 Phrasing_slur_engraver::acknowledge_text_script (Grob_info info)
113 acknowledge_extra_object (info);
116 void
117 Phrasing_slur_engraver::acknowledge_script (Grob_info info)
119 if (!info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
120 acknowledge_extra_object (info);
123 void
124 Phrasing_slur_engraver::acknowledge_tie (Grob_info info)
126 acknowledge_extra_object (info);
129 void
130 Phrasing_slur_engraver::acknowledge_slur (Grob_info info)
132 acknowledge_extra_object (info);
135 void
136 Phrasing_slur_engraver::finalize ()
138 if (slurs_.size ())
139 slurs_[0]->warning (_ ("unterminated phrasing slur"));
142 void
143 Phrasing_slur_engraver::process_music ()
145 if (events_[STOP])
147 end_slurs_ = slurs_;
148 slurs_.clear ();
151 if (events_[START] && slurs_.empty ())
153 Stream_event *ev = events_[START];
155 Grob *slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ());
156 Direction updown = to_dir (ev->get_property ("direction"));
157 if (updown)
158 set_grob_direction (slur, updown);
160 slurs_.push_back (slur);
164 void
165 Phrasing_slur_engraver::stop_translation_timestep ()
167 end_slurs_.clear ();
168 events_[START] = events_[STOP] = 0;
171 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, accidental);
172 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, fingering)
173 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, note_column);
174 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, slur);
175 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, script);
176 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, text_script);
177 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tie);
179 ADD_TRANSLATOR (Phrasing_slur_engraver,
180 /* doc */
181 "Print phrasing slurs. Similar to @ref{Slur_engraver}.",
183 /* create */
184 "PhrasingSlur ",
186 /* read */
189 /* write */