]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
Release: bump version.
[lilypond.git] / lily / stem.cc
index 6575914789de9e84c7e9164592d82eda600b6319..8c0e128487b4f48027bb7f23e8810b19aa229c56 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 
   TODO: This is way too hairy
@@ -129,7 +129,7 @@ Stem::set_stem_positions (Grob *me, Real se)
 
   Interval height = me->pure_height (me, 0, INT_MAX);
   Real staff_space = Staff_symbol_referencer::staff_space (me);
-  Real half_space =  staff_space * 0.5;
+  Real half_space = staff_space * 0.5;
 
   height[d] = se * half_space + beam_end_corrective (me);
 
@@ -149,8 +149,8 @@ Stem::set_stem_positions (Grob *me, Real se)
 
           height[-d] = (height[d] - d
                         * (0.5 * beam_thickness
-                        + beam_translation * max (0, (beam_count - 1))
-                        + stemlet_length));
+                           + beam_translation * max (0, (beam_count - 1))
+                           + stemlet_length));
         }
       else if (!stemlet && beam)
         height[-d] = height[d];
@@ -277,7 +277,12 @@ Stem::is_invisible (Grob *me)
 bool
 Stem::is_normal_stem (Grob *me)
 {
-  return head_count (me) && scm_to_int (me->get_property ("duration-log")) >= 1;
+  if (!head_count (me))
+     return false;
+
+  extract_grob_set (me, "note-heads", heads);
+  SCM style = heads[0]->get_property ("style");
+  return style != ly_symbol2scm ("kievan") && scm_to_int (me->get_property ("duration-log")) >= 1;
 }
 
 MAKE_SCHEME_CALLBACK (Stem, pure_height, 3)
@@ -302,7 +307,7 @@ Stem::internal_pure_height (Grob *me, bool calc_beam)
 
   if (!beam)
     return iv;
-  if (!to_boolean (me->get_property ("cross-staff")) && calc_beam)
+  if (calc_beam)
     {
       Interval overshoot;
       Direction dir = get_grob_direction (me);
@@ -315,12 +320,35 @@ Stem::internal_pure_height (Grob *me, bool calc_beam)
       vector<Grob *> my_stems;
       extract_grob_set (beam, "normal-stems", normal_stems);
       for (vsize i = 0; i < normal_stems.size (); i++)
-        if (normal_stems[i] != me && get_grob_direction (normal_stems[i]) == dir)
+        if (get_grob_direction (normal_stems[i]) == dir)
           {
-            heights.push_back (Stem::internal_pure_height (normal_stems[i], false));
+            if (normal_stems[i] != me)
+              heights.push_back (Stem::internal_pure_height (normal_stems[i], false));
+            else
+              heights.push_back (iv);
             my_stems.push_back (normal_stems[i]);
-            iv.unite (heights.back ());
           }
+      //iv.unite (heights.back ());
+      // look for cross staff effects
+      vector<Real> coords;
+      Grob *common = common_refpoint_of_array (my_stems, me, Y_AXIS);
+      Real min_pos = infinity_f;
+      Real max_pos = -infinity_f;
+      for (vsize i = 0; i < my_stems.size (); i++)
+        {
+          coords.push_back (my_stems[i]->pure_relative_y_coordinate (common, 0, INT_MAX));
+          min_pos = min (min_pos, coords[i]);
+          max_pos = max (max_pos, coords[i]);
+        }
+      for (vsize i = 0; i < heights.size (); i++)
+        {
+          heights[i][dir] += dir == DOWN
+                             ? coords[i] - max_pos
+                             : coords[i] - min_pos;
+        }
+
+      for (vsize i = 0; i < heights.size (); i++) iv.unite (heights[i]);
+
       for (vsize i = 0; i < my_stems.size (); i++)
         cache_pure_height (my_stems[i], iv, heights[i]);
       iv.intersect (overshoot);
@@ -390,7 +418,6 @@ Stem::internal_calc_stem_end_position (Grob *me, bool calc_beam)
   if (scm_is_pair (s))
     length = 2 * scm_to_double (robust_list_ref (durlog - 2, s));
 
-
   /* Stems in unnatural (forced) direction should be shortened,
      according to [Roush & Gourlay] */
   Interval hp = head_positions (me);
@@ -631,7 +658,7 @@ Stem::height (SCM smob)
   return ly_interval2scm (internal_height (me, true));
 }
 
-Grob*
+Grob *
 Stem::get_reference_head (Grob *me)
 {
   return to_boolean (me->get_property ("avoid-note-head"))
@@ -677,14 +704,14 @@ Stem::internal_height (Grob *me, bool calc_beam)
                                0.0);
 
   Real y2 = dir * robust_scm2double ((calc_beam
-                                     ? me->get_property ("length")
-                                     : me->get_pure_property ("length", 0, INT_MAX)),
-                                      0.0)
-                + y1;
+                                      ? me->get_property ("length")
+                                      : me->get_pure_property ("length", 0, INT_MAX)),
+                                     0.0)
+            + y1;
 
   Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
 
-  Interval stem_y  = Interval (min (y1, y2), max (y2, y1)) * half_space;
+  Interval stem_y = Interval (min (y1, y2), max (y2, y1)) * half_space;
 
   return stem_y;
 }
@@ -798,7 +825,7 @@ Stem::print (SCM smob)
 
   Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
 
-  Interval stem_y  = Interval (min (y1, y2), max (y2, y1)) * half_space;
+  Interval stem_y = Interval (min (y1, y2), max (y2, y1)) * half_space;
 
   stem_y[dir] -= beam_end_corrective (me);
 
@@ -849,11 +876,10 @@ Stem::offset_callback (SCM smob)
       Real r = real_attach;
 
       /* If not centered: correct for stem thickness.  */
-      extract_grob_set (me, "note-heads", heads);
-      SCM style = heads[0]->get_property ("style");
-      if (attach && !scm_is_eq (style, ly_symbol2scm ("mensural"))
-                 && !scm_is_eq (style, ly_symbol2scm ("neomensural"))
-                 && !scm_is_eq (style, ly_symbol2scm ("petrucci")))
+      string style = robust_symbol2string (f->get_property ("style"), "default");
+      if (attach && style != "mensural"
+          && style != "neomensural"
+          && style != "petrucci")
         {
           Real rule_thick = thickness (me);
           r += -d * rule_thick * 0.5;
@@ -988,7 +1014,7 @@ Stem::calc_stem_info (SCM smob)
 
   Also, not for knees.  Seems to be a good thing. */
   bool no_extend = to_boolean (me->get_property ("no-stem-extend"));
-  bool is_knee = to_boolean (beam->get_property ("knee"));
+  bool is_knee = Beam::is_knee (beam);
   if (!no_extend && !is_knee)
     {
       /* Highest beam of (UP) beam must never be lower than middle
@@ -1048,7 +1074,7 @@ Stem::calc_cross_staff (SCM smob)
   return scm_from_bool (is_cross_staff (unsmob_grob (smob)));
 }
 
-Grob*
+Grob *
 Stem::flag (Grob *me)
 {
   return unsmob_grob (me->get_object ("flag"));
@@ -1096,6 +1122,7 @@ ADD_INTERFACE (Stem,
                "length "
                "length-fraction "
                "max-beam-connect "
+               "melody-spanner "
                "neutral-direction "
                "no-stem-extend "
                "note-heads "
@@ -1106,6 +1133,7 @@ ADD_INTERFACE (Stem,
                "stemlet-length "
                "thickness "
                "tremolo-flag "
+               "tuplet-start "
               );
 
 /****************************************************************/