]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-engraver.cc
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / spacing-engraver.cc
index c35d5fe98b08abbe2412bb7ce13230fb887c7fb8..ad49a345b6de47eae4ed06cb6854e4003e899652 100644 (file)
@@ -3,10 +3,11 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1999--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "engraver.hh"
+#include "moment.hh"
 #include "note-spacing.hh"
 #include "paper-column.hh"
 #include "pointer-group-interface.hh"
@@ -67,12 +68,14 @@ protected:
   DECLARE_ACKNOWLEDGER (staff_spacing);
   DECLARE_ACKNOWLEDGER (note_spacing);
   DECLARE_ACKNOWLEDGER (rhythmic_head);
+  DECLARE_ACKNOWLEDGER (rhythmic_grob);
   DECLARE_TRANSLATOR_LISTENER (spacing_section);
 
   void start_translation_timestep ();
   void stop_translation_timestep ();
   void process_music ();
-  
+  void add_starter_duration (Grob_info i);
+
   virtual void finalize ();
 
   void start_spanner ();
@@ -89,7 +92,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Spacing_engraver, spacing_section);
 void
 Spacing_engraver::listen_spacing_section (Stream_event *ev)
 {
-  start_section_ = ev;
+  ASSIGN_EVENT_ONCE (start_section_, ev);
 }
 
 void
@@ -107,6 +110,7 @@ Spacing_engraver::start_spanner ()
 {
   assert (!spacing_);
 
+
   spacing_ = make_spanner ("SpacingSpanner", SCM_EOL);
   spacing_->set_bound (LEFT,
                       unsmob_grob (get_property ("currentCommandColumn")));
@@ -142,8 +146,21 @@ Spacing_engraver::acknowledge_staff_spacing (Grob_info i)
   Pointer_group_interface::add_grob (spacing_, ly_symbol2scm ("wishes"), i.grob ());
 }
 
+void
+Spacing_engraver::acknowledge_rhythmic_grob (Grob_info i)
+{
+ add_starter_duration (i);  
+}
+
 void
 Spacing_engraver::acknowledge_rhythmic_head (Grob_info i)
+{
+  add_starter_duration (i);
+}
+
+
+void
+Spacing_engraver::add_starter_duration (Grob_info i)
 {
   if (i.grob ()->internal_has_interface (ly_symbol2scm ("lyric-syllable-interface"))
       || i.grob ()->internal_has_interface (ly_symbol2scm ("multi-measure-interface")))
@@ -171,18 +188,19 @@ Spacing_engraver::stop_translation_timestep ()
     = dynamic_cast<Paper_column *> (unsmob_grob (get_property ("currentMusicalColumn")));
 
 
-  if (spacing_)
-    {  
-      musical_column->set_object ("spacing", spacing_->self_scm ());
-      unsmob_grob (get_property ("currentCommandColumn"))
-       ->set_object ("spacing", spacing_->self_scm ());
-    }
+  if (!spacing_)
+    start_spanner ();
+
+  musical_column->set_object ("spacing", spacing_->self_scm ());
+  unsmob_grob (get_property ("currentCommandColumn"))
+    ->set_object ("spacing", spacing_->self_scm ());
   
   SCM proportional = get_property ("proportionalNotationDuration");
   if (unsmob_moment (proportional))
     {
       musical_column->set_property ("shortest-playing-duration", proportional);
       musical_column->set_property ("shortest-starter-duration", proportional);
+      musical_column->set_property ("used", SCM_BOOL_T);
       return;
     }
 
@@ -240,14 +258,13 @@ Spacing_engraver::start_translation_timestep ()
 ADD_ACKNOWLEDGER (Spacing_engraver, staff_spacing);
 ADD_ACKNOWLEDGER (Spacing_engraver, note_spacing);
 ADD_ACKNOWLEDGER (Spacing_engraver, rhythmic_head);
+ADD_ACKNOWLEDGER (Spacing_engraver, rhythmic_grob);
 
 ADD_TRANSLATOR (Spacing_engraver,
                "make a SpacingSpanner and do "
                "bookkeeping of shortest starting and playing notes  ",
 
                /* create */ "SpacingSpanner",
-               /* accept */
-               "spacing-section-event ",
                /* read */
                "currentMusicalColumn "
                "currentCommandColumn "