source file of the GNU LilyPond music typesetter
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include "rest-collision.hh"
-#include <math.h> // ceil.
+#include <cmath> // ceil.
+using namespace std;
#include "warn.hh"
#include "note-column.hh"
#include "duration.hh"
#include "directional-element-interface.hh"
-MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback, 2);
+MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback, 1);
SCM
-Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
+Rest_collision::force_shift_callback (SCM smob)
{
- Grob *them = unsmob_grob (element_smob);
- (void) axis;
- assert (scm_to_int (axis) == Y_AXIS);
-
+ Grob *them = unsmob_grob (smob);
if (Note_column::has_rests (them))
{
- Grob *rc = unsmob_grob (them->get_object ("rest-collision"));
+ Grob *collision = unsmob_grob (them->get_object ("rest-collision"));
- if (rc && !to_boolean (rc->get_property ("positioning-done")))
+ if (collision)
{
- rc->set_property ("positioning-done", SCM_BOOL_T);
- do_shift (rc);
+ (void) collision->get_property ("positioning-done");
}
}
return scm_from_double (0.0);
MAKE_SCHEME_CALLBACK (Rest_collision, force_shift_callback_rest, 2);
SCM
-Rest_collision::force_shift_callback_rest (SCM rest, SCM axis)
+Rest_collision::force_shift_callback_rest (SCM rest, SCM offset)
{
Grob *rest_grob = unsmob_grob (rest);
- assert ((Axis) scm_to_int (axis) == Y_AXIS);
-
Grob *parent = rest_grob->get_parent (X_AXIS);
+
+ /*
+ 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 (Note_column::has_interface (parent))
- return force_shift_callback (parent->self_scm (), axis);
- else
- return scm_from_double (0.0);
+ force_shift_callback (parent->self_scm ());
+
+ return scm_from_double (0.0);
}
void
Rest_collision::add_column (Grob *me, Grob *p)
{
- me->add_dependency (p);
Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), p);
/*
(not?)
*/
- p->add_offset_callback (Rest_collision::force_shift_callback_proc, Y_AXIS);
+ add_offset_callback (p, Rest_collision::force_shift_callback_proc, Y_AXIS);
p->set_object ("rest-collision", me->self_scm ());
Grob *rest = unsmob_grob (p->get_object ("rest"));
if (rest)
{
- rest->add_offset_callback (Rest_collision::force_shift_callback_rest_proc,
- Y_AXIS);
+ chain_offset_callback (rest,
+ Rest_collision::force_shift_callback_rest_proc, Y_AXIS);
}
}
TODO: look at horizontal-shift to determine ordering between rests
for more than two voices.
*/
+MAKE_SCHEME_CALLBACK(Rest_collision, calc_positioning_done, 1);
SCM
-Rest_collision::do_shift (Grob *me)
+Rest_collision::calc_positioning_done (SCM smob)
{
+ Grob *me = unsmob_grob (smob);
extract_grob_set (me, "elements", elts);
Link_array<Grob> rests;
if (d)
ordered_rests[d].push (rests[i]);
else
- rests[d]->warning (_ ("can't resolve rest collission: rest direction not set"));
+ rests[d]->warning (_ ("can't resolve rest collision: rest direction not set"));
}
Direction d = LEFT;
ADD_INTERFACE (Rest_collision, "rest-collision-interface",
"Move around ordinary rests (not multi-measure-rests) to avoid "
"conflicts.",
- "minimum-distance positioning-done elements");
+
+ /* properties */
+ "minimum-distance "
+ "positioning-done "
+ "elements");