From: Paul Morris Date: Tue, 10 Nov 2015 21:13:38 +0000 (-0500) Subject: Issue 4504/1 add whiteout-style, drop whiteout-box X-Git-Tag: release/2.19.32-1~13^2~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=767b370f4e4f4eceac501c532e07b199e1b8df4d;p=lilypond.git Issue 4504/1 add whiteout-style, drop whiteout-box Introduce whiteout-style grob property, with options of 'box and 'outline, to be used with the whiteout grob property, and an equivalent style property for the whiteout markup command. Remove the whiteout-box grob property and markup command, and use the new properties instead. Make the box style of whiteout the default style again, as it was before issue 4418. --- diff --git a/lily/grob.cc b/lily/grob.cc index 2f1bd8aa9f..7ce89d5015 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -146,25 +146,15 @@ Grob::get_print_stencil () const /* whiteout background and larger file sizes with \pointAndClickOn. */ /* A grob has to be visible, otherwise the whiteout property has no effect. */ /* Calls the scheme procedure stencil-whiteout in scm/stencils.scm */ - if (!transparent && (scm_is_number (get_property("whiteout")) + if (!transparent && (scm_is_number (get_property ("whiteout")) || to_boolean (get_property ("whiteout")))) { - Real thickness = robust_scm2double (get_property("whiteout"), 3.0) - * layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + Real line_thickness = layout ()->get_dimension (ly_symbol2scm ("line-thickness")); retval = *unsmob (Lily::stencil_whiteout (retval.smobbed_copy (), - scm_from_double (thickness))); - } - - /* Calls the scheme procedure stencil-whiteout-box in scm/stencils.scm */ - if (!transparent && (scm_is_number (get_property("whiteout-box")) - || to_boolean (get_property ("whiteout-box")))) - { - Real thickness = robust_scm2double (get_property("whiteout-box"), 0.0) - * layout ()->get_dimension (ly_symbol2scm ("line-thickness")); - retval = *unsmob - (Lily::stencil_whiteout_box (retval.smobbed_copy (), - scm_from_double (thickness))); + get_property ("whiteout-style"), + get_property ("whiteout"), + scm_from_double (line_thickness))); } if (transparent) @@ -843,7 +833,7 @@ ADD_INTERFACE (Grob, "transparent " "vertical-skylines " "whiteout " - "whiteout-box " + "whiteout-style " ); /**************************************************************** diff --git a/lily/lily-imports.cc b/lily/lily-imports.cc index 04f0f7e57f..a62216e084 100644 --- a/lily/lily-imports.cc +++ b/lily/lily-imports.cc @@ -92,7 +92,6 @@ namespace Lily { Variable scorify_music ("scorify-music"); Variable span_bar_notify_grobs_of_my_existence ("span-bar::notify-grobs-of-my-existence"); Variable stencil_whiteout ("stencil-whiteout"); - Variable stencil_whiteout_box ("stencil-whiteout-box"); Variable symbol_list_p ("symbol-list?"); Variable tremolo_get_music_list ("tremolo::get-music-list"); Variable type_name ("type-name"); diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index fc8c86c5a3..b387da206e 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -1141,16 +1141,14 @@ one below this grob.") ;;; (when ,ly:moment? "Global time step associated with this column.") (whiteout ,boolean-or-number? "If a number or true, the grob is -printed over a white background that follows the outline of the stencil, -if the grob is visible. A number sets the thickness of the outline as a -multiple of the staff-line thickness. For compatibility with former -behavior (now available with @code{whiteout-box}) the value @code{#t} is -treated as @code{3.0}. Usually @code{#f} by default.") - (whiteout-box ,boolean-or-number? "If a number or true, the grob -is printed over a rectangular white background to white-out underlying -material, if the grob is visible. A number indicates how far the -outline extends beyond the bounding box of the grob as a multiple of -the staff-line thickness. Usually @code{#f} by default.") +printed over a white background to white-out underlying material, if +the grob is visible. A number indicates how far the white background +extends beyond the bounding box of the grob as a multiple of the +staff-line thickness. The shape of the background is determined by +@code{whiteout-style}. Usually @code{#f} by default.") + (whiteout-style ,symbol? "Determines the shape of the +@code{whiteout} background. Available are @code{'outline} and the +default @code{'box}.") (width ,ly:dimension? "The width of a grob measured in staff space.") (word-space ,ly:dimension? "Space to insert between words in diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index e7fc4bb956..3528933f68 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2362,7 +2362,7 @@ (parenthesis-friends . (dot)) (stem-attachment . (0.0 . 1.35)) (stencil . ,tab-note-head::print) - (whiteout-box . #t) + (whiteout . #t) (X-offset . ,ly:self-alignment-interface::x-aligned-on-self) (Y-offset . ,staff-symbol-referencer::callback) (Y-extent . ,grob::always-Y-extent-from-stencil) diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 57e2e8893a..0ca1042e8d 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -722,44 +722,36 @@ Rotate object with @var{ang} degrees around its center. (define-markup-command (whiteout layout props arg) (markup?) #:category other - #:properties ((thickness 3)) + #:properties ((style 'box) + (thickness '())) " @cindex adding a white background to text -Provide a white background for @var{arg}. +Provide a white background for @var{arg}. The shape of the white +background is determined by @code{style}. The default +is @code{box} which produces a white rectangle. @code{outline} +approximates the outline of the markup. @lilypond[verbatim,quote] \\markup { \\combine - \\filled-box #'(-1 . 10) #'(-3 . 4) #1 - \\override #'(thickness . 1.5) \\whiteout whiteout + \\filled-box #'(-1 . 15) #'(-3 . 4) #1 + \\override #'(thickness . 1.5) + \\whiteout whiteout-box } -@end lilypond" - (stencil-whiteout - (interpret-markup layout props arg) - (* thickness - (ly:output-def-lookup layout 'line-thickness)))) - -(define-markup-command (whiteout-box layout props arg) - (markup?) - #:category other - #:properties ((thickness 0)) - " -@cindex adding a rectangular white background to text - -Provide a rectangular white background for @var{arg}. - -@lilypond[verbatim,quote] \\markup { \\combine - \\filled-box #'(-1 . 10) #'(-3 . 4) #1 - \\override #'(thickness . 1.5) \\whiteout-box whiteout-box + \\filled-box #'(-1 . 18) #'(-3 . 4) #1 + \\override #'(style . outline) + \\override #'(thickness . 3) + \\whiteout whiteout-outline } @end lilypond" - (stencil-whiteout-box + (stencil-whiteout (interpret-markup layout props arg) - (* thickness - (ly:output-def-lookup layout 'line-thickness)))) + style + thickness + (ly:output-def-lookup layout 'line-thickness))) (define-markup-command (pad-markup layout props amount arg) (number? markup?) diff --git a/scm/stencil.scm b/scm/stencil.scm index 6410eae44c..8e4499d879 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -684,17 +684,17 @@ box, remains the same." (ly:stencil-extent stencil X) (ly:stencil-extent stencil Y))) -(define*-public (stencil-whiteout +(define*-public (stencil-whiteout-outline stil #:optional (thickness 0.3) (color white) (angle-increments 16) (radial-increments 1)) "This function works by creating a series of white or @var{color} stencils radially offset from the original stencil with angles from 0 to 2*pi, at an increment of @code{angle-inc}, and with radii from @code{radial-inc} to @var{thickness}. @var{thickness} is how big -the white outline is in staff-spaces. @var{radial-increments} is how -many copies of the white stencil we make on our way out to thickness. -@var{angle-increments} is how many copies of the white stencil -we make between 0 and 2*pi." +the white outline is, as a multiple of line-thickness. +@var{radial-increments} is how many copies of the white stencil we make +on our way out to thickness. @var{angle-increments} is how many copies +of the white stencil we make between 0 and 2*pi." (if (or (not (positive? angle-increments)) (not (positive? radial-increments))) (begin @@ -736,17 +736,31 @@ we make between 0 and 2*pi." `(delay-stencil-evaluation ,(delay whiteout-expr))) stil))))) -(define*-public (stencil-whiteout-box stencil +(define*-public (stencil-whiteout-box stil #:optional (thickness 0) (blot 0) (color white)) - "@var{thickness} is how far in staff-spaces the white outline -extends past the extents of @var{stencil}." + "@var{thickness} is how far, as a multiple of line-thickness, +the white outline extends past the extents of stencil @var{stil}." (let* - ((x-ext (interval-widen (ly:stencil-extent stencil X) thickness)) - (y-ext (interval-widen (ly:stencil-extent stencil Y) thickness))) + ((x-ext (interval-widen (ly:stencil-extent stil X) thickness)) + (y-ext (interval-widen (ly:stencil-extent stil Y) thickness))) (ly:stencil-add (stencil-with-color (ly:round-filled-box x-ext y-ext blot) color) - stencil))) + stil))) + +(define-public (stencil-whiteout stil style thickness line-thickness) + "@var{style} is a symbol that determines the shape of the white +background. @var{thickness} is how far, as a multiple of +@var{line-thickness}, the white background extends past the extents +of stencil @var{stil}. If @var{thickness} has not been specified +by the user, an appropriate default is chosen based on @var{style}." + (let ((thick (* line-thickness + (if (number? thickness) + thickness + (if (eq? style 'outline) 3 0))))) + (if (eq? style 'outline) + (stencil-whiteout-outline stil thick) + (stencil-whiteout-box stil thick)))) (define-public (arrow-stencil-maker start? end?) "Return a function drawing a line from current point to @code{destination}, @@ -837,10 +851,10 @@ with optional arrows of @code{max-size} on start and end controlled by (make-simple-markup (simple-format #f "~a: NaN/inf" name)))) (let ((text-stencil (interpret-markup layout text-props - (markup #:whiteout-box #:simple name))) + (markup #:whiteout #:simple name))) (dim-stencil (interpret-markup layout text-props - (markup #:whiteout-box + (markup #:whiteout #:simple (cond ((interval-empty? extent) "empty")