]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4504/1 add whiteout-style, drop whiteout-box
authorPaul Morris <paulwmorris@gmail.com>
Tue, 10 Nov 2015 21:13:38 +0000 (16:13 -0500)
committerJames Lowe <pkx166h@gmail.com>
Wed, 11 Nov 2015 13:51:06 +0000 (13:51 +0000)
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.

lily/grob.cc
lily/lily-imports.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/define-markup-commands.scm
scm/stencil.scm

index 2f1bd8aa9f52c463c274fa28ab6fe2fc60227d03..7ce89d50158ff737e2e702609c1f7750422b84d6 100644 (file)
@@ -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<Stencil>
             (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<Stencil>
-            (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 "
               );
 
 /****************************************************************
index 04f0f7e57fbf732a9248dc1e13ff09fd05848ec2..a62216e0849988f632c98d50d502cf1b7fe23b6e 100644 (file)
@@ -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");
index fc8c86c5a3241095e2eaf408abccd3130442561a..b387da206ea8bfeb304950075fe779f009b7e395 100644 (file)
@@ -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
index e7fc4bb956903f918f1aa265d28ffda553c0182f..3528933f6836ac4f50d47234fb17c9fdeefc4884 100644 (file)
         (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)
index 57e2e8893a26334a2d5af498ba518668b158ed03..0ca1042e8df936df77100711ee4831bc7dea6497 100644 (file)
@@ -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?)
index 6410eae44c961ca049366d4fb12e3f1202da7780..8e4499d87996963977b38907507869d4a5df64e9 100644 (file)
@@ -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")