lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

do not tinker with the position of a pitched rest (issue 5434061)


From: benko . pal
Subject: do not tinker with the position of a pitched rest (issue 5434061)
Date: Wed, 23 Nov 2011 22:12:52 +0000

Reviewers: ,

Message:
hi all,

if I extend the staff by a line, pitched rests appear shifted by half a
line (thus half rests look like whole rests and vice versa).
this patch is a quick fix for that.

I feel the line-positions and line-count properties of Staff are badly
tangled; I intend to work on sorting those out, but expect it to be
slow.

Description:
do not tinker with the position of a pitched rest

Please review this at http://codereview.appspot.com/5434061/

Affected files:
  A input/regression/rest-on-nonstandard-staff.ly
  M lily/rest.cc


Index: 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 0000000000000000000000000000000000000000..b68330a6872b0ca0525f3813995795e6d009ac5d
--- /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
+  }
+>>
Index: lily/rest.cc
diff --git a/lily/rest.cc b/lily/rest.cc
index d86296fada49e3c5bcbc8558f709f275f4efe51c..0a816fcd8a5296a05b6b65facbf1491e1de111d1 100644
--- a/lily/rest.cc
+++ b/lily/rest.cc
@@ -40,20 +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);
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]