]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of ssh://hanwen@git.sv.gnu.org/srv/git/lilypond
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 29 Jul 2007 16:03:58 +0000 (09:03 -0700)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 29 Jul 2007 16:03:58 +0000 (09:03 -0700)
lily/beam-quanting.cc
lily/beam.cc
lily/include/beam.hh

index a40621e61ba84d471841ed7b2ec6cb78427bebc3..ebda6eb256fe484354feb94add3a4a979932198f 100644 (file)
@@ -179,7 +179,7 @@ Beam::quanting (SCM smob, SCM posns)
 
       if (Stem::is_normal_stem (s))
        {
-         base_lengths.push_back (calc_stem_y (me, s, common, xl, xr,
+         base_lengths.push_back (calc_stem_y (me, s, common, xl, xr, CENTER, 
                                               Interval (0, 0), f) / ss);
        }
       else
index 183a936440ff12fe7038025671431264a7ae7ae3..0d83aefb77da09a97a9b0e38cdfc732464ba4a37 100644 (file)
@@ -1132,36 +1132,40 @@ where_are_the_whole_beams (SCM beaming)
    in POS for stem S.  This Y position is relative to S. */
 Real
 Beam::calc_stem_y (Grob *me, Grob *stem, Grob **common,
-                  Real xl, Real xr,
+                  Real xl, Real xr, Direction feather_dir, 
                   Drul_array<Real> pos, bool french)
 {
   Real beam_translation = get_beam_translation (me);
+  Direction stem_dir = get_grob_direction (stem);
 
-  Real r = stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl;
-  Real dy = pos[RIGHT] - pos[LEFT];
   Real dx = xr - xl;
-  Real stem_y_beam0 = (dy && dx
-                      ? r / dx
-                      * dy
-                      : 0) + pos[LEFT];
+  Real relx = dx ? (stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl)/dx : 0;
+  Real xdir = 2*relx-1;
+
+  Real stem_y = linear_combination(pos, xdir);
 
-  Direction my_dir = get_grob_direction (stem);
   SCM beaming = stem->get_property ("beaming");
 
-  Real stem_y = stem_y_beam0;
-  if (french)
-    {
-      Slice bm = where_are_the_whole_beams (beaming);
-      if (!bm.is_empty ())
-       stem_y += beam_translation * bm[-my_dir];
-    }
-  else
-    {
-      Slice bm = Stem::beam_multiplicity (stem);
-      if (!bm.is_empty ())
-       stem_y += bm[my_dir] * beam_translation;
-    }
+  Slice beam_slice (french
+                   ? where_are_the_whole_beams (beaming)
+                   : Stem::beam_multiplicity (stem));
+
+  Interval beam_multiplicity(beam_slice[LEFT],
+                            beam_slice[RIGHT]);
 
+  /*
+    feather dir = 1 , relx 0->1 : factor 0 -> 1
+    feather dir = 0 , relx 0->1 : factor 1 -> 1    
+    feather dir = -1, relx 0->1 : factor 1 -> 0    
+   */
+  Real feather_factor = 1;
+  if (feather_dir > 0)
+    feather_factor = relx;
+  else if (feather_dir < 0)
+    feather_factor = 1 - relx;
+  
+  stem_y += feather_factor * beam_translation
+    * beam_multiplicity[Direction(((french) ? DOWN : UP)*stem_dir)];
   Real id = me->relative_coordinate (common[Y_AXIS], Y_AXIS)
     - stem->relative_coordinate (common[Y_AXIS], Y_AXIS);
 
@@ -1209,6 +1213,7 @@ Beam::set_stem_lengths (SCM smob)
 
   Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
   Real xr = lvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
+  Direction feather_dir = to_dir (me->get_property ("grow-direction"));
 
   for (vsize i = 0; i < stems.size (); i++)
     {
@@ -1216,7 +1221,7 @@ Beam::set_stem_lengths (SCM smob)
 
       bool french = to_boolean (s->get_property ("french-beaming"));
       Real stem_y = calc_stem_y (me, s, common,
-                                xl, xr,
+                                xl, xr, feather_dir,
                                 pos, french && s != lvs && s!= fvs);
 
       /*
index dee61b467b07a8be1859195268b60e0e4600ca5e..fc3a722cacb7200e7daad95a9f1ed78532d5fb78 100644 (file)
@@ -122,7 +122,7 @@ private:
   static void consider_auto_knees (Grob *);
   static void set_stem_shorten (Grob *);
   static Real calc_stem_y (Grob *, Grob *s, Grob **c,
-                          Real, Real,
+                          Real, Real, Direction,
                           Drul_array<Real> pos, bool french);
   static int forced_stem_count (Grob *);
 };