]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
(precision_string): >? fix.
[lilypond.git] / lily / stem.cc
index 028843a6eb7257c0d58e5a04cbe66832a8301231..2bdc2fbcf53dd0d0857e70e6f0e7db39ed680a69 100644 (file)
@@ -121,7 +121,7 @@ Stem::set_stemend (Grob *me, Real se)
   Direction d = get_direction (me);
 
   if (d && d * head_positions (me)[get_direction (me)] >= se * d)
-    me->warning (_ ("Weird stem size; check for narrow beams"));
+    me->warning (_ ("weird stem size, check for narrow beams"));
 
   me->set_property ("stem-end-position", scm_make_real (se));
 }
@@ -298,7 +298,7 @@ Stem::get_default_stem_end_position (Grob *me)
     {
       SCM sshorten = me->get_property ("stem-shorten");
       SCM scm_shorten = scm_is_pair (sshorten)
-       ? robust_list_ref ((duration_log (me) - 2) >? 0, sshorten) : SCM_EOL;
+       ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL;
       Real shorten = 2* robust_scm2double (scm_shorten, 0);
 
       /* On boundary: shorten only half */
@@ -332,7 +332,7 @@ Stem::get_default_stem_end_position (Grob *me)
          if (dir == DOWN)
            minlen -= 1.0;
        }
-      length = length >? (minlen + 1.0);
+      length = max (length, minlen + 1.0);
     }
 
   Real st = dir ? hp[dir] + dir * length : 0;
@@ -516,7 +516,7 @@ Stem::height (SCM smob, SCM ax)
       Direction d = get_direction (me);
       if (d == CENTER)
        {
-         programming_error ("No stem direction");
+         programming_error ("no stem direction");
          d = UP;
        }
       iv[d] += d * Beam::get_thickness (b) * 0.5;
@@ -598,8 +598,8 @@ MAKE_SCHEME_CALLBACK (Stem, width_callback, 2);
 SCM
 Stem::width_callback (SCM e, SCM ax)
 {
-  Axis a = (Axis) scm_to_int (ax);
-  assert (a == X_AXIS);
+  (void) ax;
+  assert (scm_to_int (ax) == X_AXIS);
   Grob *me = unsmob_grob (e);
 
   Interval r;
@@ -615,8 +615,8 @@ Stem::width_callback (SCM e, SCM ax)
     }
   else
     {
-      r = flag (me).extent (X_AXIS)
-       + thickness (me) / 2;
+      r = Interval (-1,1) * thickness (me) * 0.5;
+      r.unite (flag (me).extent (X_AXIS));
     }
   return ly_interval2scm (r);
 }
@@ -671,11 +671,11 @@ Stem::print (SCM smob)
 
       y2 -= d
        * (0.5 * beam_thickness
-          + beam_translation * (0 >? (beam_count - 1))
+          + beam_translation * max (0, (beam_count - 1))
           + stemlet_length) / half_space;
     }
 
-  Interval stem_y (y1 <? y2, y2 >? y1);
+  Interval stem_y (min (y1, y2), max (y2, y1));
 
   if (Grob *hed = support_head (me))
     {
@@ -787,7 +787,7 @@ Stem::calc_stem_info (Grob *me)
 
   if (!my_dir)
     {
-      programming_error ("No stem dir set?");
+      programming_error ("no stem dir set");
       my_dir = UP;
     }
 
@@ -828,7 +828,7 @@ Stem::calc_stem_info (Grob *me)
     /* stem only extends to center of beam */
     - 0.5 * beam_thickness;
 
-  ideal_length = ideal_length >? ideal_minimum_length;
+  ideal_length = max (ideal_length, ideal_minimum_length);
 
   /* Convert to Y position, calculate for dir == UP */
   Real note_start
@@ -858,10 +858,10 @@ Stem::calc_stem_info (Grob *me)
     {
       /* Highest beam of (UP) beam must never be lower than middle
         staffline */
-      ideal_y = ideal_y >? 0;
+      ideal_y = max (ideal_y, 0.0);
       /* Lowest beam of (UP) beam must never be lower than second staffline */
-      ideal_y = ideal_y >? (-staff_space
-                           - beam_thickness + height_of_my_beams);
+      ideal_y = max (ideal_y, (-staff_space
+                              - beam_thickness + height_of_my_beams));
     }
 
   ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0);
@@ -878,6 +878,13 @@ Stem::calc_stem_info (Grob *me)
     /* stem only extends to center of beam */
     - 0.5 * beam_thickness;
 
+  if (Grob *tremolo = unsmob_grob (me->get_property ("tremolo-flag")))
+    {
+      Interval y_ext = tremolo->extent (tremolo, Y_AXIS);
+      y_ext.widen (0.5);       // FIXME. Should be tunable? 
+      minimum_length = max (minimum_length, y_ext.length ());
+    }
+  
   ideal_y *= my_dir;
   Real minimum_y = note_start + minimum_length;
   Real shortest_y = minimum_y * my_dir;