]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-bar.cc
release: 1.2.4
[lilypond.git] / lily / span-bar.cc
index 73944e140cd35e8e4809069d479768d5fba88371..02c7c29e3b13826b8dc4fc6b957f48a3504befdf 100644 (file)
@@ -5,7 +5,7 @@
 
   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
-
+#include "dimension-cache.hh"
 #include "span-bar.hh"
 #include "lookup.hh"
 #include "dimensions.hh"
@@ -27,16 +27,11 @@ Span_bar::do_substitute_element_pointer (Score_element*o, Score_element*n)
   spanning_l_arr_.unordered_substitute (o, n);
 }
 
-void
-Span_bar::set_align (Align_element *a)
-{
-  add_dependency (a);
-}
 
 Interval
 Span_bar::do_width () const
 {
-  Molecule m = lookup_l ()->bar (type_str_, 40 PT);
+  Molecule m = lookup_l ()->bar (type_str_, 40 PT, paper_l ());
   
   return m.extent (X_AXIS);
 }
@@ -47,15 +42,17 @@ Span_bar::do_pre_processing ()
   Bar::do_pre_processing ();
   
   evaluate_empty ();
-  translate_axis (extra_x_off_, X_AXIS);
   
-  dim_cache_[Y_AXIS].set_empty (false); // a hack to make mark scripts work.
+  set_empty (false, Y_AXIS); // a hack to make mark scripts work.
 }
 
 void
 Span_bar::do_post_processing ()
 {
   Bar::do_post_processing ();
+  Interval i(get_spanned_interval ());
+
+  translate_axis (i.center (), Y_AXIS);
 }
 
 void
@@ -64,7 +61,8 @@ Span_bar::evaluate_empty ()
   if (spanning_l_arr_.size () < 1) 
     {
       set_elt_property (transparent_scm_sym, SCM_BOOL_T);
-      set_empty (true);   
+      set_empty (true, X_AXIS, Y_AXIS);   
+
     }
   if (type_str_.empty_b ()) 
     {
@@ -89,13 +87,12 @@ Interval
 Span_bar::get_spanned_interval () const
 {
   Interval y_int;
+
   for (int i=0; i < spanning_l_arr_.size (); i++) 
     {
-      Dimension_cache*common = 
-       common_group (spanning_l_arr_[i], Y_AXIS);
-       
-      Real y = spanning_l_arr_[i]->dim_cache_[Y_AXIS].relative_coordinate (common)  
-       -dim_cache_[Y_AXIS].relative_coordinate (common);
+      Graphical_element*common = common_refpoint (spanning_l_arr_[i], 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]->extent(Y_AXIS));
     }
@@ -115,12 +112,11 @@ Span_bar::do_brew_molecule_p () const
   Molecule*output = new Molecule;
   if (!iv.empty_b())
     {
-      output->add_molecule (lookup_l ()->bar (type_str_, iv.length ()));
-      output->translate_axis (iv.center (), Y_AXIS);
+      output->add_molecule (lookup_l ()->bar (type_str_, iv.length (), paper_l ()));
     }
   else
     {
-      warning("Huh? My children deflated (FIXME)");
+      programming_error("Huh? My children deflated (FIXME)");
     }
   return output;
 }
@@ -130,5 +126,4 @@ Span_bar::do_brew_molecule_p () const
 Span_bar::Span_bar ()
 {
   type_str_ = "";
-  extra_x_off_ = 0.0;
 }