]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/slur.cc (outside_slur_callback): make offset_scm optional.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 3 Oct 2006 12:00:17 +0000 (12:00 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 3 Oct 2006 12:00:17 +0000 (12:00 +0000)
* lily/beam.cc (rest_collision_callback): make prev_offset optional.

* lily/grob-closure.cc (chain_offset_callback): don't pass 0 but
SCM_UNDEFINED for non-existent data.

* lily/side-position-interface.cc (general_side_position): allow
optional current_offset argument for chaining, so combinations of side-position
and outside slur callback don't add up.  Fixes issue #92.

14 files changed:
ChangeLog
lily/beam.cc
lily/context.cc
lily/dot-column.cc
lily/grob-closure.cc
lily/include/lily-guile-macros.hh
lily/include/side-position-interface.hh
lily/music-function.cc
lily/prob.cc
lily/rest-collision.cc
lily/side-position-interface.cc
lily/simple-closure.cc
lily/slur.cc
lily/smobs.cc

index 617631eda3aae4c90f7f67afdb4040bcf38f883a..2d7d3e60cfb8193c3657f75cd049c76ff1aef73c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,20 @@
 2006-10-03  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
-       * lily/pango-font.cc (pango_item_string_stencil): use
-       logical_rect. This prevents spaces after words from disappearing.
+       * lily/slur.cc (outside_slur_callback): make offset_scm optional.
+
+       * lily/beam.cc (rest_collision_callback): make prev_offset optional.
+
+       * lily/grob-closure.cc (chain_offset_callback): don't pass 0 but
+       SCM_UNDEFINED for non-existent data.
 
+       * lily/side-position-interface.cc (general_side_position): allow
+       optional current_offset argument for chaining, so combinations of side-position
+       and outside slur callback don't add up.  Fixes issue #92.
+
+       * lily/pango-font.cc (pango_item_string_stencil): use
+       logical_rect. This prevents spaces after words from disappearing,
+       issue #72.
+       
        * VERSION: release 2.9.20
 
 2006-10-02  Han-Wen Nienhuys  <hanwen@lilypond.org>
index c52b6f14f974f567a52fad449e4987dbc6161d8f..4a59a069be9ae407f2b5786d87eff2f92d76d288 100644 (file)
@@ -1301,7 +1301,7 @@ Beam::last_visible_stem (Grob *me)
 
   rest -> stem -> beam -> interpolate_y_position ()
 */
-MAKE_SCHEME_CALLBACK (Beam, rest_collision_callback, 2);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, rest_collision_callback, 2, 1);
 SCM
 Beam::rest_collision_callback (SCM smob, SCM prev_offset)
 {
index d8e5b7bfba32b341f2523cff06350e356d22cc5c..629dfadc4f8aa061155c4361be57e2ecdfe5a568 100644 (file)
@@ -469,15 +469,14 @@ Context::add_alias (SCM sym)
 }
 
 void
+Context::internal_set_property (SCM sym, SCM val
 #ifndef NDEBUG
-Context::internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun)
+                               , char const *file, int line, char const *fun
+#endif
+                               )
 {
   if (do_internal_type_checking_global)
     assert (type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")));
-#else
-Context::internal_set_property (SCM sym, SCM val)
-{
-#endif
 
   properties_dict ()->set (sym, val);
 }
index ac76bd4a1631782cf6994b40b9d864680ac07252..a4b13be79f1d9287746704182654780e92371036 100644 (file)
@@ -51,7 +51,7 @@ Dot_column::side_position (SCM smob)
        }
     }
 
-  return Side_position_interface::x_aligned_side (smob);
+  return Side_position_interface::x_aligned_side (smob, SCM_EOL);
 }
 
 struct Dot_position
index 9dddc0616f85a11241992a4e39d1a4967253e910..5e4035f7e898f343b0b22469ec8d3bd03309ea63 100644 (file)
@@ -75,9 +75,14 @@ chain_offset_callback (Grob *g, SCM proc, Axis a)
     data = ly_make_simple_closure (scm_list_1  (data));
   else if (is_simple_closure (data))
     data = simple_closure_expression (data);
