]> git.donarmstrong.com Git - lilypond.git/commitdiff
(get_beam_translation): new function.
authorhanwen <hanwen>
Fri, 10 Feb 2006 01:05:05 +0000 (01:05 +0000)
committerhanwen <hanwen>
Fri, 10 Feb 2006 01:05:05 +0000 (01:05 +0000)
(calc_slope): new function.
(height): don't use real slope.

ChangeLog
lily/include/stem-tremolo.hh
lily/stem-tremolo.cc
lily/stem.cc
scm/define-grobs.scm
scm/define-markup-commands.scm
scripts/convert-ly.py

index cda828adfb890cddc47cab2361a96b830f9a36eb..831ca7f4955c530ea3e91903a90d005d62b5867e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/stem-tremolo.cc (get_beam_translation): new function.
+       (calc_slope): new function.
+       (height): don't use real slope.
+
 2006-02-10  Jürgen Reuter  <reuter@ipd.uka.de>
 
        * scm/define-grobs.scm (LigatureBracket): Maintenance bugfix: add
index aa323ab09ff0d80747569214d850221b1a92910e..41d504a8c767e156d2192d7cdaaadb7dd3c7ee91 100644 (file)
@@ -18,9 +18,11 @@ public:
 
   static bool has_interface (Grob *);
   DECLARE_SCHEME_CALLBACK (dim_callback, (SCM smob));
+  DECLARE_SCHEME_CALLBACK (calc_slope, (SCM));
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (height, (SCM));
-  static Stencil raw_stencil (Grob *);
+  static Stencil raw_stencil (Grob *, Real);
+  static Real get_beam_translation (Grob *me);
 };
 
 #endif /* ABBREV_HH */
index f515f959082844cfced915fbf7d268ca78f86948..03019d023747459e306a2ab8468f20df15c5a153 100644 (file)
@@ -32,44 +32,47 @@ Stem_tremolo::dim_callback (SCM e)
   return ly_interval2scm (Interval (-space, space));
 }
 
-MAKE_SCHEME_CALLBACK (Stem_tremolo, height, 1);
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_slope, 1)
 SCM
-Stem_tremolo::height (SCM smob)
+Stem_tremolo::calc_slope (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
+  Grob *stem = unsmob_grob (me->get_object ("stem"));
+  Spanner *beam = Stem::get_beam (stem);
 
-  /* TODO: fixme. uncached? */
-  return ly_interval2scm (me->get_stencil ()
-                         ? me->get_stencil ()->extent (Y_AXIS)
-                         : Interval());
+  if (beam)
+    {
+      Real dy = 0;
+      SCM s = beam->get_property ("quantized-positions");
+      if (is_number_pair (s))
+       dy = - scm_to_double (scm_car (s)) + scm_to_double (scm_cdr (s));
+
+      Grob *s2 = Beam::last_visible_stem (beam);
+      Grob *s1 = Beam::first_visible_stem (beam);
+      
+      Grob *common = s1->common_refpoint (s2, X_AXIS);
+      Real dx = s2->relative_coordinate (common, X_AXIS) -
+       s1->relative_coordinate (common, X_AXIS);
+
+      return scm_from_double (dx ? dy / dx : 0);
+    }
+  else
+    return scm_from_double (0.25);
 }
 
