]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
second polish.
[lilypond.git] / lily / stem.cc
index 837e4c4cd8f2055a00c2d395cf8df17a5934c033..efbdcd1b774dcb21cf6994c19c035a003863b8a2 100644 (file)
@@ -289,32 +289,32 @@ Stem::get_default_stem_end_position (Grob*me)
   SCM s;
   Array<Real> a;
 
-  Real length_f = 3.5;
+  Real length = 3.5;
   SCM scm_len = me->get_grob_property ("length");
   if (gh_number_p (scm_len))
     {
-      length_f = gh_scm2double (scm_len);
+      length = gh_scm2double (scm_len);
     }
   else
     {
       s = me->get_grob_property ("lengths");
       if (gh_pair_p (s))
        {
-         length_f = 2* gh_scm2double (robust_list_ref (duration_log(me) -2, s));
+         length = 2* gh_scm2double (robust_list_ref (duration_log(me) -2, s));
        }
     }
 
-  Real shorten_f = 0.0;
+  Real shorten = 0.0;
   
   SCM sshorten = me->get_grob_property ("stem-shorten");
-  if (gh_pair_p (sshorten))
+  SCM scm_shorten = gh_pair_p (sshorten) ?
+    robust_list_ref ((duration_log (me) - 2) >? 0, sshorten): SCM_EOL;
+  if (gh_number_p (scm_shorten))
     {
-      shorten_f = 2* gh_scm2double (robust_list_ref ((duration_log (me) - 2) >? 0, sshorten));
+      shorten = 2* gh_scm2double (scm_shorten);
     }
 
-  /* On boundary: shorten only half */
-  if (abs (chord_start_y (me)) == 0.5)
-    shorten_f *= 0.5;
+
 
   /* URGURGURG
      'set-default-stemlen' sets direction too
@@ -325,16 +325,19 @@ Stem::get_default_stem_end_position (Grob*me)
       dir = get_default_dir (me);
       Directional_element_interface::set (me, dir);
     }
+
+  /* On boundary: shorten only half */
+  if (abs (head_positions (me)[get_direction (me)]) <= 1)
+    shorten *= 0.5;
   
   /* stems in unnatural (forced) direction should be shortened, 
     according to [Roush & Gourlay] */
-  if (chord_start_y (me)
-      && (get_direction (me) != get_default_dir (me)))
-    length_f -= shorten_f;
+  if (!chord_start_y (me)
+      || (get_direction (me) != get_default_dir (me)))
+    length -= shorten;
 
   Interval hp = head_positions (me);  
-  Real st = hp[dir] + dir * length_f;
-
+  Real st = hp[dir] + dir * length;
 
   /*
     TODO: change name  to extend-stems to staff/center/'()
@@ -417,11 +420,9 @@ Stem::position_noteheads (Grob*me)
     heads.reverse ();
 
 
-  bool invisible = invisible_b (me);
   Real thick = gh_scm2double (me->get_grob_property ("thickness"))
      * me->get_paper ()->get_var ("linethickness");
       
-
   Grob *hed = support_head (me);
   Real w = Note_head::head_extent (hed,X_AXIS)[dir];
   for (int i=0; i < heads.size (); i++)
@@ -430,7 +431,7 @@ Stem::position_noteheads (Grob*me)
                                X_AXIS);
     }
   
-  bool parity= true;           // todo: make me settable.
+  bool parity= true;
   int lastpos = int (Staff_symbol_referencer::get_position (heads[0]));
   for (int i=1; i < heads.size (); i ++)
     {
@@ -833,20 +834,18 @@ Stem::calc_stem_info (Grob *me)
 
 
   /* Simple standard stem length */
+  SCM lengths = me->get_grob_property ("beamed-lengths");
   Real ideal_length =
-    gh_scm2double (robust_list_ref
-                  (beam_count - 1,
-                   me->get_grob_property ("beamed-lengths")))
+    gh_scm2double (robust_list_ref (beam_count - 1,lengths))
+               
     * staff_space
     /* stem only extends to center of beam */
     - 0.5 * beam_thickness;
-
   
   /* Condition: sane minimum free stem length (chord to beams) */
+  lengths = me->get_grob_property ("beamed-minimum-free-lengths");
   Real ideal_minimum_free =
-    gh_scm2double (robust_list_ref
-                  (beam_count - 1,
-                   me->get_grob_property ("beamed-minimum-free-lengths")))
+    gh_scm2double (robust_list_ref (beam_count - 1, lengths))
     * staff_space;
   
 
@@ -910,7 +909,6 @@ Stem::calc_stem_info (Grob *me)
   if (gh_number_p (shorten))
     ideal_y -= gh_scm2double (shorten);
 
-
   Real minimum_free =
     gh_scm2double (robust_list_ref
                   (beam_count - 1,
@@ -949,6 +947,6 @@ Stem::beam_multiplicity (Grob *stem)
 
 ADD_INTERFACE (Stem,"stem-interface",
   "A stem",
-  "up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length flag-style no-stem-extend stroke-style");
+  "french-beaming up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length flag-style no-stem-extend stroke-style");