]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
patch::: 1.1.31.jcn1: Re: LilyPond 1.1.30
[lilypond.git] / lily / beam.cc
index 6e2e3b4641e778d6b0cc4f3e685c1f99f313c31b..429970ac0cab1558026e0f061ccb26d363a885dc 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998, 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999, 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 
 */
 #include "abbreviation-beam.hh"
 #include "misc.hh"
 #include "debug.hh"
-#include "atom.hh"
+
 #include "molecule.hh"
 #include "leastsquares.hh"
 #include "stem.hh"
 #include "paper-def.hh"
 #include "lookup.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 
 Beam::Beam ()
 {
@@ -41,6 +41,8 @@ Beam::Beam ()
   damping_i_ = 1;
   quantisation_ = NORMAL;
   multiple_i_ = 0;
+  vertical_align_drul_[MIN] = 0;
+  vertical_align_drul_[MAX] = -1;
 }
 
 void
@@ -77,6 +79,10 @@ Beam::do_brew_molecule_p () const
   mol_p->translate_axis (x0 
     - spanned_drul_[LEFT]->absolute_coordinate (X_AXIS), X_AXIS);
 
+  // correct if last note (and therefore reference point of beam)
+  // is on different staff
+  mol_p->translate_axis (- sinfo_.top ().interstaff_f_ * internote_f, Y_AXIS);
+
   return mol_p;
 }
 
@@ -229,13 +235,20 @@ Beam::check_stemlengths_f (bool set_b)
   for (int i=0; i < sinfo_.size (); i++)
     {
       Real y = sinfo_[i].x_ * slope_f_ + left_y_;
+
       // correct for knee
       if (dir_ != sinfo_[i].dir_)
-       y -= dir_ * (beam_f / 2
-                     + (sinfo_[i].mult_i_ - 1) * interbeam_f) / internote_f;
+       {
+         y -= dir_ * (beam_f / 2
+                      + (sinfo_[i].mult_i_ - 1) * interbeam_f) / internote_f;
+         if (!i && sinfo_[i].stem_l_->staff_sym_l_ !=
+             sinfo_.top ().stem_l_->staff_sym_l_)
+           y += dir_ * (multiple_i_ - (sinfo_[i].stem_l_->flag_i_ - 2) >? 0)
+             * interbeam_f / internote_f;
+       }
 
       if (set_b)
-       sinfo_[i].stem_l_->set_stemend (y);
+       sinfo_[i].stem_l_->set_stemend (y - sinfo_[i].interstaff_f_);
        
       y *= dir_;
       if (y > sinfo_[i].maxy_f_)
@@ -616,15 +629,15 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
        */
       Real w = here->hpos_f () - prev->hpos_f ();
       w = w/2 <? nw_f;
-      Atom a;
+      Molecule a;
       if (lhalfs)              // generates warnings if not
        a =  lookup_l ()->beam (sl, w, beam_f);
       a.translate (Offset (-w, -w * sl));
       for (int j = 0; j  < lhalfs; j++)
        {
-         Atom b (a);
+         Molecule b (a);
          b.translate_axis (-dir_ * dy * (lwholebeams+j), Y_AXIS);
-         leftbeams.add_atom (b);
+         leftbeams.add_molecule (b);
        }
     }
 
@@ -634,7 +647,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
       int rwholebeams = here->beams_i_drul_[RIGHT] <? next->beams_i_drul_[LEFT];
 
       Real w = next->hpos_f () - here->hpos_f ();
-      Atom a = lookup_l ()->beam (sl, w + stemdx, beam_f);
+      Molecule a = lookup_l ()->beam (sl, w + stemdx, beam_f);
       a.translate_axis( - stemdx/2, X_AXIS);
       int j = 0;
       Real gap_f = 0;
@@ -643,9 +656,9 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
          int nogap = rwholebeams - here->beam_gap_i_;
          for (; j  < nogap; j++)
            {
-             Atom b (a);
+             Molecule b (a);
              b.translate_axis (-dir_ * dy * j, Y_AXIS);
-             rightbeams.add_atom (b);
+             rightbeams.add_molecule (b);
            }
          // TODO: notehead widths differ for different types
          gap_f = nw_f / 2;
@@ -655,9 +668,9 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
 
       for (; j  < rwholebeams; j++)
        {
-         Atom b (a);
+         Molecule b (a);
          b.translate (Offset (gap_f, -dir_ * dy * j));
-         rightbeams.add_atom (b);
+         rightbeams.add_molecule (b);
        }
 
       w = w/2 <? nw_f;
@@ -666,9 +679,9 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
 
       for (; j  < rwholebeams + rhalfs; j++)
        {
-         Atom b (a);
+         Molecule b (a);
          b.translate_axis (-dir_ * dy * j, Y_AXIS);
-         rightbeams.add_atom (b);
+         rightbeams.add_molecule (b);
        }
 
     }