]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/extender-engraver.cc
Run `make grand-replace'.
[lilypond.git] / lily / extender-engraver.cc
index f44460530d373a9fa998a863e1757a3214bc823e..af1ae8503e7eedaf397c702320004189ca10a67f 100644 (file)
@@ -3,24 +3,29 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2005 Glen Prideaux <glenprideaux@iname.com>,
-  Han-Wen Nienhuys <hanwen@cs.uu.nl>,
+  (c) 1999--2008 Glen Prideaux <glenprideaux@iname.com>,
+  Han-Wen Nienhuys <hanwen@xs4all.nl>,
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "context.hh"
 #include "engraver.hh"
-#include "pointer-group-interface.hh"
+#include "international.hh"
 #include "item.hh"
 #include "lyric-extender.hh"
 #include "note-head.hh"
+#include "pointer-group-interface.hh"
+#include "stream-event.hh"
 #include "warn.hh"
+#include "spanner.hh"
+
+#include "translator.icc"
 
 void completize_extender (Spanner *sp);
 
 class Extender_engraver : public Engraver
 {
-  Music *ev_;
+  Stream_event *ev_;
   Spanner *extender_;
   Spanner *pending_extender_;
 
@@ -28,11 +33,13 @@ public:
   TRANSLATOR_DECLARATIONS (Extender_engraver);
 
 protected:
-  virtual void acknowledge_grob (Grob_info);
+  DECLARE_TRANSLATOR_LISTENER (extender);
+  DECLARE_ACKNOWLEDGER (lyric_syllable);
+
   virtual void finalize ();
-  virtual bool try_music (Music *);
-  PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
-  PRECOMPUTED_VIRTUAL void process_music ();
+
+  void stop_translation_timestep ();
+  void process_music ();
 };
 
 Extender_engraver::Extender_engraver ()
@@ -42,15 +49,11 @@ Extender_engraver::Extender_engraver ()
   ev_ = 0;
 }
 
-bool
-Extender_engraver::try_music (Music *r)
+IMPLEMENT_TRANSLATOR_LISTENER (Extender_engraver, extender);
+void
+Extender_engraver::listen_extender (Stream_event *ev)
 {
-  if (!ev_)
-    {
-      ev_ = r;
-      return true;
-    }
-  return false;
+  ASSIGN_EVENT_ONCE (ev_, ev);
 }
 
 void
@@ -61,22 +64,17 @@ Extender_engraver::process_music ()
 }
 
 void
-Extender_engraver::acknowledge_grob (Grob_info i)
+Extender_engraver::acknowledge_lyric_syllable (Grob_info i)
 {
-  Item *item = dynamic_cast<Item *> (i.grob ());
+  Item *item = i.item ();
+  if (extender_)
+    extender_->set_bound (LEFT, item);
 
-  if (item
-      && item->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface")))
+  if (pending_extender_)
     {
-      if (extender_)
-       extender_->set_bound (LEFT, item);
-
-      if (pending_extender_)
-       {
-         pending_extender_->set_object ("next", item->self_scm ());
-         completize_extender (pending_extender_);
-         pending_extender_ = 0;
-       }
+      pending_extender_->set_object ("next", item->self_scm ());
+      completize_extender (pending_extender_);
+      pending_extender_ = 0;
     }
 }
 
@@ -102,7 +100,16 @@ Extender_engraver::stop_translation_timestep ()
                                                 ly_symbol2scm ("heads"), h);
            }
        }
-
+      else
+       {
+         if (pending_extender_
+             && !get_property ("extendersOverRests"))
+           {
+             completize_extender (pending_extender_);
+             pending_extender_ = 0;
+           }
+         
+       }
       if (extender_)
        {
          pending_extender_ = extender_;
@@ -120,9 +127,7 @@ completize_extender (Spanner *sp)
     {
       extract_item_set (sp, "heads", heads);
       if (heads.size ())
-       {
-         sp->set_bound (RIGHT, heads.top());
-       }
+       sp->set_bound (RIGHT, heads.back ());
     }
 }
 
@@ -148,12 +153,17 @@ Extender_engraver::finalize ()
     }
 }
 
-#include "translator.icc"
-
+ADD_ACKNOWLEDGER (Extender_engraver, lyric_syllable);
 ADD_TRANSLATOR (Extender_engraver,
-               /* descr */ "Create lyric extenders",
-               /* creats*/ "LyricExtender",
-               /* accepts */ "extender-event",
-               /* acks  */ "lyric-syllable-interface",
-               /* reads */ "",
-               /* write */ "");
+               /* doc */
+               "Create lyric extenders.",
+
+               /* create */
+               "LyricExtender ",
+
+               /* read */
+               "extendersOverRests ",
+
+               /* write */
+               ""
+               );