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>
12 #include "directional-element-interface.hh"
13 #include "international.hh"
14 #include "note-column.hh"
17 #include "stream-event.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
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_
;
42 vector
<Grob
*> end_slurs_
;
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 ();
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
);
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"));
77 ASSIGN_EVENT_ONCE (events_
[START
], ev
);
78 else if (d
== STOP
&& !slurs_
.empty ())
79 ASSIGN_EVENT_ONCE (events_
[STOP
], ev
);
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
);
93 Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info
)
95 Slur::auxiliary_acknowledge_extra_object (info
, slurs_
, end_slurs_
);
99 Phrasing_slur_engraver::acknowledge_accidental (Grob_info info
)
101 acknowledge_extra_object (info
);
105 Phrasing_slur_engraver::acknowledge_fingering (Grob_info info
)
107 acknowledge_extra_object (info
);
111 Phrasing_slur_engraver::acknowledge_text_script (Grob_info info
)
113 acknowledge_extra_object (info
);
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
);
124 Phrasing_slur_engraver::acknowledge_tie (Grob_info info
)
126 acknowledge_extra_object (info
);
130 Phrasing_slur_engraver::acknowledge_slur (Grob_info info
)
132 acknowledge_extra_object (info
);
136 Phrasing_slur_engraver::finalize ()
139 slurs_
[0]->warning (_ ("unterminated phrasing slur"));
143 Phrasing_slur_engraver::process_music ()
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"));
158 set_grob_direction (slur
, updown
);
160 slurs_
.push_back (slur
);
165 Phrasing_slur_engraver::stop_translation_timestep ()
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
,
181 "Print phrasing slurs. Similar to @ref{Slur_engraver}.",