]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2535: Staccato on stem side alignment when other articulations are present
authorDavid Nalesnik <david.nalesnik@gmail.com>
Mon, 26 Jan 2015 14:13:22 +0000 (08:13 -0600)
committerDavid Nalesnik <david.nalesnik@gmail.com>
Tue, 3 Feb 2015 21:25:36 +0000 (15:25 -0600)
The default positioning of staccato dots in combination with other articulations
is poor, because the dot is positioned midway between the center of the note head
and the stem, while all other scripts are centered on the note head.

A mechanism is needed to allow a staccato dot to be positioned differently when alone
and when in combination with other articulations.  This patch introduces a new property,
called 'toward-stem-shift-in-column, which works alongside 'toward-stem-shift to control
a script's position relative to the stem.  If set for a script appearing within a column,
the new property overrides any setting in 'toward-stem-shift.  The new property has
been set only for staccato and staccatissimo.

The previous default of 0.5 for staccato has been changed to 1.0, in accordance with
Gould's recommendation that a staccato dot be centered on the stem.

In order to allow a script to recognize the column organizing it, a pointer to
ScriptColumn, called 'script-column, has been added to script-interface.

Other changes:
--The regtest script-shift.ly has been modified to use scripts other than
staccato.
--A new regtest, script-shift-staccato.ly, illustrates the idiosyncratic
behavior of staccato dots.
--Documentation of the property 'toward-stem-shift has been made more
accurate.

input/regression/script-shift-staccato.ly [new file with mode: 0644]
input/regression/script-shift.ly
lily/script-column.cc
lily/script-interface.cc
scm/define-grob-properties.scm
scm/output-lib.scm
scm/script.scm

diff --git a/input/regression/script-shift-staccato.ly b/input/regression/script-shift-staccato.ly
new file mode 100644 (file)
index 0000000..fc29dd7
--- /dev/null
@@ -0,0 +1,29 @@
+
+\header {
+  texidoc = "The horizontal placement of staccato dots above an
+upstem or below a downstem note differs from the placement of
+other scripts in that different positioning is used when the dot is
+alone and when it is part of a compound articulation.  The
+property @code{toward-stem-shift-in-column} ensures good default
+positioning of the staccato (see first measure below), and allows
+precise horizontal control of a column containing a staccato and
+of the staccato within it (second measure).  (@code{0.0} means
+centered on the note head, @code{1.0} means centered on the stem.)
+"
+}
+
+\version "2.19.16"
+
+\relative c''
+{
+  % default
+  a4^. c_.
+  a^.^- c_._-
+
+  \override Script.toward-stem-shift-in-column = 1.0
+  a4^.^- c_._-
+  \revert Script.toward-stem-shift-in-column
+
+  a4-\tweak toward-stem-shift-in-column 1.0 ^. ^-
+  c4-\tweak toward-stem-shift-in-column 1.0 _. _-
+}
index 88f8f72f02524535330d94df8dc9bfa4001cc4a3..1877fcd0a5486ba8d0d5c9dc5313dae2b0aad98c 100644 (file)
@@ -7,12 +7,12 @@ means centered on the stem).
 "
 }
 
-\version "2.17.6"
+\version "2.19.16"
 \relative c''
 {
-  \override Script.toward-stem-shift = #0.0
-  a4^. c_.
-
   \override Script.toward-stem-shift = #1.0
-  a4^. c_.
+  a4^> c_>
+
+  \override Script.toward-stem-shift = #0.0
+  a4^> c_>
 }
index 0e797b543f2948cccd5495686ceb3895a76dd16c..2456f8b00b05d5c13e9969fce2bb5ea77fe408b5 100644 (file)
@@ -39,6 +39,7 @@ Script_column::add_side_positioned (Grob *me, Grob *script)
     return;
 
   Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"), script);
+  script->set_object ("script-column", me->self_scm ());
 }
 
 LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less",
index 8778f5c6d316b8dbda9b4157aa81906260ac1fcf..c4a136b06f20e15de8ebd09dd17515bd9ecbc7c9 100644 (file)
@@ -153,11 +153,13 @@ ADD_INTERFACE (Script_interface,
                "avoid-slur "
                "direction-source "
                "positioning-done "
+               "script-column "
                "script-priority "
                "script-stencil "
                "side-relative-direction "
                "slur "
                "slur-padding "
                "toward-stem-shift "
+               "toward-stem-shift-in-column "
               );
 