-  else if (!scm_is_number (data))
-    data = scm_from_int (0);
-  
+  else
+    /*
+      Data may be nonnumber. In that case, it is assumed to be
+      undefined.
+    */
+    
+    data = SCM_UNDEFINED;
+
   SCM expr = scm_list_2 (proc, data);
   g->set_property (axis_offset_symbol (a),
                   
index 77c45973648e33f0888c3be00c2c62bc4298f2e1..3f72caddc4ddaf539833620663a24c6d03525278 100644 (file)
 #define SCM_UNPACK(x) (x)
 #endif
 
-#if (__GNUC__ > 2)
 /* Unreliable with gcc-2.x
    FIXME: should add check for x86 as well?  */
 #define CACHE_SYMBOLS
-#endif
+
+
+
 
 #ifdef CACHE_SYMBOLS
 
@@ -41,8 +42,7 @@ scm_or_str2symbol (SCM s) { return s; }
    "fooo" is a constant string. This is done at the cost of one static
    variable per ly_symbol2scm() use, and one boolean evaluation for
    every call.
-
-   The overall speedup of lily is about 5% on a run of wtk1-fugue2.  */
+ */
 #define ly_symbol2scm(x)                                               \
   ({                                                                   \
     static SCM cached;                                                 \
index ea7655fa626f3cf03306e474a4467fc39429d61c..36b1e8fdf59030697495a29bf9881d563105af9d 100644 (file)
@@ -23,13 +23,14 @@ public:
 
   DECLARE_SCHEME_CALLBACK (y_aligned_on_support_refpoints, (SCM element));
   DECLARE_SCHEME_CALLBACK (pure_y_aligned_on_support_refpoints, (SCM element, SCM start, SCM end));
-  DECLARE_SCHEME_CALLBACK (x_aligned_side, (SCM element));
-  DECLARE_SCHEME_CALLBACK (y_aligned_side, (SCM element));
+  DECLARE_SCHEME_CALLBACK (x_aligned_side, (SCM element, SCM current));
+  DECLARE_SCHEME_CALLBACK (y_aligned_side, (SCM element, SCM current));
   DECLARE_SCHEME_CALLBACK (pure_y_aligned_side, (SCM element, SCM start, SCM end));
 
-  static SCM aligned_side (Grob*me, Axis a, bool pure, int start, int end);
+  static SCM aligned_side (Grob*me, Axis a, bool pure, int start, int end, Real *current_off_ptr);
 
-  static SCM general_side_position (Grob *, Axis, bool, bool pure, int start, int end);
+  static SCM general_side_position (Grob *, Axis, bool, bool my_extents,
+                                   bool pure, int start, int end, Real *current_off);
   static Axis get_axis (Grob *);
   static void set_axis (Grob *, Axis);
   static bool has_interface (Grob *);
index c9b9a07658cdf01ab1b4b9185934fa9d07c639d4..6795ca67d4566c7aa1fb41b01bfaf0a62ccda08d 100644 (file)
@@ -33,8 +33,6 @@ LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
           "Its arguments. @code{signature} is a list containing either "
           "@code{ly:music?} predicates or other type predicates.")
 {
-  extern SCM ly_music_p_proc;
-  
   scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"),
                             signature);
 
index eecd1a4446878c768f7c4c07f16ef3037f7b4764..bff24e5adeb5d998d58d6deaa3e00f50e3a6e8d2 100644 (file)
@@ -99,11 +99,11 @@ Prob::internal_get_property (SCM sym) const
 }
 
 void
+Prob::internal_set_property (SCM sym, SCM val
 #ifndef NDEBUG
-Prob::internal_set_property (SCM sym, SCM val, char const *file, int line, char const *fun) 
-#else
-Prob::internal_set_property (SCM sym, SCM val)
+                            , char const *file, int line, char const *fun
 #endif
+                            ) 
 {
   if (do_internal_type_checking_global)
     type_check_assignment (sym, val);
index a2c9fa63c0e7e497ab6f22a6f1b9d7238384635c..959bf2156b25338711cab33e5430dcd923a4c4ab 100644 (file)
@@ -40,7 +40,7 @@ Rest_collision::force_shift_callback (SCM smob)
   return scm_from_double (0.0);
 }
 
-MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Rest_collision, force_shift_callback_rest, 2, 1);
 SCM
 Rest_collision::force_shift_callback_rest (SCM rest, SCM offset)
 {
@@ -51,7 +51,8 @@ Rest_collision::force_shift_callback_rest (SCM rest, SCM offset)
     translate REST; we need the result of this translation later on,
     while the offset probably still is 0/calculation-in-progress.
    */
-  rest_grob->translate_axis (scm_to_double (offset), Y_AXIS);
+  if (scm_is_number (offset))
+    rest_grob->translate_axis (scm_to_double (offset), Y_AXIS);
   
   if (Note_column::has_interface (parent))
     force_shift_callback (parent->self_scm ());
index 52e9ba5221f74ba043ab6109c72ff49c000d8a8f..38880cb52ef9d201927ae4229e7b97250513628c 100644 (file)
@@ -46,10 +46,15 @@ Side_position_interface::get_direction (Grob *me)
 }
 
 /* Put the element next to the support, optionally taking in
-   account the extent of the support.  */
+   account the extent of the support.
+
+   Does not take into account the extent of ME.
+*/
 SCM
 Side_position_interface::general_side_position (Grob *me, Axis a, bool use_extents,
-                                               bool pure, int start, int end)
+                                               bool include_my_extent,
+                                               bool pure, int start, int end,
+                                               Real *current_offset)
 {
   Real ss = Staff_symbol_referencer::staff_space (me);
 
@@ -102,6 +107,25 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten
       && dir
       && total_off * dir < minimum_space)
     total_off = minimum_space * dir;
