]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-bar.cc
release: 1.1.34
[lilypond.git] / lily / span-bar.cc
index fab0b28aaafd37ca8793d3d365b99e18247a62a2..67d1e2ea9230b02cf73390d5a16c579fcf2f4baf 100644 (file)
@@ -3,26 +3,26 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "span-bar.hh"
 #include "lookup.hh"
 #include "dimensions.hh"
-#include "atom.hh"
 #include "paper-def.hh"
 #include "molecule.hh"
 #include "align-element.hh"
+#include "warn.hh"
 
 void
-Span_bar::add_bar (Bar*b)
+Span_bar::add_bar (Score_element*b)
 {
   spanning_l_arr_.push (b);
   add_dependency (b);
 }
 
 void
-Span_bar::do_substitute_dependency (Score_element*o, Score_element*n)
+Span_bar::do_substitute_element_pointer (Score_element*o, Score_element*n)
 {
   spanning_l_arr_.unordered_substitute (o, n);
 }
@@ -47,6 +47,9 @@ 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.
 }
 
 void
@@ -82,17 +85,8 @@ Span_bar::evaluate_empty ()
     }
 }
 
-Molecule
-Span_bar::get_bar_sym (Real dy) const
-{
-  if (dy < paper ()->staffheight_f () / 2)
-    return Atom ();
-  
-  return lookup_l ()->bar (type_str_, dy);
-}
-
-Molecule*
-Span_bar::do_brew_molecule_p () const
+Interval
+Span_bar::get_spanned_interval () const
 {
   Interval y_int;
   for (int i=0; i < spanning_l_arr_.size (); i++) 
@@ -105,9 +99,29 @@ Span_bar::do_brew_molecule_p () const
 
       y_int.unite (y + spanning_l_arr_[i]->extent(Y_AXIS));
     }
+  return y_int;
+}
+
+Interval
+Span_bar::do_height () const
+{
+  return get_spanned_interval ();
+}
 
-  Molecule*output = new Molecule (get_bar_sym (y_int.length ()));
-  output->translate_axis (y_int.center (), Y_AXIS);
+Molecule*
+Span_bar::do_brew_molecule_p () const
+{
+  Interval iv (get_spanned_interval ());
+  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);
+    }
+  else
+    {
+      warning("Huh? My children deflated (FIXME)");
+    }
   return output;
 }
 
@@ -116,4 +130,5 @@ Span_bar::do_brew_molecule_p () const
 Span_bar::Span_bar ()
 {
   type_str_ = "";
+  extra_x_off_ = 0.0;
 }