]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/separating-group-spanner.cc
*** empty log message ***
[lilypond.git] / lily / separating-group-spanner.cc
index cfe9409140b9bc092250b503cca411a8356a8082..69d56aa806f79f0ff94024cb184effd46707904c 100644 (file)
@@ -3,19 +3,20 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "separating-group-spanner.hh"
+
 #include "separation-item.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "dimensions.hh"
 #include "group-interface.hh"
 
 void
-Separating_group_spanner::find_rods (Item * r, SCM next)
+Separating_group_spanner::find_rods (Item * r, SCM next, Real padding)
 {
 
   /*
@@ -26,10 +27,11 @@ Separating_group_spanner::find_rods (Item * r, SCM next)
   */
   if (Separation_item::width (r).is_empty ())
     return; 
-  
-  for(; gh_pair_p (next); next = ly_cdr (next))
+
+
+  for (; scm_is_pair (next); next = scm_cdr (next))
     {
-      Item *l = dynamic_cast<Item*> (unsmob_grob (ly_car( next)));
+      Item *l = dynamic_cast<Item*> (unsmob_grob (scm_car ( next)));
       Item *lb = l->find_prebroken_piece (RIGHT);
 
       if (lb)
@@ -43,7 +45,7 @@ Separating_group_spanner::find_rods (Item * r, SCM next)
              rod.item_l_drul_[LEFT] = lb;
              rod.item_l_drul_[RIGHT] = r;
 
-             rod.distance_ = li[RIGHT] - ri[LEFT];
+             rod.distance_ = li[RIGHT] - ri[LEFT] + padding;
              rod.add_to_cols ();
            }
        }
@@ -54,10 +56,10 @@ Separating_group_spanner::find_rods (Item * r, SCM next)
        {
          Rod rod;
 
-         rod.item_l_drul_[LEFT] =l;
-         rod.item_l_drul_[RIGHT]=r;
+         rod.item_l_drul_[LEFT] = l;
+         rod.item_l_drul_[RIGHT]= r;
 
-         rod.distance_ = li[RIGHT] - ri[LEFT];
+         rod.distance_ = li[RIGHT] - ri[LEFT] + padding;
        
          rod.add_to_cols ();
          break;
@@ -71,27 +73,23 @@ Separating_group_spanner::find_rods (Item * r, SCM next)
     }
 }
 
-MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods_and_seqs,1);
-SCM
-Separating_group_spanner::set_spacing_rods_and_seqs (SCM smob)
-{
-  set_spacing_rods (smob);
-
-  return SCM_UNSPECIFIED;
-}
-
 MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods,1);
 SCM
 Separating_group_spanner::set_spacing_rods (SCM smob)
 {
   Grob*me = unsmob_grob (smob);
+
+  /*
+    Ugh: padding is added doubly, also for SeparationItem
+   */
+  Real padding = robust_scm2double (me->get_property ("padding"), 0.1);
   
-  for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s) && gh_pair_p (ly_cdr (s)); s = ly_cdr (s))
+  for (SCM s = me->get_property ("elements"); scm_is_pair (s) && scm_is_pair (scm_cdr (s)); s = scm_cdr (s))
     {
       /*
        Order of elements is reversed!
        */
-      SCM elt = ly_car (s);
+      SCM elt = scm_car (s);
       Item *r = unsmob_item (elt);
 
       if (!r)
@@ -100,9 +98,9 @@ Separating_group_spanner::set_spacing_rods (SCM smob)
       Item *rb
        = dynamic_cast<Item*> (r->find_prebroken_piece (LEFT));
       
-      find_rods (r, ly_cdr (s));
+      find_rods (r, scm_cdr (s), padding);
       if (rb)
-       find_rods (rb, ly_cdr (s));
+       find_rods (rb, scm_cdr (s), padding);
     }
 
   return SCM_UNSPECIFIED ;
@@ -120,5 +118,6 @@ Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i)
 
 
 ADD_INTERFACE (Separating_group_spanner,"separation-spanner-interface",
-  "Spanner that containing @code{separation-item-interface} grobs to calculate rods",
-  "");
+              "A spanner that calculates spacing constraints (\"rods\") "
+              "using the @code{separation-item-interface} grobs in @code{elements}.",
+              "elements padding");