]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / beam.cc
index 806130862c0f411f3ff39044046cdf04ed44beb9..cab9d8fdfc2a8cd34322864d529f2ba5ce35c5b3 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -140,13 +140,7 @@ Beam::calc_direction (SCM smob)
        }
       else
        {
-         /*
-           ugh.
-
-           can happen in stem-tremolo case.
-           TODO: fixme.
-          */
-         d = Stem::get_default_dir (stems[0]);
+         d = to_dir (stems[0]->get_property ("default-direction"));
        }
     }
 
@@ -538,7 +532,10 @@ Beam::get_default_dir (Grob *me)
       if (is_direction (stem_dir_scm))
        stem_dir = to_dir (stem_dir_scm);
       else
-       stem_dir = Stem::get_default_dir (s);
+       stem_dir = to_dir (s->get_property ("default-direction"));
+
+      if (!stem_dir)
+       stem_dir = to_dir (s->get_property ("neutral-direction"));
 
       if (stem_dir)
        {
@@ -548,12 +545,14 @@ Beam::get_default_dir (Grob *me)
     }
 
   Direction dir = CENTER;
-  
-  if (Direction d =  (Direction) sign (count[UP] - count[DOWN]))
+  Direction d = CENTER;
+  if ((d = (Direction) sign (count[UP] - count[DOWN])))
     dir = d;
-  else if (Direction d = (Direction)  sign (total[UP] / count[UP] - total[DOWN]/count[DOWN]))
+  else if (count[UP]
+          && count[DOWN]
+          && (d = (Direction)  sign (total[UP] / count[UP] - total[DOWN]/count[DOWN])))
     dir = d;
-  else if (Direction d = (Direction)  sign (total[UP] - total[DOWN]))
+  else if ((d = (Direction)  sign (total[UP] - total[DOWN])))
     dir = d;
   else
     dir = to_dir (me->get_property ("neutral-direction"));
@@ -1196,8 +1195,11 @@ Beam::forced_stem_count (Grob *me)
 
       /* I can imagine counting those boundaries as a half forced stem,
         but let's count them full for now. */
+      Direction defdir = to_dir (s->get_property ("default-direction"));
+      
       if (abs (Stem::chord_start_y (s)) > 0.1
-         && (get_grob_direction (s) != Stem::get_default_dir (s)))
+         && defdir
+         && get_grob_direction (s) != defdir)
        f++;
     }
   return f;
@@ -1287,9 +1289,9 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
 
   Drul_array<Grob*> visible_stems (first_visible_stem (beam),
                                   last_visible_stem (beam));
-                                   
-  Grob *common = visible_stems[RIGHT]
-    ->common_refpoint (visible_stems[LEFT], X_AXIS);
+  extract_grob_set (beam, "stems", stems);
+  
+  Grob *common = common_refpoint_of_array (stems, beam, X_AXIS);
   
   Real x0 = visible_stems[LEFT]->relative_coordinate (common, X_AXIS);
   Real dx = visible_stems[RIGHT]->relative_coordinate (common, X_AXIS) - x0;