]> git.donarmstrong.com Git - lilypond.git/commitdiff
Implement shorten-pair for Hairpin
authorDavid Nalesnik <david.nalesnik@gmail.com>
Fri, 6 Jan 2017 16:27:25 +0000 (10:27 -0600)
committerDavid Nalesnik <david.nalesnik@gmail.com>
Sat, 21 Jan 2017 20:05:55 +0000 (14:05 -0600)
This property allows the ends of hairpins to be modified
independently.

Documentation/changes.tely
Documentation/notation/expressive.itely
Documentation/snippets/new/moving-the-ends-of-hairpins.ly [new file with mode: 0644]
input/regression/hairpin-shorten-pair-circled-tip.ly [new file with mode: 0644]
input/regression/hairpin-shorten-pair.ly [new file with mode: 0644]
lily/hairpin.cc
scm/define-grob-properties.scm

index 37e17cae1a69027df980cfc7ba7ade833b0a0c8b..a78d6d32970966e367436263e8ea1e5502fc7d5a 100644 (file)
@@ -61,6 +61,20 @@ which scares away people.
 
 @end ignore
 
+@item
+The ends of hairpins may now be fine-tuned using the @code{shorten-pair}
+grob property, which previously only affected text-spanners like
+@code{TupletBracket} and @code{OttavaBracket}.  Positive values offset
+to the right, negative to the left.
+@lilypond[quote,verbatim]
+{ \once \override Hairpin.shorten-pair = #'(2 . 2)
+  c'1~\<
+  c'2~ c'\!
+  \once \override Hairpin.shorten-pair = #'(-2 . -2)
+  c'1~\<
+  c'2~ c'\! }
+@end lilypond
+
 @item
 In fret-diagrams the distance between frets and the distance between strings is
 now independently adjustable.  Available are @code{fret-distance} and
index 3c249389c28c65c8040d2382f83e84606ad286f2..5f89cc66cf47b872b97e0261f5ed1a6370324f90 100644 (file)
@@ -454,6 +454,9 @@ items such as text scripts, text spanners, and piano pedal marks.
 @lilypondfile[verbatim,quote,texidoc,doctitle]
 {setting-the-minimum-length-of-hairpins.ly}
 
+@lilypondfile[verbatim,quote,texidoc,doctitle]
+{moving-the-ends-of-hairpins.ly}
+
 @cindex al niente
 @cindex niente, al
 
