]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/volta-spanner.cc
patch::: 1.1.30.mb1: Re: LilyPond 1.1.30
[lilypond.git] / lily / volta-spanner.cc
index d40848a56ea1c301a67e4ccf7b000a2a3fdae1aa..5162ac429c94bcb234a743c3c624c03517ea93dc 100644 (file)
@@ -3,71 +3,72 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "atom.hh"
+
 #include "box.hh"
 #include "debug.hh"
 #include "lookup.hh"
 #include "molecule.hh"
 #include "note-column.hh"
-#include "p-col.hh" // urg
-#include "bar.hh"
 #include "p-col.hh"
+#include "bar.hh"
 #include "paper-def.hh"
 #include "volta-spanner.hh"
 #include "stem.hh"
 #include "text-def.hh"
+#include "pointer.tcc"
 
-/*
-   Hmm, should probably make generic Bracket_spanner,
-   or and derive Plet and volta spanner from that.
- */
+template class P<Text_def>;            // UGH
 
 Volta_spanner::Volta_spanner ()
 {
-  dir_ = UP;
   last_b_ = false;
+  visible_b_ = true;
   number_p_.set_p (new Text_def);
   number_p_->align_dir_ = LEFT;
-  dot_p_.set_p (new Text_def);
-  dot_p_->align_dir_ = LEFT;
 }
 
 Molecule*
-Volta_spanner::brew_molecule_p () const
+Volta_spanner::do_brew_molecule_p () const
 {
   Molecule* mol_p = new Molecule;
 
-  if (column_arr_.size ())
-    {
-      Real internote_f = paper ()->internote_f ();
-      Real dx = internote_f;
-      Real w = width ().length () - 2 * dx;
-      Atom volta (lookup_l ()->volta (w, last_b_));
-      Real h = volta.dim_.y ().length ();
-      Atom num (number_p_->get_atom (paper (), LEFT));
-      Atom dot (dot_p_->get_atom (paper (), LEFT));
-      Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_] > 
-       column_arr_[0]->extent (Y_AXIS) [dir_];
-      dy += 2 * h;
-      for (int i = 0; i < note_column_arr_.size (); i++)
-        dy = dy >? note_column_arr_[i]->height ().max ();
-      dy -= h;
-
-      Real gap = num.dim_.x ().length () / 2;
-      Offset off (num.dim_.x ().length () + gap, 
-        (h - num.dim_.y ().length ()) / internote_f - gap);
-      num.translate (off);
-      Real dotheight = dot.dim_.y ().length () / 7;
-      off -= Offset (0, dotheight);
-      dot.translate (off);
-      mol_p->add_atom (volta);
-      mol_p->add_atom (num);
-      mol_p->add_atom (dot);
-      mol_p->translate (Offset (dx, dy));
-    }
+  if (!column_arr_.size ())
+    return mol_p;
+
+  if (!visible_b_)
+    return mol_p;
+
+  Real internote_f = paper ()->internote_f ();
+  Real dx = internote_f;
+  Real w = extent (X_AXIS).length () - dx;
+  Molecule volta (lookup_l ()->volta (w, last_b_));
+  Real h = volta.dim_.y ().length ();
+  Molecule num (number_p_->get_molecule (paper (), LEFT));
+  Real dy = column_arr_.top ()->extent (Y_AXIS) [UP] > 
+     column_arr_[0]->extent (Y_AXIS) [UP];
+  dy += 2 * h;
+
+  /*
+    UGH.  Must use extent  ()[dir_]
+   */
+  for (int i = 0; i < note_column_arr_.size (); i++)
+    dy = dy >? note_column_arr_[i]->extent (Y_AXIS).max ();
+  dy -= h;
+
+  Text_def two_text;
+  two_text.text_str_ = "2";
+  two_text.style_str_ = number_p_->style_str_;
+  Molecule two (two_text.get_molecule (paper (), LEFT));
+  Real gap = two.dim_.x ().length () / 2;
+  Offset off (num.dim_.x ().length () + gap, 
+             h / internote_f - gap);
+  num.translate (off);
+  mol_p->add_molecule (volta);
+  mol_p->add_molecule (num);
+  mol_p->translate (Offset (0, dy));
   return mol_p;
 }
   
@@ -79,16 +80,26 @@ Volta_spanner::do_add_processing ()
       set_bounds (LEFT, column_arr_[0]);
       set_bounds (RIGHT, column_arr_.top ());  
     }
-  number_p_->style_str_ = "number-1";
-  dot_p_->text_str_ = ".";
-  dot_p_->style_str_ = "bold";
+
+  // number_p_->style_str_ = "number-1";
+  number_p_->style_str_ = "volta";
 }
   
+Interval
+Volta_spanner::do_height () const
+{
+  /*
+    in most cases, it's a lot better not no have height...
+  */
+  Interval i;
+  return i;
+}
+
 void
 Volta_spanner::do_post_processing ()
 {
-    if (column_arr_.size())
-       translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS);
+  if (column_arr_.size())
+    translate_axis (column_arr_[0]->extent (Y_AXIS)[UP], Y_AXIS);
 }
 
 void