]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 399.
authorJoe Neeman <joeneeman@gmail.com>
Fri, 3 Aug 2007 23:52:36 +0000 (09:52 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Fri, 3 Aug 2007 23:52:36 +0000 (09:52 +1000)
Remember the last note-spacing object on each staff (instead of only
remembering one).

input/regression/spacing-folded-clef3.ly [new file with mode: 0644]
lily/note-spacing-engraver.cc

diff --git a/input/regression/spacing-folded-clef3.ly b/input/regression/spacing-folded-clef3.ly
new file mode 100644 (file)
index 0000000..01d9969
--- /dev/null
@@ -0,0 +1,25 @@
+\version "2.11.28"
+
+\header {
+  texidoc = "Voices that go back and forth between staves do not confuse the spacing engine."
+}
+
+\paper { ragged-right = ##t }
+
+\new PianoStaff <<
+        \new Staff = "rh" \relative c'' {
+                \time 6/8
+                bes16 c d
+                \change Staff = lh
+                \stemUp bes a g
+                \change Staff = rh
+                \stemDown bes c d
+                \change Staff = lh
+                \clef bass
+                \stemUp bes, a g
+
+        }
+        \new Staff = "lh" \relative c' {
+                s2.
+        }
+>>
\ No newline at end of file
index 68593604de12420214b390b78adda3536567e10c..3131f17777abea5867aaf294cfe56671c57a79c6 100644 (file)
 #include "item.hh"
 #include "pointer-group-interface.hh"
 
+#include <map>
+
 #include "translator.icc"
 
 class Note_spacing_engraver : public Engraver
 {
-  Grob *last_spacing_;
-  Context *last_spacing_parent_context_;
+  typedef map <Context*, Grob*> Last_spacing_map;
+  Last_spacing_map last_spacings_;
   
   Grob *spacing_;
 
@@ -37,14 +39,13 @@ protected:
 void
 Note_spacing_engraver::derived_mark () const
 {
-  if (last_spacing_parent_context_)
-    scm_gc_mark (last_spacing_parent_context_->self_scm ());
+  for (Last_spacing_map::const_iterator i = last_spacings_.begin ();
+       i != last_spacings_.end (); i++)
+    scm_gc_mark (i->first->self_scm ());
 }
 
 Note_spacing_engraver::Note_spacing_engraver ()
 {
-  last_spacing_parent_context_ = 0;
-  last_spacing_ = 0;
   spacing_ = 0;
 }
 
@@ -62,8 +63,9 @@ Note_spacing_engraver::add_spacing_item (Grob *g)
                                         ly_symbol2scm ("left-items"),
                                         g);
 
-      if (last_spacing_)
-       Pointer_group_interface::add_grob (last_spacing_,
+      Grob *last_spacing = last_spacings_[context ()->get_parent_context ()];
+      if (last_spacing)
+       Pointer_group_interface::add_grob (last_spacing,
                                           ly_symbol2scm ("right-items"),
                                           g);
     }
@@ -85,38 +87,38 @@ Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
 void
 Note_spacing_engraver::finalize ()
 {
-  if (last_spacing_
-      && last_spacing_parent_context_
-      && last_spacing_parent_context_ == context ()->get_parent_context ()
-      && !unsmob_grob_array (last_spacing_->get_object ("right-items")))
+  Context *parent = context ()->get_parent_context ();
+  Grob *last_spacing = last_spacings_[parent];
+
+  if (last_spacing
+      && !unsmob_grob_array (last_spacing->get_object ("right-items")))
     {
-      SCM ccol = get_property ("currentCommandColumn");
-      Grob *column = unsmob_grob (ccol);
+      Grob *col  = unsmob_grob (get_property ("currentCommandColumn"));
       
-      Pointer_group_interface::add_grob (last_spacing_,
+      Pointer_group_interface::add_grob (last_spacing,
                                         ly_symbol2scm ("right-items"),
-                                        column);
+                                        col);
     }
 }
 
 void
 Note_spacing_engraver::stop_translation_timestep ()
 {
-  if (last_spacing_
-      && last_spacing_parent_context_
-      && last_spacing_parent_context_ == context ()->get_parent_context ()
+  Context *parent = context ()->get_parent_context ();
+  Grob *last_spacing = last_spacings_[parent];
+
+  if (last_spacing
       && to_boolean (get_property ("hasStaffSpacing")))
     {
       Grob *col = unsmob_grob (get_property ("currentCommandColumn"));
-      Pointer_group_interface::add_grob (last_spacing_,
+      Pointer_group_interface::add_grob (last_spacing,
                                         ly_symbol2scm ("right-items"),
                                         col);
     }
   
   if (spacing_)
     {
-      last_spacing_ = spacing_;
-      last_spacing_parent_context_ = context ()->get_parent_context ();
+      last_spacings_[parent] = spacing_;
       spacing_ = 0;
     }