From 9f966033f062a4f525fa878b0d7d08c19f7f21fb Mon Sep 17 00:00:00 2001 From: David Nalesnik Date: Mon, 26 Jan 2015 08:13:22 -0600 Subject: [PATCH] Issue 2535: Staccato on stem side alignment when other articulations are present 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 | 29 +++++++++++++++++++++++ input/regression/script-shift.ly | 10 ++++---- lily/script-column.cc | 1 + lily/script-interface.cc | 2 ++ scm/define-grob-properties.scm | 15 ++++++++---- scm/output-lib.scm | 13 ++++++---- scm/script.scm | 7 ++++-- 7 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 input/regression/script-shift-staccato.ly diff --git a/input/regression/script-shift-staccato.ly b/input/regression/script-shift-staccato.ly new file mode 100644 index 0000000000..fc29dd75ad --- /dev/null +++ b/input/regression/script-shift-staccato.ly @@ -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 _. _- +} diff --git a/input/regression/script-shift.ly b/input/regression/script-shift.ly index 88f8f72f02..1877fcd0a5 100644 --- a/input/regression/script-shift.ly +++ b/input/regression/script-shift.ly @@ -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_> } diff --git a/lily/script-column.cc b/lily/script-column.cc index 0e797b543f..2456f8b00b 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -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", diff --git a/lily/script-interface.cc b/lily/script-interface.cc index 8778f5c6d3..c4a136b06f 100644 --- a/lily/script-interface.cc +++ b/lily/script-interface.cc @@ -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 " ); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index b850a18e8b..0d5eaa124a 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -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. diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 1e40e19f66..db4fb9b022 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -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))) diff --git a/scm/script.scm b/scm/script.scm index ab0df9f336..5d975fe0ec 100644 --- a/scm/script.scm +++ b/scm/script.scm @@ -270,14 +270,17 @@ (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))) -- 2.39.2