]> git.donarmstrong.com Git - lilypond.git/commitdiff
More flexibility for tremolo slashes
authorJanek Warchoł <lemniskata.bernoullego@gmail.com>
Wed, 22 Apr 2015 09:30:02 +0000 (11:30 +0200)
committerValentin Villenave <valentin@villenave.net>
Wed, 22 Apr 2015 09:39:09 +0000 (11:39 +0200)
This patch introduces a shape property and
relies on it to allow for various settings
of tremolo slashes behaviour.

(See issue 1735.)

Documentation/changes.tely
input/regression/stem-tremolo-style.ly [new file with mode: 0644]
lily/include/stem-tremolo.hh
lily/stem-tremolo.cc
scm/define-grob-properties.scm
scm/define-grobs.scm

index 1a5208fbd07a65590c901022a740e9d7e5c1884e..93e424ce1bbc627de680167a496ade8d4058caa9 100644 (file)
@@ -61,6 +61,19 @@ which scares away people.
 
 @end ignore
 
+@item
+The visual style of tremolo slashes (shape, style and slope)
+is now more finely controlled.
+@lilypond[quote,relative=2]
+  a8:32 b: c: d:
+  \override StemTremolo.shape = #'beam-like
+  a: b: c: d:
+  \override StemTremolo.style = #'constant
+  a: b: c: d:
+  g,2
+@end lilypond
+
+
 @item
 Multi-measure rests have length according to their total duration,
 under the control of @code{MultiMeasureRest.space-increment}.
diff --git a/input/regression/stem-tremolo-style.ly b/input/regression/stem-tremolo-style.ly
new file mode 100644 (file)
index 0000000..da0ec2b
--- /dev/null
@@ -0,0 +1,55 @@
+\version "2.19.8"
+
+\header {
+  texidoc = "Properties that control looks of tremolo slashes.
+  Slope is self-explanatory.  Shape determines wheteher slashes look like
+  rectangles or like very small beams.  Setting this properties directly
+  causes all slashes behave in the specified way.  However, one usually
+  wants the slashes to behave differently depending on wheter the note
+  has flags, beams or only a plain stem.  That's what style property
+  is used for: it sets shape and slope depending on situation.
+  There are two styles defined: default and constant."
+}
+
+music = {
+  a''4:32 a':
+  e''8: \noBeam e':
+  a'': [ a': ]
+  f': [ g':]
+  d': [ d': ]
+}
+
+\markup \wordwrap { default.  First three notes should have beam-like slashes.
+Slash of the third note should be more sloped than first two notes.
+Slashes on beamed notes should be rectangular and parallel to the beams. }
+\new Staff {
+  \music
+}
+
+\markup \wordwrap { style=constant.  All slashes should be rectangular.
+All slashes should have the same slope except for downstem flagged notes. }
+\new Staff {
+  \override StemTremolo.style = #'constant
+  \music
+}
+
+\markup \wordwrap { shape=rectangle.  All slashes should be rectangular.
+Slope like in default. }
+\new Staff {
+  \override StemTremolo.shape = #'rectangle
+  \music
+}
+
+\markup \wordwrap { shape=beam-like.  All slashes should be beam-like.
+Slope like in default. }
+\new Staff {
+  \override StemTremolo.shape = #'beam-like
+  \music
+}
+
+\markup \wordwrap { slope=-0.2  All slashes should have the same downward slope.
+  Shape like in default. }
+\new Staff {
+  \override StemTremolo.slope = #-0.2
+  \music
+}
index 55ce3248e70e3f1bcf88a9c7b9926910144fa668..2495bb695a8bb422b65521e4633c737c20beeacb 100644 (file)
@@ -34,7 +34,7 @@ public:
   DECLARE_SCHEME_CALLBACK (pure_calc_y_offset, (SCM, SCM, SCM));
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (width, (SCM));
-  DECLARE_SCHEME_CALLBACK (calc_style, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_shape, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
   DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
   static Stencil raw_stencil (Grob *, Real slope, Direction stemdir);
index e861d265668afd1712d283f56f10c9558b98fdc4..f2c716d2ec91767bb43225702aad4f99db2a5684 100644 (file)
@@ -39,7 +39,9 @@ Stem_tremolo::calc_slope (SCM smob)
   Grob *stem = Grob::unsmob (me->get_object ("stem"));
   Spanner *beam = Stem::get_beam (stem);
 
-  if (beam)
+  SCM style = me->get_property ("style");
+
+  if (beam && !scm_is_eq (style, ly_symbol2scm ("constant")))
     {
       Real dy = 0;
       SCM s = beam->get_property ("quantized-positions");
@@ -58,7 +60,8 @@ Stem_tremolo::calc_slope (SCM smob)
   else
     /* down stems with flags should have more sloped trems (helps avoid
        flag/stem collisions without making the stem very long) */
-    return scm_from_double ((Stem::duration_log (stem) >= 3 && get_grob_direction (me) == DOWN)
+    return scm_from_double ((Stem::duration_log (stem) >= 3
+                             && get_grob_direction (me) == DOWN && !beam)
                             ? 0.40 : 0.25);
 }
 
@@ -76,17 +79,20 @@ Stem_tremolo::calc_width (SCM smob)
   return scm_from_double (((dir == UP && flag) || beam) ? 1.0 : 1.5);
 }
 
-MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_style, 1)
+MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_shape, 1)
 SCM
