]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
* python/convertrules.py (string_or_scheme): Fix spelling error
[lilypond.git] / lily / stem.cc
index 1905736a9d344da0948b103de61759bba9250459..bd42bbb1e93e95b771158f1aa091a1b7f2accb48 100644 (file)
@@ -505,9 +505,7 @@ Stem::height (SCM smob, SCM ax)
   */
   Grob *beam = get_beam (me);
   if (beam)
-    {
-      Beam::after_line_breaking (beam->self_scm ());
-    }
+    Beam::after_line_breaking (beam->self_scm ());
 
   SCM mol = me->get_uncached_stencil ();
   Interval iv;
@@ -530,9 +528,15 @@ Stem::height (SCM smob, SCM ax)
 Stencil
 Stem::flag (Grob *me)
 {
-  /* TODO: maybe property stroke-style should take different values,
-     e.g. "" (i.e. no stroke), "single" and "double" (currently, it's
-     '() or "grace").  */
+  int log = duration_log (me);
+  if (log < 3
+      || unsmob_grob (me->get_object ("beam")))
+    return Stencil ();
+
+  /*
+    TODO: maybe property stroke-style should take different values,
+    e.g. "" (i.e. no stroke), "single" and "double" (currently, it's
+    '() or "grace").  */
   String flag_style;
 
   SCM flag_style_scm = me->get_property ("flag-style");
@@ -561,18 +565,14 @@ Stem::flag (Grob *me)
            = Staff_symbol_referencer::on_staffline (me, p) ? "0" : "1";
        }
       else
-       {
-         staffline_offs = "2";
-       }
+       staffline_offs = "2";
     }
   else
-    {
-      staffline_offs = "";
-    }
+    staffline_offs = "";
 
   char dir = (get_direction (me) == UP) ? 'u' : 'd';
   String font_char = flag_style
-    + to_string (dir) + staffline_offs + to_string (duration_log (me));
+    + to_string (dir) + staffline_offs + to_string (log);
   Font_metric *fm = Font_interface::get_default_font (me);
   Stencil flag = fm->find_by_name ("flags." + font_char);
   if (flag.is_empty ())
@@ -607,9 +607,7 @@ Stem::width_callback (SCM e, SCM ax)
   Interval r;
 
   if (is_invisible (me))
-    {
-      r.set_empty ();
-    }
+    r.set_empty ();
   else if (unsmob_grob (me->get_object ("beam")) || abs (duration_log (me)) <= 2)
     {
       r = Interval (-1, 1);
@@ -702,17 +700,30 @@ Stem::print (SCM smob)
   Stencil ss = Lookup::round_filled_box (b, blot);
   mol.add_stencil (ss);
 
-  if (!get_beam (me) && abs (duration_log (me)) > 2)
+  mol.add_stencil (get_translated_flag (me));
+
+  return mol.smobbed_copy ();
+}
+
+Stencil
+Stem::get_translated_flag (Grob *me)
+{
+  Stencil fl = flag (me);
+  if (!fl.is_empty ())
     {
-      Stencil fl = flag (me);
-      fl.translate_axis (stem_y[d] * half_space - d * blot / 2, Y_AXIS);
+      Direction d = get_direction (me);
+      Real blot
+       = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
+      Real stem_width = thickness (me);
+      Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
+      Real y2 = stem_end_position (me);
+      fl.translate_axis (y2 * half_space - d * blot / 2, Y_AXIS);
       fl.translate_axis (stem_width / 2, X_AXIS);
-      mol.add_stencil (fl);
     }
-
-  return mol.smobbed_copy ();
+  return fl;
 }
 
+
 /*
   move the stem to right of the notehead if it is up.
 */