-Stencil
-Stem_tremolo::raw_stencil (Grob *me)
+Real
+Stem_tremolo::get_beam_translation (Grob *me)
 {
   Grob *stem = unsmob_grob (me->get_object ("stem"));
   Spanner *beam = Stem::get_beam (stem);
 
-  SCM slope = me->get_property ("slope");
-  Real dydx = 0.25;
-  if (scm_is_number (slope))
-    {
-      dydx = robust_scm2double (slope, 0.0);
-    }
-  else
-    {
-      if (beam)
-       {
-         Real dy = 0;
-         SCM s = beam->get_property ("positions");
-         if (is_number_pair (s))
-           dy = - scm_to_double (scm_car (s)) + scm_to_double (scm_cdr (s));
-
-         Real dx = Beam::last_visible_stem (beam)->relative_coordinate (0, X_AXIS)
-           - Beam::first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
-         dydx = dx ? dy / dx : 0;
-       }
-    }
+  return  beam ? Beam::get_beam_translation (beam) : 0.81;
+}
+
+Stencil
+Stem_tremolo::raw_stencil (Grob *me, Real slope)
+{
   Real ss = Staff_symbol_referencer::staff_space (me);
   Real thick = robust_scm2double (me->get_property ("beam-thickness"), 1);
   Real width = robust_scm2double (me->get_property ("beam-width"), 1);
@@ -78,14 +81,10 @@ Stem_tremolo::raw_stencil (Grob *me)
   width *= ss;
   thick *= ss;
 
-  Stencil a (Lookup::beam (dydx, width, thick, blot));
-  a.translate (Offset (-width * 0.5, width * 0.5 * dydx));
-
-  int tremolo_flags = 0;
-  SCM s = me->get_property ("flag-count");
-  if (scm_is_number (s))
-    tremolo_flags = scm_to_int (s);
+  Stencil a (Lookup::beam (slope, width, thick, blot));
+  a.translate (Offset (-width * 0.5, width * 0.5 * slope));
 
+  int tremolo_flags = robust_scm2int (me->get_property ("flag-count"), 0);
   if (!tremolo_flags)
     {
       programming_error ("no tremolo flags");
@@ -95,7 +94,7 @@ Stem_tremolo::raw_stencil (Grob *me)
     }
 
   /* Who the fuck is 0.81 ? --hwn.   */
-  Real beam_translation = beam ? Beam::get_beam_translation (beam) : 0.81;
+  Real beam_translation = get_beam_translation(me);
 
   Stencil mol;
   for (int i = 0; i < tremolo_flags; i++)
@@ -107,6 +106,23 @@ Stem_tremolo::raw_stencil (Grob *me)
   return mol;
 }
 
+
+
+MAKE_SCHEME_CALLBACK (Stem_tremolo, height, 1);
+SCM
+Stem_tremolo::height (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+
+  /*
+    Cannot use the real slope, since it looks at the Beam.
+   */
+  Stencil s1 (raw_stencil (me, 0.35));
+
+  return ly_interval2scm (s1.extent (Y_AXIS));
+}
+
+
 MAKE_SCHEME_CALLBACK (Stem_tremolo, print, 1);
 SCM
 Stem_tremolo::print (SCM grob)
@@ -129,7 +145,8 @@ Stem_tremolo::print (SCM grob)
     ? Beam::get_beam_translation (beam)
     : 0.81;
 
-  Stencil mol = raw_stencil (me);
+  Stencil mol = raw_stencil (me, robust_scm2double (me->get_property ("slope"),
+                                                   0.25));
   Interval mol_ext = mol.extent (Y_AXIS);
   Real ss = Staff_symbol_referencer::staff_space (me);
 
index 0f42976d32dcb531c29cdf9cc076e5158e7aaf9e..c50b97631073efcd139effa0476ecd227df1329a 100644 (file)
@@ -331,7 +331,7 @@ Stem::calc_length (SCM smob)
       (Stem_tremolo::raw_stencil () looks at the beam.) --hwn  */
 
       Real minlen = 1.0
-       + 2 * Stem_tremolo::raw_stencil (t_flag).extent (Y_AXIS).length ()
+       + 2 * t_flag->extent (t_flag, Y_AXIS).length ()
        / ss;
 
       if (durlog >= 3)
index 09bddf34d3e2636ca8eefe50c06d99a50785de1f..660eacd0a5c2bd7cb9f270f1c4079046dda5943d 100644 (file)
        (Y-extent . ,ly:stem-tremolo::height)
        (stencil . ,ly:stem-tremolo::print)
        (X-extent . #f)
+       (slope . ,ly:stem-tremolo::calc-slope)
        (beam-width . 1.6) ; staff-space
        (beam-thickness . 0.48) ; staff-space
        (meta . ((class . Item)
index 9f6ff6325983372ea44afd04c9b114b3d74d6074..899e2c26f3465b03cfa2e84e0e10eb7d98b6124d 100644 (file)
@@ -568,6 +568,7 @@ of the @code{#'direction} layout property."
   "Put @code{args} in a centered column. "
   (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
          (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols)))
+    
     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
 
 (def-markup-command (vcenter layout props arg) (markup?)
index b9cac64f59b6140baae5866c94f323f42561da29..d660dfd2011ab015e558dc21610deca620b84792 100644 (file)
@@ -26,6 +26,8 @@ if os.environ.has_key ('LILYPONDPREFIX'):
 
 if os.path.exists (os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/')):
        datadir = os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/')
+elif os.path.exists (os.path.join (datadir, 'share/lilypond/current/')):
+       datadir = os.path.join (datadir, 'share/lilypond/current/')
 
 sys.path.insert (0, os.path.join (datadir, 'python'))