]> git.donarmstrong.com Git - lilypond.git/commitdiff
do not tinker with pitched rest
authorBenkő Pál <benko.pal@gmail.com>
Tue, 3 Jan 2012 18:08:26 +0000 (19:08 +0100)
committerJanek Warchol <lemniskata.bernoullego@gmail.com>
Tue, 3 Jan 2012 18:14:34 +0000 (19:14 +0100)
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 [new file with mode: 0644]
lily/rest.cc

diff --git a/input/regression/rest-on-nonstandard-staff.ly b/input/regression/rest-on-nonstandard-staff.ly
new file mode 100644 (file)
index 0000000..b68330a
--- /dev/null
@@ -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
+  }
+>>
index ddc9bbdd8f2e04a2322ca142fe28ea94f9b7bdd9..0a816fcd8a5296a05b6b65facbf1491e1de111d1 100644 (file)
@@ -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);
 }