* 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.
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>
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)
{
}
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);
}
}
}
- return Side_position_interface::x_aligned_side (smob);
+ return Side_position_interface::x_aligned_side (smob, SCM_EOL);
}
struct Dot_position
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),
#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
"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; \
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 *);
"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);
}
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);
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)
{
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 ());
}
/* 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);
&& 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)
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
}
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"));
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
}
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;
}
-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)
{
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"),
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);
}
/*
prot);
*prot_cons = prot;
#else
+ (void) prot_cons;
scm_gc_protect_object (smob);
#endif
}
unprotect_smob (SCM smob, SCM *prot_cons)
{
#if 1
+ (void) prot_cons;
scm_gc_unprotect_object (smob);
#else
SCM next = scm_cdr (*prot_cons);