Reviewers: ,
Message:
Please review. This patch allows whiteout-box to take a number
argument. A boolean argument is still possible as well. This brings it
into parity with whiteout for both grobs and markups. This is a
preliminary step needed for the further changes described in issue 4504.
Description:
Issue 4504: Let whiteout-box take a number argument
This allows the size of the box whiteout style
to be customized, for grobs and markups. Boolean
arguments are still possible as well.
Please review this at https://codereview.appspot.com/264810043/
Affected files (+28, -16 lines):
M lily/grob.cc
M scm/define-grob-properties.scm
M scm/define-markup-commands.scm
M scm/stencil.scm
Index: lily/grob.cc
diff --git a/lily/grob.cc b/lily/grob.cc
index
a9c9532c7181bbdadc461527dcd8b140a7000f07..369135d2b26a49446e692b4446e4cda3b7202bbf
100644
--- a/lily/grob.cc
+++ b/lily/grob.cc
@@ -160,10 +160,14 @@ Grob::get_print_stencil () const
}
/* Calls the scheme procedure stencil-whiteout-box in
scm/stencils.scm */
- if (!transparent && to_boolean (get_property ("whiteout-box")))
+ 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<Stencil>
- (Lily::stencil_whiteout_box (retval.smobbed_copy ()));
+ (Lily::stencil_whiteout_box (retval.smobbed_copy (),
+ scm_from_double (thickness)));
}
if (transparent)
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
8649a67117190ed03523651b06dd0002d5e16859..fc8c86c5a3241095e2eaf408abccd3130442561a
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -1146,9 +1146,11 @@ 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? "If true, the grob is printed over a
-rounded rectangular white background to white-out underlying material,
-if the grob is visible. 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.")
(width ,ly:dimension? "The width of a grob measured in staff
space.")
(word-space ,ly:dimension? "Space to insert between words in
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index
363977da9be00b291770bfaddf504749751bebfe..561481cbab9ea941286479134a630b2b5fc5e370
100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -734,19 +734,23 @@ Provide a white background for @var{arg}.
(define-markup-command (whiteout-box layout props arg)
(markup?)
#:category other
+ #:properties ((thickness 0))
"
-@cindex adding a rounded rectangular white background to text
+@cindex adding a rectangular white background to text
-Provide a rounded rectangular white background for @var{arg}.
+Provide a rectangular white background for @var{arg}.
@lilypond[verbatim,quote]
\\markup {
\\combine
\\filled-box #'(-1 . 10) #'(-3 . 4) #1
- \\whiteout-box whiteout-box
+ \\override #'(thickness . 1.5) \\whiteout-box whiteout-box
}
@end lilypond"
- (stencil-whiteout-box (interpret-markup layout props arg)))
+ (stencil-whiteout-box
+ (interpret-markup layout props arg)
+ (* thickness
+ (ly:output-def-lookup layout 'line-thickness))))
(define-markup-command (pad-markup layout props amount arg)
(number? markup?)
Index: scm/stencil.scm
diff --git a/scm/stencil.scm b/scm/stencil.scm
index
f73b08163052b0567d0f2628887bbd8bd552dd19..fb2809e9fd2fee40c1d98660f7f10ac5ccf4711d
100644
--- a/scm/stencil.scm
+++ b/scm/stencil.scm
@@ -737,15 +737,17 @@ 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 stencil
+ #: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}."
(let*
- ((x-ext (ly:stencil-extent stencil X))
- (y-ext (ly:stencil-extent stencil Y)))
+ ((x-ext (interval-widen (ly:stencil-extent stencil X) thickness))
+ (y-ext (interval-widen (ly:stencil-extent stencil Y) thickness)))
- (ly:stencil-add
- (stencil-with-color (ly:round-filled-box x-ext y-ext 0.0)
- white)
- stencil)))
+ (ly:stencil-add
+ (stencil-with-color (ly:round-filled-box x-ext y-ext blot) color)
+ stencil)))
(define-public (arrow-stencil-maker start? end?)
"Return a function drawing a line from current point to
@code{destination},
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel