]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/separating-group-spanner.cc
release: 1.3.53
[lilypond.git] / lily / separating-group-spanner.cc
index 41c2c515e6304eb9b9210b6fd8228fd708839f12..295bef4824fa866176c26ac6224b0a8dc1add831 100644 (file)
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "separating-group-spanner.hh"
 #include "single-malt-grouping-item.hh"
-#include "p-col.hh"
+#include "paper-column.hh"
 #include "paper-def.hh"
+#include "dimensions.hh"
+
+static Rod
+make_rod (Single_malt_grouping_item *l, Single_malt_grouping_item *r)
+{
+  Rod rod;
+
+  Interval li (l->my_width ());
+  Interval ri (r->my_width ());
+
+  rod.item_l_drul_[LEFT] =l;
+  rod.item_l_drul_[RIGHT]=r;
+
+  if (li.empty_b () || ri.empty_b ())
+    rod.distance_f_ = 0;
+  else
+    rod.distance_f_ = li[RIGHT] - ri[LEFT];
+
+  rod.columnize ();
+  return rod;
+}
+  
 
 Array<Rod>
 Separating_group_spanner::get_rods () const
 {
   Array<Rod> a;
   
-  for (int i=0; i < spacing_unit_l_arr_.size () -1; i++)
+  for (SCM s = get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s))
     {
-      Single_malt_grouping_item *l =spacing_unit_l_arr_[i];
+      /*
+       Order of elements is reversed!
+       */
+      SCM elt = gh_cadr (s);
+      SCM next_elt = gh_car (s);
+
+      Single_malt_grouping_item *l = dynamic_cast<Single_malt_grouping_item*> (unsmob_element (elt));
+      Single_malt_grouping_item *r = dynamic_cast<Single_malt_grouping_item*> (unsmob_element ( next_elt));
+
+      if (!r || !l)
+       continue;
+      
       Single_malt_grouping_item *lb
        = dynamic_cast<Single_malt_grouping_item*>(l->find_prebroken_piece (RIGHT));
-      Single_malt_grouping_item *r = spacing_unit_l_arr_[i+1];
+
       Single_malt_grouping_item *rb
        = dynamic_cast<Single_malt_grouping_item*>(r->find_prebroken_piece (LEFT));
       
-      a.push (Rod (spacing_unit_l_arr_[i], spacing_unit_l_arr_[i+1]));
+      a.push (make_rod(l,  r));
       if (lb)
        {
-         Rod rod(lb, r);
-         rod.distance_f_ += paper ()->interline_f () *1.5;
+         Rod rod(make_rod (lb, r));
          a.push (rod);
        }
       
       if (rb)
        {
-         a.push (Rod (l, rb));
+         a.push (make_rod (l, rb));
        }
+      
       if (lb && rb)
        {
-         Rod rod(lb, rb);
-         rod.distance_f_ += paper ()->interline_f () *1.5;
+         Rod rod(make_rod (lb, rb));
          a.push (rod);
        }
     }
-      
+
+  /*
+    We've done our job, so we get lost. 
+   */
+  for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
+    {
+      Item * it =dynamic_cast<Item*>(unsmob_element (gh_car (s)));
+      if (it && it->broken_b ())
+       {
+         it->find_prebroken_piece (LEFT) ->suicide ();
+         it->find_prebroken_piece (RIGHT)->suicide ();
+       }
+      it->suicide ();
+    }
+  
+  ((Separating_group_spanner *)this)->suicide ();
+  
   return a;
 }
 
 void
 Separating_group_spanner::add_spacing_unit (Single_malt_grouping_item*i)
 {
-  spacing_unit_l_arr_.push (i);
+  set_elt_property ("elements",
+                   gh_cons (i->self_scm_,
+                            get_elt_property ("elements")));
   add_dependency (i);
 }
 
 
-
-void
-Separating_group_spanner::do_substitute_dependency (Score_element*o, Score_element*n)
+Separating_group_spanner::Separating_group_spanner ()
 {
-  if (dynamic_cast<Single_malt_grouping_item *> (o))
-    {
-      Single_malt_grouping_item*ns = dynamic_cast<Single_malt_grouping_item *> (n);
-      spacing_unit_l_arr_.substitute (dynamic_cast<Single_malt_grouping_item *> (o), ns);
-    }
+  set_elt_property ("elements", SCM_EOL);
 }
-