X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frest-collision.cc;h=7648f6d9a09825109e54f879442e3b3d1c2f2fca;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=8ba647e2019d8201d3698dbaa39cdd74f6671e90;hpb=caac677710724849651381d11577f61dd9618bcf;p=lilypond.git diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 8ba647e201..7648f6d9a0 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1997--2012 Han-Wen Nienhuys + Copyright (C) 1997--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,13 +34,14 @@ using namespace std; #include "staff-symbol-referencer.hh" #include "stem.hh" #include "grob.hh" +#include "unpure-pure-container.hh" #include "warn.hh" MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Rest_collision, force_shift_callback_rest, 2, 1, ""); SCM Rest_collision::force_shift_callback_rest (SCM rest, SCM offset) { - Grob *rest_grob = unsmob_grob (rest); + Grob *rest_grob = Grob::unsmob (rest); Grob *parent = rest_grob->get_parent (X_AXIS); /* @@ -52,7 +53,7 @@ Rest_collision::force_shift_callback_rest (SCM rest, SCM offset) if (Note_column::has_interface (parent) && Note_column::has_rests (parent)) { - Grob *collision = unsmob_grob (parent->get_object ("rest-collision")); + Grob *collision = Grob::unsmob (parent->get_object ("rest-collision")); if (collision) (void) collision->get_property ("positioning-done"); @@ -68,11 +69,14 @@ Rest_collision::add_column (Grob *me, Grob *p) p->set_object ("rest-collision", me->self_scm ()); - Grob *rest = unsmob_grob (p->get_object ("rest")); + Grob *rest = Grob::unsmob (p->get_object ("rest")); if (rest) { chain_offset_callback (rest, - Rest_collision::force_shift_callback_rest_proc, Y_AXIS); + Unpure_pure_container::make_smob + (Rest_collision::force_shift_callback_rest_proc, + ly_lily_module_constant ("pure-chain-offset-callback")), + Y_AXIS); } } @@ -92,7 +96,7 @@ MAKE_SCHEME_CALLBACK (Rest_collision, calc_positioning_done, 1); SCM Rest_collision::calc_positioning_done (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = Grob::unsmob (smob); me->set_property ("positioning-done", SCM_BOOL_T); @@ -104,10 +108,13 @@ Rest_collision::calc_positioning_done (SCM smob) for (vsize i = 0; i < elts.size (); i++) { Grob *e = elts[i]; - if (unsmob_grob (e->get_object ("rest"))) - rests.push_back (e); - else - notes.push_back (e); + if (Note_column::has_interface (e)) + { + if (Grob::unsmob (e->get_object ("rest"))) + rests.push_back (e); + else + notes.push_back (e); + } } /* @@ -149,7 +156,6 @@ Rest_collision::calc_positioning_done (SCM smob) for (LEFT_and_RIGHT (d)) vector_sort (ordered_rests[d], rest_shift_less); - for (LEFT_and_RIGHT (d)) { if (ordered_rests[d].size () < 1) @@ -250,19 +256,14 @@ Rest_collision::calc_positioning_done (SCM smob) Real y = dir * max (0.0, -dir * restdim[-dir] + dir * notedim[dir] + minimum_dist); - int stafflines = Staff_symbol_referencer::line_count (me); - if (!stafflines) - { - programming_error ("no staff line count"); - stafflines = 5; - } - // move discretely by half spaces. int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space))); + Interval staff_span = Staff_symbol_referencer::staff_span (rest); + staff_span.widen (1); // move by whole spaces inside the staff. - if (fabs (Staff_symbol_referencer::get_position (rest) - + discrete_y) < stafflines + 1) + if (staff_span.contains + (Staff_symbol_referencer::get_position (rest) + discrete_y)) { discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0); }