]> git.donarmstrong.com Git - lilypond.git/commitdiff
property to set voiced-rest positions; issue 3902
authorKeith OHara <k-ohara5a5a@oco.net>
Sat, 3 Jan 2015 22:29:39 +0000 (14:29 -0800)
committerKeith OHara <k-ohara5a5a@oco.net>
Sun, 18 Jan 2015 05:42:33 +0000 (21:42 -0800)
input/regression/rest-polyphonic.ly
lily/rest.cc
scm/define-grob-properties.scm
scm/define-grobs.scm

index a1e762923bc37e7339f93a7610845bf1dbbfd765..4dca1efc9ace4eb63392e6044e728791e34e0e1b 100644 (file)
@@ -2,7 +2,7 @@
 
   texidoc = "In polyphonic situations, rests are moved according
 to their @code{direction} even if there is no opposite note or rest.
-The amount is two @code{staff-space}s. "
+The amount in @code{staff-position}s is set by @code{voiced-position}."
 
 }
 
@@ -15,6 +15,9 @@ The amount is two @code{staff-space}s. "
 \new Staff  \relative c' {
   << { r8 g''4 g8       r g4 g8 } \\
      { d,4    r \stemUp b   r   } >>
+ \override Staff.Rest.voiced-position = 2
+  << { r8 g''4 g8       r g4 g8 } \\
+     { d,4    r \stemUp b   r   } >>
 }
 
 
index b202519cf574e8374b4f53281e6f47abb68ae59f..9e5dc046e14821fdced4de7ee10707c02f08b956 100644 (file)
@@ -72,12 +72,13 @@ Rest::staff_position_internal (Grob *me, int duration_log, int dir)
       return pos;
     }
 
-  pos = 4 * dir;
+  Real vpos = dir * robust_scm2int (me->get_property ("voiced-position"), 0);
+  pos = vpos;
 
   if (duration_log > 1)
     /* Only half notes or longer want alignment with staff lines */
     return pos;
-      
+
   /*
     We need a staff symbol for actually aligning anything
   */
@@ -89,9 +90,9 @@ Rest::staff_position_internal (Grob *me, int duration_log, int dir)
 
   if (linepos.empty ())
     return pos;
-      
+
   std::sort (linepos.begin (), linepos.end ());
-          
+
   if (duration_log == 0)
     {
       /*
@@ -105,7 +106,7 @@ Rest::staff_position_internal (Grob *me, int duration_log, int dir)
         make a semibreve rest hang from the next available line,
         except when there is none.
       */
-      
+
       std::vector<Real>::const_iterator it
         = std::upper_bound (linepos.begin (), linepos.end (), pos);
       if (it != linepos.end ())
@@ -127,16 +128,15 @@ Rest::staff_position_internal (Grob *me, int duration_log, int dir)
     return pos;
 
   /* If we have a voiced position, make sure that it's on the
-     proper side of neutral before using it.  If it isn't, we fall
-     back to a constant offset from neutral position.
+     proper side of neutral before using it.
   */
 
   Real neutral = staff_position_internal (me, duration_log, 0);
 
   if (dir * (pos - neutral) > 0)
     return pos;
-
-  return neutral + 4 * dir;
+  else
+    return neutral + vpos;
 }
 
 /* A rest might lie under a beam, in which case it should be cross-staff if
@@ -318,4 +318,5 @@ ADD_INTERFACE (Rest,
                "direction "
                "minimum-distance "
                "style "
+               "voiced-position "
               );
index 4a95ca5c476d1c2a2fd3ec3ea635c22bcc57f588..72597bc84eecd98cfeb6442f115c4c6695393743 100644 (file)
@@ -1112,6 +1112,8 @@ positioning?")
 ;;;
      (vertical-skylines ,ly:skyline-pair? "Two skylines, one above and
 one below this grob.")
+     (voiced-position ,number? "The staff-position of a voiced
+@code{Rest}, negative if the rest has @code{direction} @code{DOWN}.")
 
 ;;;
 ;;; w
index c859b52bcbeee1d59a9b8af1f758246eab43b940..252733d1668e808660bb716e0c6004b488422ae1 100644 (file)
         (thick-thickness . 6.6)
         ;; See Wanske pp. 125
         (usable-duration-logs . ,(iota 4 -3))
+        (voiced-position . 4)
         (Y-extent . ,(ly:make-unpure-pure-container ly:multi-measure-rest::height))
         (Y-offset . ,staff-symbol-referencer::callback)
         (meta . ((class . Spanner)
         (duration-log . ,stem::calc-duration-log)
         (minimum-distance . 0.25)
         (stencil . ,ly:rest::print)
+        (voiced-position . 4)
         (X-extent . ,ly:rest::width)
         (Y-extent . ,(ly:make-unpure-pure-container ly:rest::height ly:rest::pure-height))
         (Y-offset . ,(ly:make-unpure-pure-container ly:rest::y-offset-callback))