]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/glissando-engraver.cc
Run `make grand-replace'.
[lilypond.git] / lily / glissando-engraver.cc
index 21baa4f15001183bceb3b6155e4c1c28a5ff8ee1..da9c0a1156117ae984ce94494c010c433c5fa220 100644 (file)
@@ -3,33 +3,36 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2008 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "warn.hh"
-#include "spanner.hh"
-#include "rhythmic-head.hh"
 #include "engraver.hh"
 
-/**
-   Create line-spanner grobs for glissandi lines that connect note
-   heads.
-*/
+#include "international.hh"
+#include "rhythmic-head.hh"
+#include "spanner.hh"
+#include "stream-event.hh"
+#include "warn.hh"
+#include "item.hh"
+
+#include "translator.icc"
+
 class Glissando_engraver : public Engraver
 {
 public:
   TRANSLATOR_DECLARATIONS (Glissando_engraver);
 
 protected:
-  virtual void acknowledge_grob (Grob_info);
+  DECLARE_TRANSLATOR_LISTENER (glissando);
+  DECLARE_ACKNOWLEDGER (rhythmic_head);
   virtual void finalize ();
-  virtual void stop_translation_timestep ();
-  virtual bool try_music (Music *);
-  virtual void process_music ();
+
+  void stop_translation_timestep ();
+  void process_music ();
 private:
   Spanner *line_;
   Spanner *last_line_;
-  Music *event_;
+  Stream_event *event_;
 };
 
 Glissando_engraver::Glissando_engraver ()
@@ -38,38 +41,32 @@ Glissando_engraver::Glissando_engraver ()
   event_ = 0;
 }
 
-bool
-Glissando_engraver::try_music (Music *m)
+IMPLEMENT_TRANSLATOR_LISTENER (Glissando_engraver, glissando);
+void
+Glissando_engraver::listen_glissando (Stream_event *ev)
 {
-  if (!event_)
-    {
-      event_ = m;
-      return true;
-    }
-  return false;
+  ASSIGN_EVENT_ONCE (event_, ev);
 }
 
 void
 Glissando_engraver::process_music ()
 {
   if (event_)
-    {
-      line_ = make_spanner ("Glissando", event_->self_scm ());
-    }
+    line_ = make_spanner ("Glissando", event_->self_scm ());
 }
 
 void
-Glissando_engraver::acknowledge_grob (Grob_info info)
+Glissando_engraver::acknowledge_rhythmic_head (Grob_info info)
 {
-  if (Rhythmic_head::has_interface (info.grob_))
-    {
-      Grob *g = info.grob_;
-      if (line_)
-       line_->set_bound (LEFT, g);
+  Grob *g = info.grob ();
+  if (line_)
+    line_->set_bound (LEFT, g);
 
-      if (last_line_)
-       last_line_->set_bound (RIGHT, g);
-    }
+  if (last_line_)
+    {
+      last_line_->set_bound (RIGHT, g);
+      announce_end_grob (last_line_, g->self_scm ());
+    }      
 }
 
 void
@@ -94,7 +91,7 @@ Glissando_engraver::finalize ()
 {
   if (line_)
     {
-      String msg = _ ("unterminated glissando");
+      string msg = _ ("unterminated glissando");
 
       if (event_)
        event_->origin ()->warning (msg);
@@ -106,10 +103,17 @@ Glissando_engraver::finalize ()
     }
 }
 
+ADD_ACKNOWLEDGER (Glissando_engraver, rhythmic_head);
 ADD_TRANSLATOR (Glissando_engraver,
-               /* descr */ "Engrave a glissandi",
-               /* creats*/ "Glissando",
-               /* accepts */ "glissando-event",
-               /* acks  */ "rhythmic-head-interface",
-               /* reads */ "followVoice",
-               /* write */ "");
+               /* doc */
+               "Engrave glissandi.",
+
+               /* create */
+               "Glissando ",
+
+               /* read */
+               "",
+
+               /* write */
+               ""
+               );