X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-collision.cc;h=50958af832b8d4360f6f30c884f2f4bf110e97ce;hb=33f2e59ea0b2a1ba41e943b5afa29e5fee97ba94;hp=fa977fda00bfaa57df9d7414d745639f7271d986;hpb=c89de2a770104af7b014bd4674e871957951e8fb;p=lilypond.git diff --git a/lily/note-collision.cc b/lily/note-collision.cc index fa977fda00..50958af832 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -4,10 +4,10 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2002 Han-Wen Nienhuys + (c) 1997--2003 Han-Wen Nienhuys */ -#include "debug.hh" +#include "warn.hh" #include "note-collision.hh" #include "note-column.hh" #include "note-head.hh" @@ -28,9 +28,9 @@ Note_collision_interface::force_shift_callback (SCM element_smob, SCM axis) me = me->get_parent (a); - if (! to_boolean (me->get_grob_property ("collision-done"))) + if (! to_boolean (me->get_grob_property ("positioning-done"))) { - me->set_grob_property ("collision-done", SCM_BOOL_T); + me->set_grob_property ("positioning-done", SCM_BOOL_T); do_shifts (me); } @@ -52,8 +52,8 @@ check_meshing_chords (Grob*me, Grob *cu =clash_groups[UP][0]; Grob *cd =clash_groups[DOWN][0]; - Grob * nu_l= Note_column::first_head (cu); - Grob * nd_l = Note_column::first_head (cd); + Grob * nu= Note_column::first_head (cu); + Grob * nd = Note_column::first_head (cd); @@ -80,6 +80,14 @@ check_meshing_chords (Grob*me, bool distant_half_collide = false; bool full_collide = false; + /* + Let's not crash. + */ + if (!Note_column::get_stem (cu) + || !Note_column::get_stem (cd)) + return ; + + /* TODO: @@ -93,8 +101,8 @@ check_meshing_chords (Grob*me, */ - Array ups = Stem::note_head_positions (Note_column::stem_l (cu)); - Array dps = Stem::note_head_positions (Note_column::stem_l (cd)); + Array ups = Stem::note_head_positions (Note_column::get_stem (cu)); + Array dps = Stem::note_head_positions (Note_column::get_stem (cd)); /* they're too far apart to collide. @@ -112,13 +120,13 @@ check_meshing_chords (Grob*me, don't merge whole notes (or longer, like breve, longa, maxima) */ - int upball_type = Note_head::balltype_i (nu_l); - int dnball_type = Note_head::balltype_i (nd_l); + int upball_type = Note_head::get_balltype (nu); + int dnball_type = Note_head::get_balltype (nd); merge_possible = merge_possible && (upball_type > 0); if (!to_boolean (me->get_grob_property ("merge-differently-dotted"))) - merge_possible = merge_possible && Rhythmic_head::dot_count (nu_l) == Rhythmic_head::dot_count (nd_l); + merge_possible = merge_possible && Rhythmic_head::dot_count (nu) == Rhythmic_head::dot_count (nd); if (!to_boolean (me->get_grob_property ("merge-differently-headed"))) @@ -129,10 +137,10 @@ check_meshing_chords (Grob*me, Can't merge quarter and half notes. */ merge_possible = merge_possible && - !((Rhythmic_head::duration_log (nu_l) == 1 - && Rhythmic_head::duration_log (nd_l) == 2) - ||(Rhythmic_head::duration_log (nu_l) == 2 - && Rhythmic_head::duration_log (nd_l) == 1)); + !((Rhythmic_head::duration_log (nu) == 1 + && Rhythmic_head::duration_log (nd) == 2) + ||(Rhythmic_head::duration_log (nu) == 2 + && Rhythmic_head::duration_log (nd) == 1)); int i = 0, j=0; while (i < ups.size () && j < dps.size ()) @@ -177,7 +185,7 @@ check_meshing_chords (Grob*me, for full collisions, the right hand head may obscure dots, so make sure the dotted heads go to the right. */ - if ((Rhythmic_head::dot_count (nu_l) > Rhythmic_head::dot_count (nd_l) + if ((Rhythmic_head::dot_count (nu) > Rhythmic_head::dot_count (nd) && full_collide)) shift_amount = 1; @@ -191,14 +199,23 @@ check_meshing_chords (Grob*me, Grob *wipe_ball = 0; if (upball_type < dnball_type) - wipe_ball = nd_l; + wipe_ball = nd; else if (upball_type > dnball_type) - wipe_ball = nu_l; + wipe_ball = nu; - if (wipe_ball) + if (wipe_ball && wipe_ball->live ()) { wipe_ball->set_grob_property ("transparent", SCM_BOOL_T); - wipe_ball->set_grob_property ("molecule", SCM_EOL); + wipe_ball->set_grob_property ("molecule", SCM_EOL); + + if (Grob *d = unsmob_grob (wipe_ball->get_grob_property ("dot"))) + d->suicide (); + } + + if (wipe_ball == 0 + && unsmob_grob (nd->get_grob_property ("dot"))) + { + unsmob_grob (nd->get_grob_property ("dot"))->suicide (); } } else if (close_half_collide && !touch) @@ -211,7 +228,7 @@ check_meshing_chords (Grob*me, /* we're meshing. */ - else if (Rhythmic_head::dot_count (nu_l) || Rhythmic_head::dot_count (nd_l)) + else if (Rhythmic_head::dot_count (nu) || Rhythmic_head::dot_count (nd)) shift_amount *= 0.1; else shift_amount *= 0.25; @@ -263,7 +280,7 @@ Note_collision_interface::do_shifts (Grob* me) Grob * s = unsmob_grob (ly_caar (autos)); Real amount = gh_scm2double (ly_cdar (autos)); - if (!done.find_l (s)) + if (!done.find (s)) s->translate_axis (amount * wid, X_AXIS); } } @@ -329,7 +346,7 @@ Note_collision_interface::automatic_shift (Grob *me, { if (shift[i-1] == shift[i]) { - me->warning (_ ("Too many clashing notecolumns. Ignoring them.")); + clashes[0]->warning (_ ("Too many clashing notecolumns. Ignoring them.")); return tups; } } @@ -403,7 +420,7 @@ Note_collision_interface::forced_shift (Grob *me) { Grob * se = unsmob_grob (ly_car (s)); - SCM force = se->remove_grob_property ("force-hshift"); + SCM force = se->get_grob_property ("force-hshift"); if (gh_number_p (force)) { tups = gh_cons (gh_cons (se->self_scm (), force), @@ -414,18 +431,17 @@ Note_collision_interface::forced_shift (Grob *me) } void -Note_collision_interface::add_column (Grob*me,Grob* ncol_l) +Note_collision_interface::add_column (Grob*me,Grob* ncol) { - ncol_l->add_offset_callback (Note_collision_interface::force_shift_callback_proc, X_AXIS); - Axis_group_interface::add_element (me, ncol_l); - me->add_dependency (ncol_l); + ncol->add_offset_callback (Note_collision_interface::force_shift_callback_proc, X_AXIS); + Axis_group_interface::add_element (me, ncol); + me->add_dependency (ncol); } ADD_INTERFACE (Note_collision_interface, "note-collision-interface", - "An object that handles collisions between notes with different stem -directions and horizontal shifts. Most of the interesting properties -are to be set in @ref{note-column-interface}: these are -@code{force-hshift} and @{horizontal-shift}. -", - "merge-differently-dotted merge-differently-headed collision-done"); + "An object that handles collisions between notes with different stem " +"directions and horizontal shifts. Most of the interesting properties " +"are to be set in @ref{note-column-interface}: these are " +"@code{force-hshift} and @code{horizontal-shift}. ", + "merge-differently-dotted merge-differently-headed positioning-done");