]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/extender-engraver.cc
Imported Upstream version 2.14.2
[lilypond.git] / lily / extender-engraver.cc
index f3f711de0f84d9efb31664bb04b43f3ce7f8086e..49fcbcaf3f598d6a55895c1238cb46685dcacd75 100644 (file)
@@ -1,11 +1,22 @@
 /*
-  extender-engraver.cc -- implement Extender_engraver
+  This file is part of LilyPond, the GNU music typesetter.
 
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1999--2009 Glen Prideaux <glenprideaux@iname.com>,
+  Copyright (C) 1999--2011 Glen Prideaux <glenprideaux@iname.com>,
   Han-Wen Nienhuys <hanwen@xs4all.nl>,
   Jan Nieuwenhuizen <janneke@gnu.org>
+
+  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 <http://www.gnu.org/licenses/>.
 */
 
 #include "context.hh"
@@ -18,7 +29,6 @@
 #include "stream-event.hh"
 #include "warn.hh"
 #include "spanner.hh"
-
 #include "translator.icc"
 
 void completize_extender (Spanner *sp);
@@ -34,6 +44,7 @@ public:
 
 protected:
   DECLARE_TRANSLATOR_LISTENER (extender);
+  DECLARE_TRANSLATOR_LISTENER (completize_extender);
   DECLARE_ACKNOWLEDGER (lyric_syllable);
 
   virtual void finalize ();
@@ -56,6 +67,24 @@ Extender_engraver::listen_extender (Stream_event *ev)
   ASSIGN_EVENT_ONCE (ev_, ev);
 }
 
+
+/*
+  A CompletizeExtenderEvent is sent at the end of each lyrics block
+  to ensure any pending extender can be correctly terminated if the lyrics
+  end before the associated voice (this prevents the right bound being extended
+  to the next note-column if no lyric follows the extender)
+*/
+IMPLEMENT_TRANSLATOR_LISTENER (Extender_engraver, completize_extender);
+void
+Extender_engraver::listen_completize_extender (Stream_event * /* ev */)
+{
+  if (pending_extender_)
+    {
+      completize_extender (pending_extender_);
+      pending_extender_ = 0;
+    }
+}
+
 void
 Extender_engraver::process_music ()
 {
@@ -84,7 +113,7 @@ Extender_engraver::stop_translation_timestep ()
   if (extender_ || pending_extender_)
     {
       Context *voice = get_voice_to_lyrics (context ());
-      Grob *h = voice ? get_current_note_head (voice) : 0;
+      Grob *h = voice ? get_current_note_head (voice, to_boolean (get_property ("includeGraceNotes"))) : 0;
 
       if (h)
        {
@@ -108,7 +137,6 @@ Extender_engraver::stop_translation_timestep ()
              completize_extender (pending_extender_);
              pending_extender_ = 0;
            }
-         
        }
       if (extender_)
        {
@@ -162,7 +190,8 @@ ADD_TRANSLATOR (Extender_engraver,
                "LyricExtender ",
 
                /* read */
-               "extendersOverRests ",
+               "extendersOverRests "
+               "includeGraceNotes ",
 
                /* write */
                ""