From 9f24e79a945ec4ab000d3e09ff2d2ac8208e2246 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benk=C5=91=20P=C3=A1l?= Date: Tue, 3 Jan 2012 19:08:26 +0100 Subject: [PATCH] do not tinker with pitched rest half rests should lie on a staff line, whole rests should hang from a staff line by default even for non-standard staves, except when the position is set by pitch. --- input/regression/rest-on-nonstandard-staff.ly | 38 +++++++++++++++++++ lily/rest.cc | 30 +++++++++++---- 2 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 input/regression/rest-on-nonstandard-staff.ly diff --git a/input/regression/rest-on-nonstandard-staff.ly b/input/regression/rest-on-nonstandard-staff.ly new file mode 100644 index 0000000000..b68330a687 --- /dev/null +++ b/input/regression/rest-on-nonstandard-staff.ly @@ -0,0 +1,38 @@ +\version "2.15.18" + +\header { + texidoc = "half rests should lie on a staff line, whole rests should hang + from a staff line by default even for non-standard staves, except when + the position is set by pitch." +} + + +\layout { + ragged-right = ##t + indent = 0.0 +} + +\new StaffGroup << + \new Staff { + r2 + g'2\rest + r1 + g'1\rest + } + + \new Staff { + \override Staff.StaffSymbol #'line-positions = #'(-4 -2 0 2) + r2 + g'2\rest + r1 + g'1\rest + } + + \new Staff { + \override Staff.StaffSymbol #'line-count = #4 + r2 + g'2\rest + r1 + g'1\rest + } +>> diff --git a/lily/rest.cc b/lily/rest.cc index ddc9bbdd8f..0a816fcd8a 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -40,19 +40,33 @@ Rest::y_offset_callback (SCM smob) Real ss = Staff_symbol_referencer::staff_space (me); bool position_override = scm_is_number (me->get_property ("staff-position")); - Real amount = robust_scm2double (me->get_property ("staff-position"), 0) - * 0.5 * ss; + Real amount; - if (line_count % 2) + if (position_override) { - if (duration_log == 0 && line_count > 1) - amount += ss; + amount = + robust_scm2double (me->get_property ("staff-position"), 0) * 0.5 * ss; + /* + trust the client on good positioning; + would be tempting to adjust position of rests longer than a quarter + to be properly aligned to staff lines, + but custom rest shapes may not need that sort of care. + */ } else - amount += ss / 2; + { + amount = 2 * ss * get_grob_direction (me); - if (!position_override) - amount += 2 * ss * get_grob_direction (me); + if (line_count % 2 == 0) + amount += ss / 2; + } + + /* + make a semibreve rest hang from the next line, + except for a single line staff + */ + if (duration_log == 0 && line_count > 1) + amount += ss; return scm_from_double (amount); } -- 2.39.2