diff --git a/Documentation/snippets/new/moving-the-ends-of-hairpins.ly b/Documentation/snippets/new/moving-the-ends-of-hairpins.ly
new file mode 100644 (file)
index 0000000..6c8438c
--- /dev/null
@@ -0,0 +1,30 @@
+\version "2.19.55"
+
+\header {
+  lsrtags = "expressive-marks"
+
+  texidoc = "
+The ends of hairpins may be offset by setting the @code{shorten-pair}
+property of the @code{Hairpin} object.  Positive values move endpoints
+to the right, negative to the left.  Unlike the @code{minimum-length}
+property, this property only affects the appearance of the hairpin; it
+does not adjust horizontal spacing (including the position of bounding
+dynamics).  This method is thus suitable for fine-tuning a hairpin
+within its allotted space.
+
+"
+  doctitle = "Moving the ends of hairpins"
+}
+
+{
+  c'1~\<
+  c'2~ c'\!
+  \once \override Hairpin.shorten-pair = #'(2 . 2)
+  c'1~\<
+  c'2~ c'\!
+  \once \override Hairpin.shorten-pair = #'(-2 . -2)
+  c'1~\<
+  c'2~ c'\!
+  c'1~\p-\tweak shorten-pair #'(2 . 0)\<
+  c'2~ c'\ffff
+}
diff --git a/input/regression/hairpin-shorten-pair-circled-tip.ly b/input/regression/hairpin-shorten-pair-circled-tip.ly
new file mode 100644 (file)
index 0000000..63ebfcd
--- /dev/null
@@ -0,0 +1,22 @@
+\version "2.19.55"
+
+\header {
+  texidoc = "The @code{shorten-pair} property works with circled-tip
+hairpins.  When two hairpins share a circle, the adjoining ends are
+not moved.
+"
+}
+
+{
+  \override Hairpin.circled-tip = ##t
+  \once \override Hairpin.shorten-pair = #'(-2 . -4)
+  c'1~\<
+  c'2~ c'\!
+  \once \override Hairpin.shorten-pair = #'(0 . -4)
+  c'1~\>
+  c'2~ c'\!
+  \break
+  \override Hairpin.shorten-pair = #'(4 . -8)
+  c'2~\> c'2~\<
+  c'2~ c'2\!
+}
diff --git a/input/regression/hairpin-shorten-pair.ly b/input/regression/hairpin-shorten-pair.ly
new file mode 100644 (file)
index 0000000..55eaaf2
--- /dev/null
@@ -0,0 +1,26 @@
+\version "2.19.55"
+
+\header {
+  texidoc = "The ends of hairpins may be offset with the
+@code{shorten-pair} property.  Positive values offset ends to the right,
+negative values to the left.
+"
+}
+
+hairpin = {
+  c'1~\<
+  c'2~ c'\!
+}
+
+{
+  \hairpin
+  \once \override Hairpin.shorten-pair = #'(2 . 2)
+  \hairpin
+  \once \override Hairpin.shorten-pair = #'(-2 . -2)
+  \hairpin
+  \break
+  \alterBroken shorten-pair #'((10 . 0) (-2 . -20)) Hairpin
+  c'1~\<
+  \break
+  c'2~ c'\!
+}
index 01d8fd93dea61f696d5af6a189244517f4fca622..afd94f3ee06ada9f66d16a851fed3da119037de5 100644 (file)
@@ -157,6 +157,8 @@ Hairpin::print (SCM smob)
   if (circled_tip)
     thick = robust_scm2double (me->get_property ("thickness"), 1.0)
             * Staff_symbol_referencer::line_thickness (me);
+  Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
+                                                  Interval (0, 0));
 
   for (LEFT_and_RIGHT (d))
     {
@@ -220,7 +222,10 @@ Hairpin::print (SCM smob)
                         Handle back-to-back hairpins with a circle in the middle
                       */
                       if (circled_tip && (grow_dir != d))
-                        x_points[d] = e.center () + d * (rad - thick / 2.0);
+                        {
+                          x_points[d] = e.center () + d * (rad - thick / 2.0);
+                          shorten[d] = 0.0;
+                        }
                       /*
                         If we're hung on a paper column, that means we're not
                         adjacent to a text-dynamic, and we may move closer. We
@@ -248,6 +253,8 @@ Hairpin::print (SCM smob)
                 }
             }
         }
+
+        x_points[d] -= shorten[d] * d;
     }
 
   Real width = x_points[RIGHT] - x_points[LEFT];
@@ -336,4 +343,5 @@ ADD_INTERFACE (Hairpin,
                "bound-padding "
                "grow-direction "
                "height "
+               "shorten-pair "
               );
index 3f7a94d9c2e251683924831fef9b64f550ac0d51..34450a9d23000eb79d4b1ec71be38abb90540ab3 100644 (file)
@@ -883,9 +883,10 @@ of the staff-position at which each clef places C:
 If the list contains a single element it applies for all clefs.
 A single number in place of a pair sets accidentals within the octave
 ending at that staff-position.")
-     (shorten-pair ,number-pair? "The lengths to shorten a
-text-spanner on both sides, for example a pedal bracket.  Positive
-values shorten the text-spanner, while negative values lengthen it.")
+     (shorten-pair ,number-pair? "The lengths to shorten on both sides
+a hairpin or text-spanner such as a pedal bracket.  Positive values
+shorten the hairpin or text-spanner, while negative values lengthen
+it.")
      (shortest-duration-space ,number? "Start with this multiple of
 @code{spacing-increment} space for the shortest duration.  See also
 @rinternals{spacing-spanner-interface}.")