source file of the GNU LilyPond music typesetter
- (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+
#include "debug.hh"
#include "collision.hh"
#include "note-column.hh"
#include "item.hh"
-MAKE_SCHEME_CALLBACK(Collision,force_shift_callback,2);
+MAKE_SCHEME_CALLBACK (Collision,force_shift_callback,2);
+
SCM
Collision::force_shift_callback (SCM element_smob, SCM axis)
{
- Grob *me = unsmob_element (element_smob);
+ Grob *me = unsmob_grob (element_smob);
Axis a = (Axis) gh_scm2int (axis);
assert (a == X_AXIS);
/*
ugh. the way DONE is done is not clean
*/
- if (!unsmob_element (me->get_grob_property ("done")))
+ if (!unsmob_grob (me->get_grob_property ("done")))
{
me->set_grob_property ("done", me->self_scm ());
do_shifts (me);
/*
TODO: make callback of this.
+
+ TODO:
+
+ note-width is hardcoded, making it difficult to handle all note
+ heads sanely. We should really look at the widths of the colliding
+ columns, and have a separate setting for "align stems".
+
+
*/
void
-Collision::do_shifts(Grob* me)
+Collision::do_shifts (Grob* me)
{
SCM autos (automatic_shift (me));
SCM hand (forced_shift (me));
Link_array<Grob> done;
-
+
+
Real wid
= gh_scm2double (me->get_grob_property ("note-width"));
for (; gh_pair_p (hand); hand =gh_cdr (hand))
{
- Grob * s = unsmob_element (gh_caar (hand));
+ Grob * s = unsmob_grob (gh_caar (hand));
Real amount = gh_scm2double (gh_cdar (hand));
s->translate_axis (amount *wid, X_AXIS);
}
for (; gh_pair_p (autos); autos =gh_cdr (autos))
{
- Grob * s = unsmob_element (gh_caar (autos));
+ Grob * s = unsmob_grob (gh_caar (autos));
Real amount = gh_scm2double (gh_cdar (autos));
if (!done.find_l (s))
{
SCM car = gh_car (s);
- Grob * se = unsmob_element (car);
+ Grob * se = unsmob_grob (car);
if (Note_column::has_interface (se))
clash_groups[Note_column::dir (se)].push (se);
}
{
for (int i=0; i < clash_groups[d].size (); i++)
{
- Slice s(Note_column::head_positions_interval (clash_groups[d][i]));
+ Slice s (Note_column::head_positions_interval (clash_groups[d][i]));
s[LEFT] --;
s[RIGHT]++;
extents[d].push (s);
Slice prev =extents[d][i-1];
prev.intersect (extents[d][i]);
if (prev.length ()> 0 ||
- (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0))
+ (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0))
for (int j = i; j < clash_groups[d].size (); j++)
offsets[d][j] += d * 0.5;
}
/*
TODO.
*/
- Grob * nu_l= Note_column::first_head(cu_l);
- Grob * nd_l = Note_column::first_head(cd_l);
+ Grob * nu_l= Note_column::first_head (cu_l);
+ Grob * nd_l = Note_column::first_head (cd_l);
int downpos = Note_column::head_positions_interval (cd_l)[BIGGER];
int uppos = Note_column::head_positions_interval (cu_l)[SMALLER];
/*
notes are close, but can not be merged. Shift
*/
- if (abs(uppos - downpos) < 2 && !merge)
+ if (abs (uppos - downpos) < 2 && !merge)
do
{
for (int i=0; i < clash_groups[d].size (); i++)
SCM s = me->get_grob_property ("elements");
for (; gh_pair_p (s); s = gh_cdr (s))
{
- Grob * se = unsmob_element (gh_car (s));
+ Grob * se = unsmob_grob (gh_car (s));
SCM force = se->remove_grob_property ("force-hshift");
if (gh_number_p (force))
return tups;
}
-
-
-
void
Collision::add_column (Grob*me,Grob* ncol_l)
{