]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/span-bar.cc
release: 1.1.28
[lilypond.git] / lily / span-bar.cc
index a371dc019d312527a0ccf65250ea5acfeedeeb57..f2ea6a5a71248fbd6300e3e524f64046e4fed8f0 100644 (file)
@@ -3,52 +3,70 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "dimen.hh"
 #include "span-bar.hh"
 #include "lookup.hh"
-#include "atom.hh"
+#include "dimensions.hh"
+
 #include "paper-def.hh"
 #include "molecule.hh"
-#include "vertical-align-elem.hh"
+#include "align-element.hh"
 
 void
-Span_bar::add (Bar*b)
+Span_bar::add_bar (Bar*b)
 {
   spanning_l_arr_.push (b);
   add_dependency (b);
 }
 
-
-
 void
-Span_bar::do_substitute_dependency (Score_elem*o, Score_elem*n)
+Span_bar::do_substitute_dependency (Score_element*o, Score_element*n)
 {
   spanning_l_arr_.unordered_substitute (o, n);
 }
 
-
 void
-Span_bar::set (Vertical_align_element *a)
+Span_bar::set_align (Align_element *a)
 {
   add_dependency (a);
 }
-  
 
 Interval
-Span_bar::do_width() const
+Span_bar::do_width () const
 {
-  return paper()->lookup_l ()->bar (type_str_, 40 PT).dim_.x (); // ugh
+  if (no_width_b_)
+    {
+      return Interval (0,0);
+    }
+  
+  Molecule m = lookup_l ()->bar (type_str_, 40 PT);
+  
+  return m.extent (X_AXIS);
 }
 
 void
-Span_bar::do_pre_processing()
+Span_bar::do_pre_processing ()
 {
   Bar::do_pre_processing ();
   
-  if (spanning_l_arr_.size() < 1) 
+  evaluate_empty ();
+  translate_axis (extra_x_off_, X_AXIS);
+  
+  dim_cache_[Y_AXIS].set_empty (false); // a hack to make mark scripts work.
+}
+
+void
+Span_bar::do_post_processing ()
+{
+  Bar::do_post_processing ();
+}
+
+void
+Span_bar::evaluate_empty ()
+{ 
+  if (spanning_l_arr_.size () < 1) 
     {
       transparent_b_ = true;
       set_empty (true);   
@@ -66,40 +84,50 @@ Span_bar::do_pre_processing()
     {
       type_str_ = "|.";
     }
+  else if (type_str_ == ":|:")
+    {
+      type_str_ = ".|.";
+    }
 }
 
-Atom
-Span_bar::get_bar_sym (Real dy) const
-{
-  return paper()->lookup_l ()->bar (type_str_, dy);
-}
-
-
-Molecule*
-Span_bar::brew_molecule_p() const
+Interval
+Span_bar::get_spanned_interval () const
 {
   Interval y_int;
-  for (int i=0; i < spanning_l_arr_.size(); i++) 
+  for (int i=0; i < spanning_l_arr_.size (); i++) 
     {
-      Axis_group_element *common = 
+      Dimension_cache*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]->dim_cache_[Y_AXIS].relative_coordinate (common)  
+       -dim_cache_[Y_AXIS].relative_coordinate (common);
 
-      y_int.unite (y + spanning_l_arr_[i]->height());
+      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*
+Span_bar::do_brew_molecule_p () const
+{
+  Interval iv (get_spanned_interval ());
+  Molecule*output = new Molecule (lookup_l ()->bar (type_str_, iv.length ()));
 
-  Atom s = get_bar_sym (y_int.length());
-  Molecule*output = new Molecule (Atom (s));
-  output->translate_axis (y_int.center(), Y_AXIS);
+  output->translate_axis (iv.center (), Y_AXIS);
   return output;
 }
 
 
-IMPLEMENT_IS_TYPE_B1(Span_bar,Bar);
 
-Span_bar::Span_bar()
+Span_bar::Span_bar ()
 {
   type_str_ = "";
+  extra_x_off_ = 0.0;
+  no_width_b_ = false;
 }