]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/stem.cc (calc_stem_info): trigger beaming calculation.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Nov 2005 15:11:19 +0000 (15:11 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Nov 2005 15:11:19 +0000 (15:11 +0000)
* lily/beam.cc (calc_beaming): new function.
(calc_shorten): new function.

* THANKS: add Edward Neeman.

* scm/define-grobs.scm (all-grob-descriptions): add Y-offset property.

ChangeLog
THANKS
lily/beam.cc
lily/include/beam.hh
lily/include/stem.hh
lily/stem.cc
scm/define-grobs.scm

index 39ce04051c36df3ca97a23f239507b2d7ca21087..dee05a0421bbd87953176bbe09103c34bffca015 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2005-11-17  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/stem.cc (calc_stem_info): trigger beaming calculation.
+
+       * lily/beam.cc (calc_beaming): new function.
+       (calc_shorten): new function.
+
+       * THANKS: add Edward Neeman.
+
        * input/regression/accidental-clef-change.ly: new file.
 
        * lily/note-collision.cc (check_meshing_chords): don't merge fa heads.
diff --git a/THANKS b/THANKS
index 434b25a294b901e8806f765e9ce0bfab8baaf72e..7483c5586f4ba3503ff275c0b0f8745e07078dd3 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -47,6 +47,7 @@ Bob Broadus
 Chris Sawer
 Darius Blasband
 Donald Axel
+Edward Neeman
 Eduardo Vieira
 Erlend Aasland
 Matevž Jekovec
index 19b69fe15be0f134b24bc688be92e97796de4c16..4b6bfa3024f6e0f4b60dfca63d1124022ebfe878 100644 (file)
@@ -160,13 +160,13 @@ Beam::calc_direction (SCM smob)
   if (d)
     {
       set_stem_directions (me, d);
-      connect_beams (me);
-      set_stem_shorten (me);
     }
   
   return scm_from_int (d);
 }
 
+
+
 /* We want a maximal number of shared beams, but if there is choice, we
  * take the one that is closest to the end of the stem. This is for
  * situations like
@@ -209,9 +209,12 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming,
   return best_start;
 }
 
-void
-Beam::connect_beams (Grob *me)
+MAKE_SCHEME_CALLBACK(Beam, calc_beaming, 1)
+SCM
+Beam::calc_beaming (SCM smob)
 {
+  Grob *me = unsmob_grob (smob);
+  
   extract_grob_set (me, "stems", stems);
 
   Slice last_int;
@@ -269,6 +272,8 @@ Beam::connect_beams (Grob *me)
          last_dir = this_dir;
        }
     }
+
+  return SCM_BOOL_T;
 }
 
 /*
@@ -692,14 +697,44 @@ scmify forced-fraction
 This is done in beam because the shorten has to be uniform over the
 entire beam.
 */
+
+
+
 void
-Beam::set_stem_shorten (Grob *me)
+set_minimum_dy (Grob *me, Real *dy)
+{
+  if (*dy)
+    {
+      /*
+       If dy is smaller than the smallest quant, we
+       get absurd direction-sign penalties.
+      */
+
+      Real ss = Staff_symbol_referencer::staff_space (me);
+      Real thickness = Beam::get_thickness (me) / ss;
+      Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
+      Real sit = (thickness - slt) / 2;
+      Real inter = 0.5;
+      Real hang = 1.0 - (thickness - slt) / 2;
+
+      *dy = sign (*dy) * max (fabs (*dy),
+                             min (min (sit, inter), hang));
+    }
+}
+
+  
+
+MAKE_SCHEME_CALLBACK(Beam, calc_stem_shorten, 1)
+SCM
+Beam::calc_stem_shorten (SCM smob)
 {
+  Grob *me = unsmob_grob (smob);
+  
   /*
     shortening looks silly for x staff beams
   */
   if (is_knee (me))
-    return;
+    return scm_from_int (0);
 
   Real forced_fraction = 1.0 * forced_stem_count (me)
     / visible_stem_count (me);
@@ -708,7 +743,7 @@ Beam::set_stem_shorten (Grob *me)
 
   SCM shorten_list = me->get_property ("beamed-stem-shorten");
   if (shorten_list == SCM_EOL)
-    return;
+    return scm_from_int (0);
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
 
@@ -718,33 +753,14 @@ Beam::set_stem_shorten (Grob *me)
 
   shorten *= forced_fraction;
 
+  
   if (shorten)
-    me->set_property ("shorten", scm_from_double (shorten));
-}
-
-
+    return scm_from_double (shorten);
 