-Stem_tremolo::calc_style (SCM smob)
+Stem_tremolo::calc_shape (SCM smob)
 {
   Grob *me = Grob::unsmob (smob);
   Grob *stem = Grob::unsmob (me->get_object ("stem"));
   Direction dir = get_grob_direction (me);
   bool beam = Stem::get_beam (stem);
   bool flag = Stem::duration_log (stem) >= 3 && !beam;
+  SCM style = me->get_property ("style");
 
-  return ly_symbol2scm (((dir == UP && flag) || beam) ? "rectangle" : "default");
+  return ly_symbol2scm (!scm_is_eq (style, ly_symbol2scm ("constant"))
+                        && ((dir == UP && flag) || beam)
+                        ? "rectangle" : "beam-like");
 }
 
 Real
@@ -108,15 +114,15 @@ Stem_tremolo::raw_stencil (Grob *me, Real slope, Direction dir)
   Real thick = robust_scm2double (me->get_property ("beam-thickness"), 1);
   Real width = robust_scm2double (me->get_property ("beam-width"), 1);
   Real blot = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
-  SCM style = me->get_property ("style");
-  if (!scm_is_symbol (style))
-    style = ly_symbol2scm ("default");
+  SCM shape = me->get_property ("shape");
+  if (!scm_is_symbol (shape))
+    shape = ly_symbol2scm ("beam-like");
 
   width *= ss;
   thick *= ss;
 
   Stencil a;
-  if (scm_is_eq (style, ly_symbol2scm ("rectangle")))
+  if (scm_is_eq (shape, ly_symbol2scm ("rectangle")))
     a = Lookup::rotated_box (slope, width, thick, blot);
   else
     a = Lookup::beam (slope, width, thick, blot);
@@ -339,7 +345,7 @@ Stem_tremolo::print (SCM grob)
 
 ADD_INTERFACE (Stem_tremolo,
                "A beam slashing a stem to indicate a tremolo.  The property"
-               " @code{style} can be @code{default} or @code{rectangle}.",
+               " @code{shape} can be @code{beam-like} or @code{rectangle}.",
 
                /* properties */
                "beam-thickness "
@@ -348,6 +354,6 @@ ADD_INTERFACE (Stem_tremolo,
                "flag-count "
                "length-fraction "
                "stem "
-               "style "
+               "shape "
                "slope "
               );
index e35a05439d3b679901c88361d6c54aad5f1c8ded..3914cf459db9b490ecead8b57cce8cd1156c2427 100644 (file)
@@ -847,6 +847,9 @@ value @w{@code{-1}} means left aligned, @code{0}@tie{}centered, and
 values may also be specified - the unit is half the object width.")
      (self-alignment-Y ,number? "Like @code{self-alignment-X} but for
 the Y@tie{}axis.")
+     (shape ,symbol? "This setting determines what shape a grob
+has.  Valid choices depend on the @code{stencil} callback reading
+this property.")
      (sharp-positions ,list? "Sharps in key signatures are placed
 within the specified ranges of staff-positions.  The general form
 is a list of pairs, with one pair for each type of clef, in order
index f077c80168125629144f17465eb718bf2e425725..f82f27cec3bc7d9fd135b1af8f154dbc3f539ca2 100644 (file)
         (parent-alignment-X . ,CENTER)
         (slope . ,ly:stem-tremolo::calc-slope)
         (stencil . ,ly:stem-tremolo::print)
-        (style . ,ly:stem-tremolo::calc-style)
+        (shape . ,ly:stem-tremolo::calc-shape)
         (X-extent . ,ly:stem-tremolo::width)
         (X-offset . ,ly:self-alignment-interface::aligned-on-x-parent)
         (Y-extent . ,(grob::unpure-Y-extent-from-stencil ly:stem-tremolo::pure-height))