From: Janek WarchoĊ‚ Date: Wed, 22 Apr 2015 09:30:02 +0000 (+0200) Subject: More flexibility for tremolo slashes X-Git-Tag: release/2.19.19-1~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=72ec71be99f23ced1c0827ae7f82f5dc4745539a;p=lilypond.git More flexibility for tremolo slashes This patch introduces a shape property and relies on it to allow for various settings of tremolo slashes behaviour. (See issue 1735.) --- diff --git a/Documentation/changes.tely b/Documentation/changes.tely index 1a5208fbd0..93e424ce1b 100644 --- a/Documentation/changes.tely +++ b/Documentation/changes.tely @@ -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 index 0000000000..da0ec2b540 --- /dev/null +++ b/input/regression/stem-tremolo-style.ly @@ -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 +} diff --git a/lily/include/stem-tremolo.hh b/lily/include/stem-tremolo.hh index 55ce3248e7..2495bb695a 100644 --- a/lily/include/stem-tremolo.hh +++ b/lily/include/stem-tremolo.hh @@ -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); diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index e861d26566..f2c716d2ec 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -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 " ); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index e35a05439d..3914cf459d 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -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 diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index f077c80168..f82f27cec3 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2161,7 +2161,7 @@ (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))