]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #207.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 31 Dec 2006 13:09:36 +0000 (14:09 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 31 Dec 2006 13:09:36 +0000 (14:09 +0100)
Set NoteSpacing -> SeparationItem item link in Note_spacing_engraver
using the breakableSeparationItem property.  This detects spacing
structure in single-staff polyphonic situations more correctly

input/regression/spacing-folded-clef-cross-staff.ly [new file with mode: 0644]
lily/note-spacing-engraver.cc
lily/separating-line-group-engraver.cc
lily/spaceable-grob.cc
lily/spacing-determine-loose-columns.cc

diff --git a/input/regression/spacing-folded-clef-cross-staff.ly b/input/regression/spacing-folded-clef-cross-staff.ly
new file mode 100644 (file)
index 0000000..a38c033
--- /dev/null
@@ -0,0 +1,22 @@
+\version "2.10.0"
+\header {
+    texidoc = "Clefs are also folded under cross staff constructs."
+}
+
+\layout { ragged-right = ##t}
+
+\context PianoStaff <<
+  \new Staff = "up"
+  \relative c'' <<
+    {
+      \stemDown
+      f16[ \change Staff = down \stemUp
+      \clef treble g,]
+
+    } \\
+  >>
+  \new Staff = "down" {
+    \time 3/8 \clef bass s8
+  }
+>>
+
index 33c459cb133d42330fbbcb10945f109183e0929e..7b5f2ad7bd33c4f261dde5d08604da7e38373aec 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "engraver.hh"
 
+#include "context.hh"
 #include "item.hh"
 #include "pointer-group-interface.hh"
 
 class Note_spacing_engraver : public Engraver
 {
   Grob *last_spacing_;
+  Context *last_spacing_parent_context_;
+  
   Grob *spacing_;
 
   void add_spacing_item (Grob *);
-
   TRANSLATOR_DECLARATIONS (Note_spacing_engraver);
 protected:
 
   DECLARE_ACKNOWLEDGER (rhythmic_grob);
   DECLARE_ACKNOWLEDGER (note_column);
   void stop_translation_timestep ();
+  virtual void finalize ();
+  virtual void derived_mark () const;
 };
 
+void
+Note_spacing_engraver::derived_mark () const
+{
+  if (last_spacing_parent_context_)
+    scm_gc_mark (last_spacing_parent_context_->self_scm ());
+}
+
 Note_spacing_engraver::Note_spacing_engraver ()
 {
+  last_spacing_parent_context_ = 0;
   last_spacing_ = 0;
   spacing_ = 0;
 }
@@ -43,7 +55,6 @@ Note_spacing_engraver::add_spacing_item (Grob *g)
       spacing_ = make_item ("NoteSpacing", g->self_scm ());
     }
   
-  
   if (spacing_)
     {
       Pointer_group_interface::add_grob (spacing_,
@@ -51,11 +62,9 @@ Note_spacing_engraver::add_spacing_item (Grob *g)
                                         g);
 
       if (last_spacing_)
-       {
-         Pointer_group_interface::add_grob (last_spacing_,
-                                            ly_symbol2scm ("right-items"),
-                                            g);
-       }
+       Pointer_group_interface::add_grob (last_spacing_,
+                                          ly_symbol2scm ("right-items"),
+                                          g);
     }
 }
 
@@ -72,14 +81,43 @@ Note_spacing_engraver::acknowledge_rhythmic_grob (Grob_info gi)
   add_spacing_item (gi.grob ());
 }
 
+void
+Note_spacing_engraver::finalize ()
+{
+  if (last_spacing_
+      && last_spacing_parent_context_
+      && last_spacing_parent_context_ == context ()->get_parent_context ())
+    {
+      SCM ccol = get_property ("currentCommandColumn");
+      Grob *column = unsmob_grob (ccol);
+      
+      Pointer_group_interface::add_grob (last_spacing_,
+                                        ly_symbol2scm ("right-items"),
+                                        column);
+    }
+}
+
 void
 Note_spacing_engraver::stop_translation_timestep ()
 {
+  if (last_spacing_
+      && last_spacing_parent_context_
+      && last_spacing_parent_context_ == context ()->get_parent_context ())
+    {
+      Grob *sep = unsmob_grob (get_property ("breakableSeparationItem"));
+      if (sep)
+       Pointer_group_interface::add_grob (last_spacing_,
+                                          ly_symbol2scm ("right-items"),
+                                          sep);
+    }
+  
   if (spacing_)
     {
       last_spacing_ = spacing_;
+      last_spacing_parent_context_ = context ()->get_parent_context ();
       spacing_ = 0;
     }
+
 }
 
 ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column);
