Remove unused prototype in score.hh.
[lilypond/mpolesky.git] / lily / bend-engraver.cc
blob8427af0525e345f5d2a0d46f54c35745f66f5bc4
1 /*
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"
21 #include "item.hh"
22 #include "moment.hh"
23 #include "spanner.hh"
24 #include "stream-event.hh"
26 #include "translator.icc"
28 class Bend_engraver : public Engraver
30 public:
31 TRANSLATOR_DECLARATIONS (Bend_engraver);
32 DECLARE_ACKNOWLEDGER (note_head);
34 protected:
35 DECLARE_TRANSLATOR_LISTENER (bend_after);
36 void finalize ();
37 void process_music ();
38 void stop_translation_timestep ();
39 void start_translation_timestep ();
40 void stop_fall ();
42 private:
43 Moment stop_moment_;
44 Stream_event *fall_event_;
45 Spanner *fall_;
46 Spanner *last_fall_;
47 Grob *note_head_;
50 void
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.
55 if (last_fall_)
56 last_fall_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
59 void
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")));
68 last_fall_ = fall_;
69 fall_ = 0;
70 note_head_ = 0;
71 fall_event_ = 0;
74 void
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);
84 void
85 Bend_engraver::start_translation_timestep ()
87 last_fall_ = 0;
89 if (fall_ && now_mom ().main_part_ >= stop_moment_.main_part_)
91 stop_fall ();
95 void
96 Bend_engraver::acknowledge_note_head (Grob_info info)
98 if (!fall_event_)
99 return;
101 if (note_head_ && fall_)
103 stop_fall ();
106 note_head_ = info.grob ();
107 stop_moment_ = now_mom () + get_event_length (info.event_cause (),
108 now_mom ());
111 Bend_engraver::Bend_engraver ()
113 fall_ = 0;
114 last_fall_ = 0;
115 note_head_ = 0;
116 fall_event_ = 0;
119 IMPLEMENT_TRANSLATOR_LISTENER (Bend_engraver, bend_after);
120 void
121 Bend_engraver::listen_bend_after (Stream_event *ev)
123 ASSIGN_EVENT_ONCE (fall_event_, ev);
126 void
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,
140 /* doc */
141 "Create fall spanners.",
143 /* create */
144 "BendAfter ",
146 /* read */
149 /* write */