]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-engraver.cc
2003 -> 2004
[lilypond.git] / lily / spacing-engraver.cc
index 9fc77d723947edd5afd3d968117efbb01fd5a9cc..109a3063212d1ea991e436a507507a6d01b0bc5d 100644 (file)
@@ -3,11 +3,11 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
-#include "request.hh"
+#include "event.hh"
 #include "paper-column.hh"
 #include "engraver.hh"
 #include "pqueue.hh"
@@ -51,7 +51,7 @@ protected:
   virtual void acknowledge_grob (Grob_info);
   virtual void start_translation_timestep ();
   virtual void stop_translation_timestep ();
-  virtual void initialize ();
+  virtual void process_music ();
   virtual void finalize ();
 };
 
@@ -74,20 +74,27 @@ Spacing_engraver::Spacing_engraver ()
 }
 
 void
-Spacing_engraver::initialize ()
+Spacing_engraver::process_music ()
 {
-  spacing_  =new Spanner (get_property ("SpacingSpanner"));
-  spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));  
-  announce_grob(spacing_, SCM_EOL);
+  if (!spacing_)
+    {
+      spacing_ = make_spanner ("SpacingSpanner");
+      spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));  
+      announce_grob(spacing_, SCM_EOL);
+    }
 }
 
 void
 Spacing_engraver::finalize ()
 {
-  Grob * p = unsmob_grob (get_property ("currentCommandColumn"));
-  spacing_->set_bound (RIGHT, p);
-  typeset_grob (spacing_);
-  spacing_ =0;
+  if (spacing_)
+    {
+      Grob * p = unsmob_grob (get_property ("currentCommandColumn"));
+  
+      spacing_->set_bound (RIGHT, p);
+      typeset_grob (spacing_);
+      spacing_ =0;
+    }
 }
 
 void
@@ -109,7 +116,7 @@ Spacing_engraver::acknowledge_grob (Grob_info i)
       Music *r = i.music_cause ();
       if (r && r->is_mus_type ("rhythmic-event"))
        {
-         Moment len = r->length_mom ();
+         Moment len = r->get_length ();
          Rhythmic_tuple t (i, now_mom () + len);
          now_durations_.push (t);
        }
@@ -123,16 +130,19 @@ Spacing_engraver::stop_translation_timestep ()
   shortest_playing.set_infinite (1);
   for (int i=0; i < playing_durations_.size (); i++)
     {
-      Moment m = (playing_durations_[i].info_.music_cause ())->length_mom ();
-      shortest_playing = shortest_playing <? m;
+      Music * mus = playing_durations_[i].info_.music_cause ();
+      if (mus)
+       {
+         Moment m = mus->get_length ();
+         shortest_playing = shortest_playing <? m;
+       }
     }
-  
   Moment starter;
   starter.set_infinite (1);
 
   for (int i=0; i < now_durations_.size (); i++)
     {
-      Moment m = now_durations_[i].info_.music_cause ()->length_mom ();
+      Moment m = now_durations_[i].info_.music_cause ()->get_length ();
       if (m.to_bool ())
        {
          starter = starter <? m;