Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / phrasing-slur-engraver.cc
blob4cd0c6ee109bc7001ff7b8801e3334967a38b34a
1 /*
2 phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 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_ACKNOWLEDGER (tuplet_number);
54 DECLARE_TRANSLATOR_LISTENER (phrasing_slur);
56 void stop_translation_timestep ();
57 virtual void finalize ();
58 void process_music ();
60 public:
61 TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver);
64 Phrasing_slur_engraver::Phrasing_slur_engraver ()
66 events_[START] = events_[STOP] = 0;
69 IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver, phrasing_slur);
70 void
71 Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev)
74 Let's not start more than one slur per moment.
76 Direction d = to_dir (ev->get_property ("span-direction"));
77 if (d == START)
78 ASSIGN_EVENT_ONCE (events_[START], ev);
79 else if (d == STOP && !slurs_.empty ())
80 ASSIGN_EVENT_ONCE (events_[STOP], ev);
83 void
84 Phrasing_slur_engraver::acknowledge_note_column (Grob_info info)
86 Grob *e = info.grob ();
87 for (vsize i = slurs_.size (); i--;)
88 Slur::add_column (slurs_[i], e);
89 for (vsize i = end_slurs_.size (); i--;)
90 Slur::add_column (end_slurs_[i], e);
93 void
94 Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info)
96 Slur::auxiliary_acknowledge_extra_object (info, slurs_, end_slurs_);
99 void
100 Phrasing_slur_engraver::acknowledge_accidental (Grob_info info)
102 acknowledge_extra_object (info);
105 void
106 Phrasing_slur_engraver::acknowledge_fingering (Grob_info info)
108 acknowledge_extra_object (info);
111 void
112 Phrasing_slur_engraver::acknowledge_text_script (Grob_info info)
114 acknowledge_extra_object (info);
117 void
118 Phrasing_slur_engraver::acknowledge_script (Grob_info info)
120 if (!info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
121 acknowledge_extra_object (info);
124 void
125 Phrasing_slur_engraver::acknowledge_tie (Grob_info info)
127 acknowledge_extra_object (info);
130 void
131 Phrasing_slur_engraver::acknowledge_tuplet_number (Grob_info info)
133 acknowledge_extra_object (info);
136 void
137 Phrasing_slur_engraver::acknowledge_slur (Grob_info info)
139 acknowledge_extra_object (info);
142 void
143 Phrasing_slur_engraver::finalize ()
145 if (slurs_.size ())
146 slurs_[0]->warning (_ ("unterminated phrasing slur"));
149 void
150 Phrasing_slur_engraver::process_music ()
152 if (events_[STOP])
154 end_slurs_ = slurs_;
155 slurs_.clear ();
158 if (events_[START] && slurs_.empty ())
160 Stream_event *ev = events_[START];
162 Grob *slur = make_spanner ("PhrasingSlur", events_[START]->self_scm ());
163 Direction updown = to_dir (ev->get_property ("direction"));
164 if (updown)
165 set_grob_direction (slur, updown);
167 slurs_.push_back (slur);
171 void
172 Phrasing_slur_engraver::stop_translation_timestep ()
174 end_slurs_.clear ();
175 events_[START] = events_[STOP] = 0;
178 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, accidental);
179 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, fingering)
180 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, note_column);
181 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, slur);
182 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, script);
183 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, text_script);
184 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tie);
185 ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tuplet_number);
187 ADD_TRANSLATOR (Phrasing_slur_engraver,
188 /* doc */
189 "Print phrasing slurs. Similar to @ref{Slur_engraver}.",
191 /* create */
192 "PhrasingSlur ",
194 /* read */
197 /* write */