+
+  if (include_my_extent)
+    {
+      Interval iv = me->maybe_pure_extent (me, a, pure, start, end);
+      if (!iv.is_empty ())
+       {
+         if (!dir)
+           {
+             programming_error ("direction unknown, but aligned-side wanted");
+             dir = DOWN;
+           }
+         total_off += -iv[-dir];
+       }
+    }
+
+  if (current_offset)
+    total_off = dir * max (dir * total_off,
+                          dir * (*current_offset));
+  
   
   /* FIXME: 1000 should relate to paper size.  */
   if (fabs (total_off) > 1000)
@@ -122,60 +146,64 @@ MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_on_support_refpoints, 1
 SCM
 Side_position_interface::y_aligned_on_support_refpoints (SCM smob)
 {
-  return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, 0, 0); 
+  return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, false, 0, 0, 0); 
 }
 
 MAKE_SCHEME_CALLBACK (Side_position_interface, pure_y_aligned_on_support_refpoints, 3);
 SCM
 Side_position_interface::pure_y_aligned_on_support_refpoints (SCM smob, SCM start, SCM end)
 {
-  return general_side_position (unsmob_grob (smob), Y_AXIS, false,
-                               true, scm_to_int (start), scm_to_int (end)); 
+  return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, 
+                               true, scm_to_int (start), scm_to_int (end), 0); 
 }
 
 
 /*
   Position next to support, taking into account my own dimensions and padding.
 */
+SCM
+axis_aligned_side_helper (SCM smob, Axis a, bool pure, int start, int end, SCM current_off_scm)
+{
+  Real r;
+  Real *current_off_ptr = 0;
+  if (scm_is_number (current_off_scm))
+    {
+      r = scm_to_double (current_off_scm);
+      current_off_ptr = &r; 
+    }
+  
+  return Side_position_interface::aligned_side (unsmob_grob (smob), a, pure, start, end, current_off_ptr);
+}
+
 
-MAKE_SCHEME_CALLBACK (Side_position_interface, x_aligned_side, 1);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Side_position_interface, x_aligned_side, 2, 1);
 SCM
-Side_position_interface::x_aligned_side (SCM smob)
+Side_position_interface::x_aligned_side (SCM smob, SCM current_off)
 {
-  return aligned_side (unsmob_grob (smob), X_AXIS, false, 0, 0);
+  return axis_aligned_side_helper (smob, X_AXIS, false, 0, 0, current_off);
 }
 
-MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_side, 1);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Side_position_interface, y_aligned_side, 2, 1);
 SCM
-Side_position_interface::y_aligned_side (SCM smob)
+Side_position_interface::y_aligned_side (SCM smob, SCM current_off)
 {
-  return aligned_side (unsmob_grob (smob), Y_AXIS, false, 0, 0);
+  return axis_aligned_side_helper (smob, Y_AXIS, false, 0, 0, current_off);
 }
 
 MAKE_SCHEME_CALLBACK (Side_position_interface, pure_y_aligned_side, 3);
 SCM
 Side_position_interface::pure_y_aligned_side (SCM smob, SCM start, SCM end)
 {
-  return aligned_side (unsmob_grob (smob), Y_AXIS, true, scm_to_int (start), scm_to_int (end));
+  return aligned_side (unsmob_grob (smob), Y_AXIS, true, scm_to_int (start), scm_to_int (end), 0);
 }
 
 SCM
-Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, int end)
+Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, int end,
+                                      Real *current_off)
 {
   Direction dir = get_grob_direction (me);
 
-  Real o = scm_to_double (general_side_position (me, a, true, pure, start, end));
-  Interval iv = me->maybe_pure_extent (me, a, pure, start, end);
-
-  if (!iv.is_empty ())
-    {
-      if (!dir)
-       {
-         programming_error ("direction unknown, but aligned-side wanted");
-         dir = DOWN;
-       }
-      o += -iv[-dir];
-    }
+  Real o = scm_to_double (general_side_position (me, a, true, true, pure, start, end, current_off));
 
   /*
     Maintain a minimum distance to the staff. This is similar to side
@@ -206,6 +234,8 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
        }
       else if (scm_is_number (me->get_property ("staff-padding")))
        {
+         Interval iv = me->maybe_pure_extent (me, a, pure, start, end);
+         
          Real padding
            = Staff_symbol_referencer::staff_space (me)
            * scm_to_double (me->get_property ("staff-padding"));
@@ -226,11 +256,11 @@ Side_position_interface::set_axis (Grob *me, Axis a)
   if (!scm_is_number (me->get_property ("side-axis")))
     {
       me->set_property ("side-axis", scm_from_int (a));
-      add_offset_callback (me,
-                          (a==X_AXIS)
-                          ? x_aligned_side_proc
-                          : y_aligned_side_proc,
-                          a);
+      chain_offset_callback (me,
+                            (a==X_AXIS)
+                            ? x_aligned_side_proc
+                            : y_aligned_side_proc,
+                            a);
     }
 }
 Axis
index db19cfc38c091aff26955e0475d60500c8086898..77764b2bc6a1f6ee908bb86ff14be2f2e9b7b042 100644 (file)
@@ -63,7 +63,7 @@ evaluate_with_simple_closure (SCM delayed_argument,
     }
   else
     // ugh. deviation from standard. Should print error? 
-    return  evaluate_args (delayed_argument, scm_cdr (expr)); 
+    return evaluate_args (delayed_argument, scm_cdr (expr)); 
   
   assert (false);
   return SCM_EOL;
index c78a066d065cc5069995adea3c86de5ae7c81cd1..d8c81f7836337258a4d1a09e9344d1a8f1f24070 100644 (file)
@@ -186,7 +186,7 @@ Slur::add_extra_encompass (Grob *me, Grob *n)
 }
 
 
-MAKE_SCHEME_CALLBACK (Slur, outside_slur_callback, 2);
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, outside_slur_callback, 2, 1);
 SCM
 Slur::outside_slur_callback (SCM grob, SCM offset_scm)
 {
@@ -216,8 +216,8 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm)
   Interval yext = robust_relative_extent (script, cy, Y_AXIS);
   Interval xext = robust_relative_extent (script, cx, X_AXIS);
 
-  yext.translate (robust_scm2double (offset_scm, 0));
-  
+  Real offset = robust_scm2double (offset_scm, 0);
+  yext.translate (offset);
   
   /* FIXME: slur property, script property?  */
   Real slur_padding = robust_scm2double (script->get_property ("slur-padding"),
@@ -258,7 +258,7 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm)
       avoidance_offset = dir * (max (dir * avoidance_offset,
                                     dir * (ys[k] - yext[-dir] + dir * slur_padding)));
   
-  return scm_from_double (scm_to_double (offset_scm) + avoidance_offset);
+  return scm_from_double (offset + avoidance_offset);
 }
 
 /*
index 9629ed45ee610702f2d3e4b1024b56be9e3ac693..fff178ccb27746376a66c6ce24a9e84318821297 100644 (file)
@@ -44,6 +44,7 @@ protect_smob (SCM smob, SCM *prot_cons)
                 prot);
   *prot_cons = prot;
 #else
+  (void) prot_cons; 
   scm_gc_protect_object (smob);
 #endif
 }
@@ -52,6 +53,7 @@ void
 unprotect_smob (SCM smob, SCM *prot_cons)
 {
 #if 1
+  (void) prot_cons; 
   scm_gc_unprotect_object (smob);
 #else
   SCM next = scm_cdr (*prot_cons);