]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/beam.cc (get_default_dir): take extreme note head as input
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 17 Feb 2006 01:15:52 +0000 (01:15 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 17 Feb 2006 01:15:52 +0000 (01:15 +0000)
for stem direction.

* lily/tie.cc (get_default_dir): only look directions for visible
stems.

* lily/side-position-interface.cc (aligned_side): oops. Don't
mutiply with direction. This fixes quantized (staccato, tenuto)
scripts below notes.

ChangeLog
lily/beam.cc
lily/side-position-interface.cc
lily/tie.cc

index 0709a4f69b870e23406f11d94c2ab37fbc1008f7..50490729a6b1eced084f3ebefe393bd20546bc3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2006-02-17  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/beam.cc (get_default_dir): take extreme note head as input
+       for stem direction.
+
+       * lily/tie.cc (get_default_dir): only look directions for visible
+       stems. 
+
        * lily/side-position-interface.cc (aligned_side): oops. Don't
        mutiply with direction. This fixes quantized (staccato, tenuto)
        scripts below notes.
index 49acbbd541189fbc8b05b55a1f9b9d955ce8274e..d47efc5a7875b80ec12506bd67d721e8871be60f 100644 (file)
@@ -100,12 +100,6 @@ Beam::get_beam_count (Grob *me)
 }
 
 
-/* After pre-processing all directions should be set.
-   Several post-processing routines (stem, slur, script) need stem/beam
-   direction.
-   Currenly, this means that beam has set all stem's directions.
-   [Alternatively, stems could set its own directions, according to
-   their beam, during 'final-pre-processing'.] */
 MAKE_SCHEME_CALLBACK (Beam, calc_direction, 1);
 SCM
 Beam::calc_direction (SCM smob)
@@ -522,16 +516,34 @@ Beam::print (SCM grob)
   return the_beam.smobbed_copy ();
 }
 
+#define iterof(i,s) typeof((s).begin()) i((s).begin())
+
 Direction
 Beam::get_default_dir (Grob *me)
 {
-  Drul_array<int> total;
-  total[UP] = total[DOWN] = 0;
-  Drul_array<int> count;
-  count[UP] = count[DOWN] = 0;
-
   extract_grob_set (me, "stems", stems);
 
+  Drul_array<Real> extremes (0.0, 0.0);
+  for (iterof (s, stems); s != stems.end (); s++)
+    {
+      Interval positions = Stem::head_positions (*s);
+      Direction d = DOWN;
+      do
+       {
+         if (sign (positions[d]) == d)
+           extremes[d] = d * max (d * positions[d], d * extremes[d]);
+       }
+      while (flip (&d) != DOWN);
+    }
+
+  if (extremes[UP] > extremes[DOWN])
+    return DOWN;
+  else if (extremes[UP] < extremes[DOWN])
+    return UP;
+
+  Drul_array<int> total (0, 0);
+  Drul_array<int> count (0, 0);
   for (vsize i = 0; i < stems.size (); i++)
     {
       Grob *s = stems[i];
index 2352c116d08ae37c9adb54c953734f037e786e32..72dfbb838018b7da1918bd4dd233fa2138c2d700 100644 (file)
@@ -240,10 +240,10 @@ ADD_INTERFACE (Side_position_interface, "side-position-interface",
               "direction-source "
               "minimum-space "
               "padding "
+              "quantize-position "
               "side-axis "
               "side-relative-direction "
               "side-support-elements "
               "slur-padding "
               "staff-padding "
-              "quantize-position "
               );
index 4b0404d690ca4e02755f058414082f123bebc728..e0c17aa912c3124f4cb16eb07d38eeaf9511f4cc 100644 (file)
@@ -96,17 +96,27 @@ Tie::get_position (Grob *me)
 Direction
 Tie::get_default_dir (Grob *me)
 {
-  Item *sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) : 0;
-  Item *sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) : 0;
-  if (sl && sr)
+  Drul_array<Grob*> stems;
+  Direction d = LEFT;
+  do
+    {
+      Grob *stem = head (me, d) ? Rhythmic_head::get_stem (head (me, d)) : 0;
+      if (stem)
+       stem = Stem::is_invisible (stem) ? 0 : stem;
+
+      stems[d] = stem;
+    }
+  while (flip (&d)!= LEFT);
+  
+  if (stems[LEFT] && stems[RIGHT])
     {
-      if (get_grob_direction (sl) == UP
-         && get_grob_direction (sr) == UP)
+      if (get_grob_direction (stems[LEFT]) == UP
+         && get_grob_direction (stems[RIGHT]) == UP)
        return DOWN;
     }
-  else if (sl || sr)
+  else if (stems[LEFT] || stems[RIGHT])
     {
-      Item *s = sl ? sl : sr;
+      Grob *s = stems[LEFT] ? stems[LEFT] : stems[RIGHT];
       return -get_grob_direction (s);
     }