2 bend-engraver.cc -- implement Bend_engraver
4 (c) 2006--2007 Han-Wen Nienhuys
13 #include "stream-event.hh"
15 #include "translator.icc"
17 class Bend_engraver : public Engraver
20 TRANSLATOR_DECLARATIONS (Bend_engraver);
21 DECLARE_ACKNOWLEDGER (note_head);
24 DECLARE_TRANSLATOR_LISTENER (bend_after);
26 void process_music ();
27 void stop_translation_timestep ();
28 void start_translation_timestep ();
33 Stream_event *fall_event_;
40 Bend_engraver::finalize ()
42 // We shouldn't end a spanner on the last musical column of a piece because then
43 // it would extend past the last breakable column of the piece.
45 last_fall_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
49 Bend_engraver::stop_fall ()
51 bool bar = scm_is_string (get_property ("whichBar"));
54 fall_->set_bound (RIGHT, unsmob_grob (bar
55 ? get_property ("currentCommandColumn")
56 : get_property ("currentMusicalColumn")));
64 Bend_engraver::stop_translation_timestep ()
66 if (fall_ && !fall_->get_bound (LEFT))
68 fall_->set_bound (LEFT, note_head_);
69 fall_->set_parent (note_head_, Y_AXIS);
74 Bend_engraver::start_translation_timestep ()
78 if (fall_ && now_mom ().main_part_ >= stop_moment_.main_part_)
85 Bend_engraver::acknowledge_note_head (Grob_info info)
90 if (note_head_ && fall_)
95 note_head_ = info.grob ();
96 stop_moment_ = now_mom () + get_event_length (info.event_cause (),
100 Bend_engraver::Bend_engraver ()
108 IMPLEMENT_TRANSLATOR_LISTENER (Bend_engraver, bend_after);
110 Bend_engraver::listen_bend_after (Stream_event *ev)
112 ASSIGN_EVENT_ONCE (fall_event_, ev);
116 Bend_engraver::process_music ()
118 if (fall_event_ && !fall_)
120 fall_ = make_spanner ("BendAfter", fall_event_->self_scm ());
121 fall_->set_property ("delta-position",
122 scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0)));
126 ADD_ACKNOWLEDGER (Bend_engraver, note_head);
128 ADD_TRANSLATOR (Bend_engraver,
130 "Create fall spanners.",