]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #184.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 1 Jan 2007 13:22:39 +0000 (14:22 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 1 Jan 2007 13:22:39 +0000 (14:22 +0100)
Use new function Stem_tremolo::vertical_length() to determine stem
length. Breaks Stem::length -> Stem_tremolo::extent -> Stem::stem_end
-> Stem::length cycle.

input/regression/stem-tremolo-forced-dir.ly [new file with mode: 0644]
lily/include/stem-tremolo.hh
lily/stem-tremolo.cc
lily/stem.cc

diff --git a/input/regression/stem-tremolo-forced-dir.ly b/input/regression/stem-tremolo-forced-dir.ly
new file mode 100644 (file)
index 0000000..146dd62
--- /dev/null
@@ -0,0 +1,8 @@
+
+\version "2.10.2"
+\layout { ragged-right = ##t }
+\relative c 
+{
+        \clef bass
+       \stemUp f4 : 32
+}
index 75946a34ee1fb3d2633ddc6ab8ac74eefb095c1c..59f1962f158ba652a17f0455f4b955dae872259b 100644 (file)
@@ -24,7 +24,9 @@ public:
   DECLARE_SCHEME_CALLBACK (calc_style, (SCM));
   static Stencil raw_stencil (Grob *, Real slope, Direction stemdir);
   static Stencil translated_stencil (Grob*, Real slope);
+  static Stencil untranslated_stencil (Grob*, Real slope);
   static Real get_beam_translation (Grob *me);
+  static Real vertical_length (Grob *me);
 };
 
 #endif /* ABBREV_HH */
index e607fda1b08ec3e551a303be846af81c9c78a791..cf927a5e51a8253a8df1ae5b45f5dc9693dad597 100644 (file)
@@ -147,8 +147,14 @@ Stem_tremolo::height (SCM smob)
   return ly_interval2scm (s1.extent (Y_AXIS));
 }
 
+Real
+Stem_tremolo::vertical_length (Grob *me)
+{
+  return untranslated_stencil (me, 0.35).extent (Y_AXIS).length ();
+}
+  
 Stencil
-Stem_tremolo::translated_stencil (Grob *me, Real slope)
+Stem_tremolo::untranslated_stencil (Grob *me, Real slope)
 {
   Grob *stem = unsmob_grob (me->get_object ("stem"));
   if (!stem)
@@ -157,30 +163,37 @@ Stem_tremolo::translated_stencil (Grob *me, Real slope)
       return Stencil();
     }
 
-  Spanner *beam = Stem::get_beam (stem);
   Direction stemdir = get_grob_direction (stem);
-  if (stemdir == 0)
+  if (!stemdir)
     stemdir = UP;
 
   bool whole_note = Stem::duration_log (stem) <= 0;
 
-  Real beam_translation = get_beam_translation (me);
-
   /* for a whole note, we position relative to the notehead, so we want the
      stencil aligned on the flag closest to the head */
   Direction stencil_dir = whole_note ? -stemdir : stemdir;
-  Stencil mol = raw_stencil (me, slope, stencil_dir);
+  return raw_stencil (me, slope, stencil_dir);
+}
 
-  Interval mol_ext = mol.extent (Y_AXIS);
-  Real ss = Staff_symbol_referencer::staff_space (me);
+  
+Stencil
+Stem_tremolo::translated_stencil (Grob *me, Real slope)
+{
+  Stencil mol = untranslated_stencil (me, slope);
 
-  // ugh, rather calc from Stem_tremolo_req
-  int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0;
+  Grob *stem = unsmob_grob (me->get_object ("stem"));
+  if (!stem)
+    return Stencil ();
+  
+  Direction stemdir = get_grob_direction (stem);
+  if (stemdir == 0)
+    stemdir = UP;
 
-  Real beamthickness = 0.0;
-  SCM sbt = (beam) ? beam->get_property ("thickness") : SCM_EOL;
-  if (scm_is_number (sbt))
-    beamthickness = scm_to_double (sbt) * ss;
+  Spanner *beam = Stem::get_beam (stem);
+  Real beam_translation = get_beam_translation (me);
+
+  int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0;
+  Real ss = Staff_symbol_referencer::staff_space (me);
 
   Real end_y
     = Stem::stem_end_position (stem) * ss / 2
@@ -192,6 +205,8 @@ Stem_tremolo::translated_stencil (Grob *me, Real slope)
       if (stemdir == UP)
         end_y -= stemdir * beam_translation * 0.5;
     }
+
+  bool whole_note = Stem::duration_log (stem) <= 0;
   if (whole_note)
     {
       /* we shouldn't position relative to the end of the stem since the stem
index 77185b3bdc9bc07e2c8539a4c97953a01b90a618..d333690491c6d98de4d1e85bb21688afb96728f8 100644 (file)
@@ -317,7 +317,7 @@ Stem::calc_stem_end_position (SCM smob)
   return scm_from_double (stem_end);
 }
 
-
+/* Length is in half-spaces (or: positions) here. */
 MAKE_SCHEME_CALLBACK (Stem, calc_length, 1)
 SCM
 Stem::calc_length (SCM smob)
@@ -364,8 +364,7 @@ Stem::calc_length (SCM smob)
       (Stem_tremolo::raw_stencil () looks at the beam.) --hwn  */
 
       Real minlen = 1.0
-       + 2 * t_flag->extent (t_flag, Y_AXIS).length ()
-       / ss;
+       + 2 * Stem_tremolo::vertical_length (t_flag) / ss;
 
       /* We don't want to add the whole extent of the flag because the trem
          and the flag can overlap partly. beam_translation gives a good