2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2006--2010 Han-Wen Nienhuys
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
24 #include "stream-event.hh"
26 #include "translator.icc"
28 class Bend_engraver
: public Engraver
31 TRANSLATOR_DECLARATIONS (Bend_engraver
);
32 DECLARE_ACKNOWLEDGER (note_head
);
35 DECLARE_TRANSLATOR_LISTENER (bend_after
);
37 void process_music ();
38 void stop_translation_timestep ();
39 void start_translation_timestep ();
44 Stream_event
*fall_event_
;
51 Bend_engraver::finalize ()
53 // We shouldn't end a spanner on the last musical column of a piece because then
54 // it would extend past the last breakable column of the piece.
56 last_fall_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
60 Bend_engraver::stop_fall ()
62 bool bar
= scm_is_string (get_property ("whichBar"));
65 fall_
->set_bound (RIGHT
, unsmob_grob (bar
66 ? get_property ("currentCommandColumn")
67 : get_property ("currentMusicalColumn")));
75 Bend_engraver::stop_translation_timestep ()
77 if (fall_
&& !fall_
->get_bound (LEFT
))
79 fall_
->set_bound (LEFT
, note_head_
);
80 fall_
->set_parent (note_head_
, Y_AXIS
);
85 Bend_engraver::start_translation_timestep ()
89 if (fall_
&& now_mom ().main_part_
>= stop_moment_
.main_part_
)
96 Bend_engraver::acknowledge_note_head (Grob_info info
)
101 if (note_head_
&& fall_
)
106 note_head_
= info
.grob ();
107 stop_moment_
= now_mom () + get_event_length (info
.event_cause (),
111 Bend_engraver::Bend_engraver ()
119 IMPLEMENT_TRANSLATOR_LISTENER (Bend_engraver
, bend_after
);
121 Bend_engraver::listen_bend_after (Stream_event
*ev
)
123 ASSIGN_EVENT_ONCE (fall_event_
, ev
);
127 Bend_engraver::process_music ()
129 if (fall_event_
&& !fall_
)
131 fall_
= make_spanner ("BendAfter", fall_event_
->self_scm ());
132 fall_
->set_property ("delta-position",
133 scm_from_double (robust_scm2double (fall_event_
->get_property ("delta-step"), 0)));
137 ADD_ACKNOWLEDGER (Bend_engraver
, note_head
);
139 ADD_TRANSLATOR (Bend_engraver
,
141 "Create fall spanners.",