index b2aeb9b2ab4e72fe492f84114cb1cd1e06cb59a2..d98221e6481de00c3030508162f4770579f3c397 100644 (file)
@@ -93,13 +93,6 @@ Separating_line_group_engraver::finalize ()
   sep_span_->set_bound (RIGHT, unsmob_grob (ccol));
   sep_span_ = 0;
 
-  for (vsize i = 0; i < last_spacings_.note_spacings_.size (); i++)
-    {
-      Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
-                                        ly_symbol2scm ("right-items"),
-                                        column);
-    }
-
   if (last_spacings_.staff_spacing_
       && last_spacings_.staff_spacing_->get_column () == column)
     last_spacings_.staff_spacing_->suicide ();
@@ -146,14 +139,8 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i)
          Pointer_group_interface::add_grob (it, ly_symbol2scm ("left-items"),
                                             break_item_);
 
-         if (int i = last_spacings_.note_spacings_.size ())
-           {
-             for (; i--;)
-               Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
-                                                  ly_symbol2scm ("right-items"),
-                                                  break_item_);
-           }
-         else if (last_spacings_.staff_spacing_)
+         if (!last_spacings_.note_spacings_.size ()
+             && last_spacings_.staff_spacing_)
            {
              SCM ri = last_spacings_.staff_spacing_->get_object ("right-items");
              Grob_array *ga = unsmob_grob_array (ri);
index 679c2bcb195651dc1954d371c59830d7d447b887..7d86ebf9195ac73a7356e1f187a2807430be2fca 100644 (file)
@@ -132,5 +132,7 @@ ADD_INTERFACE (Spaceable_grob,
               "measure-length "
               "minimum-distances "
               "right-neighbors "
-              "spacing-wishes");
+              "spacing-wishes "
+
+              );
 
index 8f6355b26e024aea3f2e2991662a2435b1b1dc78..052e0d766bf441c64d1d7c71ec0c539be3864c9c 100644 (file)
@@ -39,7 +39,7 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
   
 
   if ((options->float_nonmusical_columns_
-       ||options->float_grace_columns_)
+       || options->float_grace_columns_)
       && Paper_column::when_mom (col).grace_part_)
     {
       return true;
@@ -104,9 +104,6 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
     return false;
 
   /*
-    A rather hairy check, but we really only want to move around
-    clefs. (anything else?)
-
     in any case, we don't want to move bar lines.
   */
   extract_grob_set (col, "elements", elts);
@@ -120,9 +117,6 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options)
            {
              Grob *h = gelts[j];
 
-             /*
-               ugh. -- fix staff-bar name?
-             */
              if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar"))
                return false;
            }
@@ -234,8 +228,20 @@ Spacing_spanner::prune_loose_columns (Grob *me, vector<Grob*> *cols,
            }
          else
            {
+             Grob *min_item = 0;
+             int min_rank = INT_MAX;
+             for (vsize j = 0; j < right_items.size (); j ++)
+               {
+                 int rank = dynamic_cast<Item*> (right_items[j])->get_column ()->get_rank ();
+                 if (rank < min_rank)
+                   {
+                     min_item = right_items[j];
+                     min_rank = rank;
+                   }
+               }
+             
              c->set_object ("between-cols", scm_cons (lns,
-                                                      right_items[0]->self_scm ()));
+                                                      min_item->self_scm ()));
 
              /*
                Set distance constraints for loose columns
@@ -264,7 +270,7 @@ Spacing_spanner::set_explicit_neighbor_columns (vector<Grob*> const &cols)
     {
       SCM right_neighbors = Grob_array::make_array ();
       Grob_array *rn_arr = unsmob_grob_array (right_neighbors);
-      int min_rank = 100000;   // inf.
+      int min_rank = INT_MAX;
 
       extract_grob_set (cols[i], "spacing-wishes", wishes);
       for (vsize k = wishes.size (); k--;)
@@ -338,8 +344,6 @@ Spacing_spanner::set_implicit_neighbor_columns (vector<Grob*> const &cols)
       if (!Paper_column::is_breakable (it) && !Paper_column::is_musical (it))
        continue;
 
-      // it->breakable || it->musical
-
       /*
        sloppy with typing left/right-neighbors should take list, but paper-column found instead.
       */