]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
release: 1.2.8
[lilypond.git] / lily / beam.cc
index 43975b65dc62e8c2ff64296ac93b6e2ca71232b4..22735719719340c4a64759ffc79b7e4994a74266 100644 (file)
@@ -24,7 +24,8 @@ needs what, and what information should be available when.
 
 #include <math.h>
 
-#include "new-beaming.hh"
+#include "chord-tremolo.hh"
+#include "beaming.hh"
 #include "proto.hh"
 #include "dimensions.hh"
 #include "beam.hh"
@@ -48,9 +49,14 @@ void
 Beam::add_stem (Stem*s)
 {
 #if 0
+  /*
+    should figure out why this didn't work.
+
+    --hwn.
+   */
   if (!stems_.size ())
     {
-      dim_cache_[Y_AXIS]->parent_l_ = s->dim_cache_[Y_AXIS];
+      set_parent (s, Y_AXIS);
     }
 #endif
   stems_.push (s);
@@ -99,7 +105,7 @@ Beam::do_brew_molecule_p () const
       mol_p->add_molecule (sb);
     }
   mol_p->translate_axis (x0 
-    - spanned_drul_[LEFT]->absolute_coordinate (X_AXIS), X_AXIS);
+    - spanned_drul_[LEFT]->relative_coordinate (0, X_AXIS), X_AXIS);
 
   return mol_p;
 }
@@ -170,7 +176,6 @@ Beam::get_default_dir () const
   count[UP]  = count[DOWN] = 0;
   Direction d = DOWN;
 
-  Direction beamdir;
   for (int i=0; i <stems_.size (); i++)
     do {
       Stem *s = stems_[i];
@@ -198,28 +203,38 @@ Beam::get_default_dir () const
      If dir is not determined: up (see stem::get_default_dir ())
   */
 
+  Direction beam_dir;
+  Direction neutral_dir = (Direction)(int)paper_l ()->get_var ("stem_default_neutral_direction");
+
   Dir_algorithm a = (Dir_algorithm)rint(paper_l ()->get_var ("beam_dir_algorithm"));
   switch (a)
     {
     case MAJORITY:
-      beamdir = (count[UP] >= count[DOWN]) ? UP : DOWN;
+      beam_dir = (count[UP] == count[DOWN]) ? neutral_dir 
+        : (count[UP] > count[DOWN]) ? UP : DOWN;
       break;
     case MEAN:
       // mean center distance
-      beamdir = (total[UP] >= total[DOWN]) ? UP : DOWN;
+      beam_dir = (total[UP] == total[DOWN]) ? neutral_dir
+        : (total[UP] > total[DOWN]) ? UP : DOWN;
       break;
     default:
     case MEDIAN:
       // median center distance
-      if (!count[DOWN])
-       beamdir = UP;
-      if (!count[UP])
-       beamdir = DOWN;
+      if (!count[DOWN] || !count[UP])
+        {
+         beam_dir = (count[UP] == count[DOWN]) ? neutral_dir 
+           : (count[UP] > count[DOWN]) ? UP : DOWN;
+       }
       else
-       beamdir = (total[UP] / count[UP] >= total[DOWN] / count[DOWN]) ? UP : DOWN;
+        {
+         beam_dir = (total[UP] / count[UP] == total[DOWN] / count[DOWN]) 
+           ? neutral_dir 
+             : (total[UP] / count[UP] > total[DOWN] / count[DOWN]) ? UP : DOWN;
+       }
       break;
     }
-  return beamdir;
+  return beam_dir;
 }
 
 void
@@ -294,8 +309,8 @@ Beam::check_stemlengths_f (bool set_b)
        { 
          // when all too short, normal stems win..
          if (dy_f < -epsilon_f)
-           warning (_ ("weird beam shift, check your knees"));
-         dy_f = dy_f >? sinfo_[i].miny_f_ - y;
+           warning (_ ("weird beam vertical offset"));
+         dy_f = dy_f >? sinfo_[i].miny_f_ - y; 
        }
     }
   return dy_f;
@@ -332,8 +347,14 @@ Beam::set_steminfo ()
   for (int i=0; i < stems_.size (); i++)
     {
       Stem *s = stems_[i];
-      if (s->invisible_b ())
-       continue;
+      /*
+       Chord tremolo needs to beam over invisible stems of wholes
+      */
+      if (!dynamic_cast<Chord_tremolo*> (this))
+       {
+         if (s->invisible_b ())
+           continue;
+       }
 
       Stem_info info (s, multiple_i_);
       if (leftx == 0)
@@ -654,7 +675,15 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
   Molecule rightbeams;
 
   // UGH
-  Real nw_f = paper_l ()->note_width () * 0.8;
+  Real nw_f;
+  if (!here->head_l_arr_.size ())
+    nw_f = 0;
+  else if (here->type_i ()== 1)
+    nw_f = paper_l ()->get_var ("wholewidth");
+  else if (here->type_i () == 2)
+    nw_f = paper_l ()->note_width () * 0.8;
+  else
+    nw_f = paper_l ()->get_var ("quartwidth");
 
   /* half beams extending to the left. */
   if (prev)
@@ -693,7 +722,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
       SCM gap = get_elt_property (beam_gap_scm_sym);
       if (gap != SCM_BOOL_F)
        {
-         int gap_i = gh_scm2int (gap);
+         int gap_i = gh_scm2int (SCM_CDR (gap));
          int nogap = rwholebeams - gap_i;
          
          for (; j  < nogap; j++)
@@ -711,7 +740,10 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
       for (; j  < rwholebeams; j++)
        {
          Molecule b (a);
-         b.translate (Offset (gap_f, -dir_ * dy * j));
+         if (!here->invisible_b ())
+           b.translate (Offset (gap_f, -dir_ * dy * j));
+         else
+           b.translate (Offset (0, -dir_ * dy * j));
          rightbeams.add_molecule (b);
        }