2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2006--2011 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"));
64 fall_->set_bound (RIGHT, unsmob_grob (bar
65 ? get_property ("currentCommandColumn")
66 : get_property ("currentMusicalColumn")));
74 Bend_engraver::stop_translation_timestep ()
76 if (fall_ && !fall_->get_bound (LEFT))
78 fall_->set_bound (LEFT, note_head_);
79 fall_->set_parent (note_head_, Y_AXIS);
84 Bend_engraver::start_translation_timestep ()
88 if (fall_ && now_mom ().main_part_ >= stop_moment_.main_part_)
95 Bend_engraver::acknowledge_note_head (Grob_info info)
100 if (note_head_ && fall_)
105 note_head_ = info.grob ();
106 stop_moment_ = now_mom () + get_event_length (info.event_cause (),
110 Bend_engraver::Bend_engraver ()
118 IMPLEMENT_TRANSLATOR_LISTENER (Bend_engraver, bend_after);
120 Bend_engraver::listen_bend_after (Stream_event *ev)
122 ASSIGN_EVENT_ONCE (fall_event_, ev);
126 Bend_engraver::process_music ()
128 if (fall_event_ && !fall_)
130 fall_ = make_spanner ("BendAfter", fall_event_->self_scm ());
131 fall_->set_property ("delta-position",
132 scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0)));
136 ADD_ACKNOWLEDGER (Bend_engraver, note_head);
138 ADD_TRANSLATOR (Bend_engraver,
140 "Create fall spanners.",