index b850a18e8beb3c39cb0786c3b695916cae3e106f..0d5eaa124a001d875af1f3f7019e34df1dd8e60d 100644 (file)
@@ -1088,9 +1088,15 @@ automatically.")
 line just before it would otherwise stop.")
      (toward-stem-shift ,number? "Amount by which scripts are shifted
 toward the stem if their direction coincides with the stem direction.
-@code{0.0} means keep the default position (centered on the note
-head), @code{1.0} means centered on the stem.  Interpolated values are
-possible.")
+@code{0.0} means centered on the note head (the default position of
+most scripts); @code{1.0} means centered on the stem.  Interpolated
+values are possible.")
+     (toward-stem-shift-in-column ,number? "Amount by which a script
+is shifted toward the stem if its direction coincides with the stem
+direction and it is associated with a @code{ScriptColumn} object.
+@code{0.0} means centered on the note head (the default position of
+most scripts); @code{1.0} means centered on the stem.  Interpolated
+values are possible.")
      (transparent ,boolean? "This makes the grob invisible.")
 
 
@@ -1380,7 +1386,8 @@ to be within staff spaces.")
      (quantized-positions ,number-pair? "The beam positions after
 quanting.")
 
-
+     (script-column ,ly:grob? "A @code{ScriptColumn} associated with a
+@code{Script} object.")
      (script-stencil ,pair? "A pair @code{(@var{type} . @var{arg})} which
 acts as an index for looking up a @code{Stencil} object.")
      (shorten ,ly:dimension? "The amount of space that a stem is shortened.
index 1e40e19f667293cb8ab3c9348919093fd52f5fe5..db4fb9b022255a7bc277706ff1774f4bb7fefa61 100644 (file)
@@ -1157,17 +1157,20 @@ parent or the parent has no setting."
 
 (define-public (script-interface::calc-x-offset grob)
   (ly:grob-property grob 'positioning-done)
-  (let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
+  (let* ((shift-when-alone (ly:grob-property grob 'toward-stem-shift 0.0))
+         (shift-in-column (ly:grob-property grob 'toward-stem-shift-in-column))
+         (script-column (ly:grob-object grob 'script-column))
+         (shift (if (and (ly:grob? script-column) (number? shift-in-column))
+                    shift-in-column shift-when-alone))
          (note-head-location
           (ly:self-alignment-interface::aligned-on-x-parent grob))
          (note-head-grob (ly:grob-parent grob X))
          (stem-grob (ly:grob-object note-head-grob 'stem)))
 
     (+ note-head-location
-       ;; If the property 'toward-stem-shift is defined and the script
-       ;; has the same direction as the stem, move the script accordingly.
-       ;; Since scripts can also be over skips, we need to check whether
-       ;; the grob has a stem at all.
+       ;; If the script has the same direction as the stem, move the script
+       ;; in accordance with the value of 'shift'.  Since scripts can also be
+       ;; over skips, we need to check whether the grob has a stem at all.
        (if (ly:grob? stem-grob)
            (let ((dir1 (ly:grob-property grob 'direction))
                  (dir2 (ly:grob-property stem-grob 'direction)))
index ab0df9f33690271b06dfb26243197139653e7743..5d975fe0ec43a54b0217b003efc101f75315677b 100644 (file)
         (script-stencil . (feta . ("dstaccatissimo" . "ustaccatissimo")))
         (padding . 0.20)
         (skyline-horizontal-padding . 0.10)
-        (side-relative-direction . ,DOWN)))
+        (side-relative-direction . ,DOWN)
+        (toward-stem-shift . 1.0)
+        (toward-stem-shift-in-column . 0.0)))
     ("staccato"
      . (
         (script-stencil . (feta . ("staccato" . "staccato")))
         (side-relative-direction . ,DOWN)
         (quantize-position . #t)
         (avoid-slur . inside)
-        (toward-stem-shift . 0.5)
+        (toward-stem-shift . 1.0)
+        (toward-stem-shift-in-column . 0.0)
         (padding . 0.20)
         (skyline-horizontal-padding . 0.10)
         (script-priority . -100)))