-void
-set_minimum_dy (Grob *me, Real *dy)
-{
-  if (*dy)
-    {
-      /*
-       If dy is smaller than the smallest quant, we
-       get absurd direction-sign penalties.
-      */
+  return scm_from_double (0.0);
+}
 
-      Real ss = Staff_symbol_referencer::staff_space (me);
-      Real thickness = Beam::get_thickness (me) / ss;
-      Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
-      Real sit = (thickness - slt) / 2;
-      Real inter = 0.5;
-      Real hang = 1.0 - (thickness - slt) / 2;
 
-      *dy = sign (*dy) * max (fabs (*dy),
-                             min (min (sit, inter), hang));
-    }
-}
 
 /*
   Compute a first approximation to the beam slope.
index a044a1fd8cc8723ce9d149af97d7a238c1a76a82..6025cd1e129265ccc0ed35642b035ca41e0a2a9d 100644 (file)
@@ -57,6 +57,8 @@ public:
 
   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
   DECLARE_SCHEME_CALLBACK (print, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM));
index ee66ec15fa4f3bfdf7440df34f5c4822675915ed..dbbb3e8438dab838ee1f925df7d94cf52c47ccec 100644 (file)
@@ -42,6 +42,7 @@ public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_length, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_end_position, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_info, (SCM));
index 9cdaaa2568073c274aeaa903c57a15e23087e8e5..62f9c8669b7012554f981c90ab6d02ba3baca681 100644 (file)
@@ -448,8 +448,6 @@ Stem::calc_positioning_done (SCM smob)
   return SCM_BOOL_T;
 }
 
-
-
 MAKE_SCHEME_CALLBACK(Stem, calc_direction, 1);
 SCM
 Stem::calc_direction (SCM smob)
@@ -809,31 +807,38 @@ Stem::calc_stem_info (SCM smob)
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Grob *beam = get_beam (me);
+
+  if (beam)
+    {
+      (void) beam->get_property ("beaming");
+    }
+  
   Real beam_translation = Beam::get_beam_translation (beam);
   Real beam_thickness = Beam::get_thickness (beam);
   int beam_count = Beam::get_direction_beam_count (beam, my_dir);
+  Real length_fraction
+    = robust_scm2double (me->get_property ("length-fraction"), 1.0);
 
   /* Simple standard stem length */
   SCM details = me->get_property ("details");
   SCM lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-lengths"), details));
-
   
   Real ideal_length
     = scm_to_double (robust_list_ref (beam_count - 1, lengths))
-
     * staff_space
+    * length_fraction
+    
     /* stem only extends to center of beam
      */
     - 0.5 * beam_thickness;
 
   /* Condition: sane minimum free stem length (chord to beams) */
   lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-minimum-free-lengths"), details));
-  Real length_fraction
-    = robust_scm2double (me->get_property ("length-fraction"), 1.0);
 
   Real ideal_minimum_free
     = scm_to_double (robust_list_ref (beam_count - 1, lengths))
-    * staff_space * length_fraction;
+    * staff_space
+    * length_fraction;
 
   /* UGH
      It seems that also for ideal minimum length, we must use
@@ -893,7 +898,8 @@ Stem::calc_stem_info (SCM smob)
   
   Real minimum_free
     = scm_to_double (robust_list_ref (beam_count - 1, bemfl))
-    * staff_space;
+    * staff_space
+    * length_fraction;
 
   Real minimum_length = minimum_free
     + height_of_my_beams
index 6d96746247fe76a7b63232215facc2fef4d67389..91883374401c73e7b0409941d534a520fa770059 100644 (file)
        (quantized-positions . ,Beam::set_stem_lengths)
        (concaveness . ,Beam::calc_concaveness)
        (direction . ,Beam::calc_direction)
+       (shorten . ,Beam::calc_stem_shorten)
+       (beaming . ,Beam::calc_beaming)
        (stencil . ,Beam::print)
 
        ;; TODO: should be in SLT.