X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frest.cc;h=8e45405de278dbd4ea5040dfc3259c6a2164a112;hb=8b77ad1750c202c78f4ea81844f7c93ef40aa400;hp=a25e6a93198298ef4d8ca778dbded2379e583365;hpb=ebe492ca408fb0d9abf80b94c56197eef8dc2f09;p=lilypond.git diff --git a/lily/rest.cc b/lily/rest.cc index a25e6a9319..8e45405de2 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -26,6 +26,7 @@ #include "output-def.hh" #include "paper-score.hh" #include "staff-symbol-referencer.hh" +#include "staff-symbol.hh" #include "stencil.hh" #include "grob.hh" @@ -36,7 +37,6 @@ Rest::y_offset_callback (SCM smob) { Grob *me = unsmob_grob (smob); int duration_log = scm_to_int (me->get_property ("duration-log")); - int line_count = Staff_symbol_referencer::line_count (me); Real ss = Staff_symbol_referencer::staff_space (me); bool position_override = scm_is_number (me->get_property ("staff-position")); @@ -44,11 +44,11 @@ Rest::y_offset_callback (SCM smob) if (position_override) { - amount = - robust_scm2double (me->get_property ("staff-position"), 0) * 0.5 * ss; + amount + = robust_scm2double (me->get_property ("staff-position"), 0) * 0.5 * ss; /* - semibreve rests were always positioned one off + semibreve rests are positioned one staff line off */ if (duration_log == 0) amount += ss; @@ -66,17 +66,25 @@ Rest::y_offset_callback (SCM smob) /* make a semibreve rest hang from the next line, - except for a single line staff; - assume the next line being integer steps away + except for a single line staff */ - if (duration_log == 0 && line_count > 1) - ++pos; + if (duration_log == 0 && Staff_symbol_referencer::line_count (me) > 1) + pos += 2; /* make sure rest is aligned to a staff line */ - while (!Staff_symbol_referencer::on_line (me, pos)) - ++pos; + if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) + { + std::vector linepos = Staff_symbol::line_positions (staff); + std::sort (linepos.begin (), linepos.end ()); + std::vector::const_iterator it + = std::lower_bound (linepos.begin (), linepos.end (), pos); + if (it != linepos.end ()) + { + pos = (int)ceil (*it); + } + } amount = ss * 0.5 * pos; } @@ -112,14 +120,14 @@ Rest::glyph_name (Grob *me, int durlog, string style, bool try_ledgers) int const pos = int (Staff_symbol_referencer::get_position (me)); /* - half rests need ledger if not lying on a staff line, - whole rests need ledger if not hanging from a staff line, - breve rests need ledger if neither lying on nor hanging from a staff line + half rests need ledger if not lying on a staff line, + whole rests need ledger if not hanging from a staff line, + breve rests need ledger if neither lying on nor hanging from a staff line */ if (-1 <= durlog && durlog <= 1) is_ledgered = !Staff_symbol_referencer::on_staff_line (me, pos) - && !(durlog == -1 - && Staff_symbol_referencer::on_staff_line (me, pos + 2)); + && !(durlog == -1 + && Staff_symbol_referencer::on_staff_line (me, pos + 2)); } string actual_style (style.c_str ());