X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbend-engraver.cc;h=f9eaaa71f4bed96eb985f7f07782527dc9b7ad63;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=9f5602fef096ccde37a9a10fedb01aeb5116c0ab;hpb=ecf2b5e9dcfa7654803fb0050d7127e0ec7fd934;p=lilypond.git
diff --git a/lily/bend-engraver.cc b/lily/bend-engraver.cc
index 9f5602fef0..f9eaaa71f4 100644
--- a/lily/bend-engraver.cc
+++ b/lily/bend-engraver.cc
@@ -1,9 +1,20 @@
/*
- bend-engraver.cc -- implement Bend_engraver
+ This file is part of LilyPond, the GNU music typesetter.
- (c) 2006--2007 Han-Wen Nienhuys
+ Copyright (C) 2006--2015 Han-Wen Nienhuys
-
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see .
*/
#include "engraver.hh"
@@ -18,31 +29,42 @@ class Bend_engraver : public Engraver
{
public:
TRANSLATOR_DECLARATIONS (Bend_engraver);
- DECLARE_ACKNOWLEDGER (note_head);
+ void acknowledge_note_head (Grob_info);
protected:
- DECLARE_TRANSLATOR_LISTENER (bend_after);
+ void listen_bend_after (Stream_event *);
+ void finalize ();
void process_music ();
void stop_translation_timestep ();
void start_translation_timestep ();
void stop_fall ();
-
+
private:
Moment stop_moment_;
Stream_event *fall_event_;
Spanner *fall_;
+ Spanner *last_fall_;
Grob *note_head_;
};
+void
+Bend_engraver::finalize ()
+{
+ // We shouldn't end a spanner on the last musical column of a piece because then
+ // it would extend past the last breakable column of the piece.
+ if (last_fall_)
+ last_fall_->set_bound (RIGHT, unsmob (get_property ("currentCommandColumn")));
+}
+
void
Bend_engraver::stop_fall ()
{
bool bar = scm_is_string (get_property ("whichBar"));
-
-
- fall_->set_bound (RIGHT, unsmob_grob (bar
- ? get_property ("currentCommandColumn")
- : get_property ("currentMusicalColumn")));
+
+ fall_->set_bound (RIGHT, unsmob (bar
+ ? get_property ("currentCommandColumn")
+ : get_property ("currentMusicalColumn")));
+ last_fall_ = fall_;
fall_ = 0;
note_head_ = 0;
fall_event_ = 0;
@@ -51,16 +73,18 @@ Bend_engraver::stop_fall ()
void
Bend_engraver::stop_translation_timestep ()
{
- if (fall_ && !fall_->get_bound (LEFT))
+ if (fall_ && !fall_->get_bound (LEFT))
{
fall_->set_bound (LEFT, note_head_);
- fall_->set_parent (note_head_, Y_AXIS);
+ fall_->set_parent (note_head_, Y_AXIS);
}
}
void
Bend_engraver::start_translation_timestep ()
{
+ last_fall_ = 0;
+
if (fall_ && now_mom ().main_part_ >= stop_moment_.main_part_)
{
stop_fall ();
@@ -72,7 +96,7 @@ Bend_engraver::acknowledge_note_head (Grob_info info)
{
if (!fall_event_)
return;
-
+
if (note_head_ && fall_)
{
stop_fall ();
@@ -80,17 +104,18 @@ Bend_engraver::acknowledge_note_head (Grob_info info)
note_head_ = info.grob ();
stop_moment_ = now_mom () + get_event_length (info.event_cause (),
- now_mom ());
+ now_mom ());
}
-Bend_engraver::Bend_engraver ()
+Bend_engraver::Bend_engraver (Context *c)
+ : Engraver (c)
{
fall_ = 0;
+ last_fall_ = 0;
note_head_ = 0;
fall_event_ = 0;
}
-IMPLEMENT_TRANSLATOR_LISTENER (Bend_engraver, bend_after);
void
Bend_engraver::listen_bend_after (Stream_event *ev)
{
@@ -104,22 +129,28 @@ Bend_engraver::process_music ()
{
fall_ = make_spanner ("BendAfter", fall_event_->self_scm ());
fall_->set_property ("delta-position",
- scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0)));
+ scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0)));
}
}
-ADD_ACKNOWLEDGER (Bend_engraver, note_head);
+
+void
+Bend_engraver::boot ()
+{
+ ADD_LISTENER (Bend_engraver, bend_after);
+ ADD_ACKNOWLEDGER (Bend_engraver, note_head);
+}
ADD_TRANSLATOR (Bend_engraver,
- /* doc */
- "Create fall spanners.",
+ /* doc */
+ "Create fall spanners.",
- /* create */
- "BendAfter ",
+ /* create */
+ "BendAfter ",
- /* read */
- "",
+ /* read */
+ "",
- /* write */
- ""
- );
+ /* write */
+ ""
+ );