]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-bar.cc
release: 0.1.59
[lilypond.git] / lily / span-bar.cc
index 5f19f84177b93538ac1e13d3c2f89d86efcb698c..a371dc019d312527a0ccf65250ea5acfeedeeb57 100644 (file)
@@ -9,7 +9,7 @@
 #include "dimen.hh"
 #include "span-bar.hh"
 #include "lookup.hh"
-#include "symbol.hh"
+#include "atom.hh"
 #include "paper-def.hh"
 #include "molecule.hh"
 #include "vertical-align-elem.hh"
@@ -17,7 +17,6 @@
 void
 Span_bar::add (Bar*b)
 {
-  b->spanned_i_ ++;
   spanning_l_arr_.push (b);
   add_dependency (b);
 }
@@ -27,21 +26,7 @@ Span_bar::add (Bar*b)
 void
 Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
 {
-  Bar * bold = 0;
-  if  (o->is_type_b (Bar::static_name())) 
-       bold = (Bar*)o->item();
-  else
-       return;
-
-  bold->spanned_i_ --;
-  Bar * b =0;
-  if (n && n->is_type_b (Bar::static_name())) 
-    {
-       b = (Bar*)n->item();
-       b->spanned_i_ ++;
-    }
-  
-  spanning_l_arr_.substitute (bold , b);
+  spanning_l_arr_.unordered_substitute (o, n);
 }
 
 
@@ -55,37 +40,35 @@ Span_bar::set (Vertical_align_element *a)
 Interval
 Span_bar::do_width() const
 {
-  return paper()->lookup_l ()->bar (type_str_, 40 PT).dim.x (); // ugh
+  return paper()->lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
 }
+
 void
 Span_bar::do_pre_processing()
 {
+  Bar::do_pre_processing ();
+  
   if (spanning_l_arr_.size() < 1) 
     {
-       transparent_b_ = true;
-       empty_b_ =true;
+      transparent_b_ = true;
+      set_empty (true);   
+    }
+  if (type_str_.empty_b ()) 
+    {
+      transparent_b_=true;
+      set_empty (true);
+    }
+  else if (type_str_ == "|:") 
+    {
+      type_str_ = ".|";
     }
-  else 
+  else if (type_str_ == ":|")
     {
-       if (type_str_ == "")
-           type_str_ = spanning_l_arr_[0]->type_str_;
-       if (type_str_ =="") 
-         {
-           transparent_b_=true;
-           empty_b_ = true;
-         }
-       else if (type_str_ == "|:") 
-         {
-           type_str_ = ".|";
-         }
-       else if (type_str_ == ":|")
-         {
-           type_str_ = "|.";
-         }
+      type_str_ = "|.";
     }
 }
 
-Symbol
+Atom
 Span_bar::get_bar_sym (Real dy) const
 {
   return paper()->lookup_l ()->bar (type_str_, dy);
@@ -98,18 +81,18 @@ Span_bar::brew_molecule_p() const
   Interval y_int;
   for (int i=0; i < spanning_l_arr_.size(); i++) 
     {
-       Axis_group_element *common = 
-           common_group (spanning_l_arr_[i], Y_AXIS);
+      Axis_group_element *common = 
+       common_group (spanning_l_arr_[i], Y_AXIS);
        
-       Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
-           -relative_coordinate (common,Y_AXIS);
+      Real y = spanning_l_arr_[i]->relative_coordinate (common, Y_AXIS)  
+       -relative_coordinate (common,Y_AXIS);
 
-       y_int.unite (y + spanning_l_arr_[i]->height());
+      y_int.unite (y + spanning_l_arr_[i]->height());
     }
 
-  Symbol s = get_bar_sym (y_int.length());
+  Atom s = get_bar_sym (y_int.length());
   Molecule*output = new Molecule (Atom (s));
-  output->translate (y_int[-1], Y_AXIS);
+  output->translate_axis (y_int.center(), Y_AXIS);
   return output;
 }