]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/multi-measure-rest.cc
release: 1.1.28
[lilypond.git] / lily / multi-measure-rest.cc
index 6bb3a5a6e48f868dabe74595a3f989a44514ebbe..12b66ee7742fd459b95844b3b448e96f51d79ba3 100644 (file)
@@ -3,13 +3,15 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1998, 1999 Jan Nieuwenhuizen <janneke@gnu.org>
   
  */
 
 #include "multi-measure-rest.hh"
 #include "debug.hh"
 #include "paper-def.hh"
+#include "p-col.hh" // urg
+#include "bar.hh"
 #include "lookup.hh"
 #include "rest.hh"
 #include "script.hh"
@@ -33,20 +35,26 @@ Molecule*
 Multi_measure_rest::do_brew_molecule_p () const
 {
   /*
-   [TODO]                                     3
-     * make real multi-measure rest symbol: |---|
-     * make two,four,eight-measure-rest symbols
+   [TODO]                                          17
+     * variable-sized multi-measure rest symbol: |====| ??
+     * build 3, 5, 6, 7, 8 symbols (how far, property?)
+       from whole, brevis and longa rests
    */
-  Atom s;
+  Molecule* mol_p = new Molecule;
+  if (!column_arr_.size ())
+    return mol_p;
+
+  Molecule s;
   if (measures_i_ == 1 || measures_i_ == 2 || measures_i_ == 4) 
     {
       s = (lookup_l ()->rest (- intlog2(measures_i_), 0));
+      s.translate_axis (-s.extent ()[X_AXIS].length () / 2, X_AXIS);
     }
   else 
     {
       s = (lookup_l ()->rest (-4, 0));
     }
-  Molecule* mol_p = new Molecule ( Atom (s));
+  mol_p->add_molecule (s);
   Real interline_f = paper ()->interline_f ();
   if (measures_i_ == 1)
     {
@@ -59,11 +67,42 @@ Multi_measure_rest::do_brew_molecule_p () const
       text.text_str_ = to_str (measures_i_);
       text.style_str_ = "number";
       text.align_dir_ = CENTER;
-      Atom s = text.get_atom (paper (), UP);
+      Molecule s = text.get_molecule (paper (), UP);
       s.translate_axis (3.0 * interline_f, Y_AXIS);
-      mol_p->add_atom (s);
+      mol_p->add_molecule (s);
     }
 
   return mol_p;
 }
 
+void
+Multi_measure_rest::do_add_processing ()
+{
+  if (column_arr_.size ())
+    {
+      set_bounds (LEFT, column_arr_[0 >? column_arr_.size () - 2]);
+      set_bounds (RIGHT, column_arr_[column_arr_.size () - 1]);
+    }
+}
+  
+void
+Multi_measure_rest::do_post_processing ()
+{
+  if (column_arr_.size ())
+    translate_axis (extent (X_AXIS).length () / 2, X_AXIS);
+}
+
+void
+Multi_measure_rest::do_substitute_dependency (Score_element* o, Score_element* n)
+{
+  if (Bar* c = dynamic_cast <Bar*> (o))
+    column_arr_.substitute (c, dynamic_cast<Bar*> (n));
+}
+  
+void
+Multi_measure_rest::add_column (Bar* c)
+{
+  column_arr_.push (c);
+  add_dependency (c);
+}
+