(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "rest-collision.hh"
+
#include <math.h> // ceil.
#include "warn.hh"
-#include "rest-collision.hh"
#include "note-column.hh"
#include "stem.hh"
#include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
#include "rest.hh"
#include "group-interface.hh"
#include "staff-symbol-referencer.hh"
Rest_collision::force_shift_callback (SCM element_smob, SCM axis)
{
Grob *them = unsmob_grob (element_smob);
- Axis a = (Axis) ly_scm2int (axis);
+ Axis a = (Axis) scm_to_int (axis);
assert (a == Y_AXIS);
- Grob * rc = unsmob_grob (them->get_property ("rest-collision"));
-
- if (rc && !to_boolean (rc->get_property ("positioning-done")))
- {
- rc->set_property ("positioning-done", SCM_BOOL_T);
+ if (Note_column::has_rests (them))
+ {
+ Grob * rc = unsmob_grob (them->get_property ("rest-collision"));
- do_shift (rc);
- }
-
+ if (rc && !to_boolean (rc->get_property ("positioning-done")))
+ {
+ rc->set_property ("positioning-done", SCM_BOOL_T);
+ do_shift (rc);
+ }
+ }
return scm_make_real (0.0);
}
}
-/*
- Combination of dot-count and duration-log.
- */
-static SCM
-head_characteristic (Grob * col)
-{
- Grob * s = unsmob_grob (col->get_property ("rest"));
-
- if (!s)
- return SCM_BOOL_F;
- else
- return scm_cons (s->get_property ("duration-log"),
- scm_int2num (Rhythmic_head::dot_count (s)));
-}
/*
TODO: look at horizontal-shift to determine ordering between rests
Link_array<Grob> rests;
Link_array<Grob> notes;
- for (SCM s = elts; ly_pair_p (s); s = ly_cdr (s))
+ for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
{
- Grob * e = unsmob_grob (ly_car (s));
+ Grob * e = unsmob_grob (scm_car (s));
if (unsmob_grob (e->get_property ("rest")))
{
/*
center one should be centered on the staff.
*/
Drul_array< Link_array <Grob > > ordered_rests;
- for (int i= 0; i < rests.size (); i++)
+ for (int i = 0; i < rests.size (); i++)
{
Grob * r = Note_column::get_rest (rests[i]);
ordered_rests[d].sort (Note_column::shift_compare);
} while (flip (&d) != LEFT);
- if (ordered_rests[UP].size () + ordered_rests[DOWN].size () < 2)
- return SCM_UNSPECIFIED;
+ do {
+ if (ordered_rests[d].size () < 1)
+ {
+ if (ordered_rests[-d].size() > 1)
+ ordered_rests[-d][0]->warning (_ ("too many colliding rests"));
+
+ return SCM_UNSPECIFIED;
+ }
+ } while (flip (&d) != LEFT);
Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS);
common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
Grob * rcol = 0;
Direction dir = CENTER;
- for (int i= rests.size (); !rcol && i--;)
+ for (int i = rests.size (); !rcol && i--;)
if (Note_column::dir (rests[i]))
{
dir = Note_column::dir (rests[i]);
ADD_INTERFACE (Rest_collision,"rest-collision-interface",
- "Move around ordinary rests (not multi-measure-rests) to avoid "
-"conflicts.",
- "minimum-distance positioning-done elements");
+ "Move around ordinary rests (not multi-measure-rests) to avoid "
+ "conflicts.",
+ "minimum-distance positioning-done elements");