]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
2003 -> 2004
[lilypond.git] / lily / stem.cc
index a8d9f390e2f1ebeeb8e991d437c3d150debd20e0..49c907879e1a19f609eb3945fbe401c81db6554d 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 
   TODO: This is way too hairy
@@ -462,13 +462,17 @@ Stem::position_noteheads (Grob*me)
     }
   
   bool parity= true;
-  int lastpos = int (Staff_symbol_referencer::get_position (heads[0]));
+  Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0]));
   for (int i=1; i < heads.size (); i ++)
     {
       Real p = Staff_symbol_referencer::get_position (heads[i]);
-      int dy =abs (lastpos- (int)p);
+      Real dy =fabs (lastpos- p);
 
-      if (dy <= 1)
+      /*
+       dy should always be 0.5, 0.0, 1.0, but provide safety margin
+       for rounding errors.
+      */
+      if (dy < 1.1)            
        {
          if (parity)
            {
@@ -847,7 +851,7 @@ Stem::calc_stem_info (Grob *me)
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Grob *beam = get_beam (me);
   Real beam_translation = Beam::get_beam_translation (beam);
-  Real beam_thickness = robust_scm2double (beam->get_grob_property ("thickness"), 1);
+  Real beam_thickness = Beam::get_thickness (beam);
   int beam_count = Beam::get_direction_beam_count (beam, my_dir);
 
 
@@ -889,7 +893,7 @@ Stem::calc_stem_info (Grob *me)
   Real note_start =
     /* staff positions */
     head_positions (me)[my_dir] * 0.5
-    * my_dir;
+    * my_dir * staff_space;
   Real ideal_y = note_start + ideal_length;
 
 
@@ -973,3 +977,18 @@ ADD_INTERFACE (Stem,"stem-interface",
               "no-stem-extend stroke-style");
 
 
+
+/****************************************************************/
+
+Stem_info::Stem_info()
+{
+  ideal_y_ = shortest_y_ =0;
+  dir_ = CENTER;
+}
+
+void
+Stem_info::scale (Real x)
+{
+  ideal_y_ *= x;
+  shortest_y_ *= x;
+}