]> git.donarmstrong.com Git - lilypond.git/commitdiff
markup: some skylines should not follow printed shapes; issue 3522
authorKeith OHara <k-ohara5a5a@oco.net>
Thu, 29 Aug 2013 17:43:40 +0000 (10:43 -0700)
committerKeith OHara <k-ohara5a5a@oco.net>
Fri, 6 Sep 2013 23:51:50 +0000 (16:51 -0700)
Implement the stencil tag 'transparent to support proper skylining of
stencils with extents different from their printed shapes, such as those
created by \transparent and \with-dimensions, or where the printed shape
is not yet known during layout, such as \page-ref.

input/regression/text-script-vertical-skylines.ly
lily/stencil-integral.cc
lily/stencil-interpret.cc
scm/define-markup-commands.scm
scm/define-stencil-commands.scm
scm/harp-pedals.scm
scm/stencil.scm

index a32818cb6eb30aa5baa9624f0eed0ff636a2e408..3657bc274d2be64891ca3219f8d091ee9b7f3964 100644 (file)
@@ -1,13 +1,23 @@
-\version "2.16.0"
+\version "2.17.21"
 
 \header {
-  texidoc = "By default, @code{TextScript} vertical skylines allow
-for stack @code{TextScript} grobs to fit snugly over each other instead
-of moving the entire distance of the bounding box.
-"
+  texidoc = "@code{TextScript}s are spaced closely, following outlines of
+the stencil.  When markup commands like @code{pad-around} and
+@code{with-dimensions} change the extent of a stencil, these changed
+extents have effect in the stencil outline used to place the resulting
+@code{TextScript}."
 }
 
-\relative c' {
-  a^\markup { \filled-box #'(0 . 2) #'(0 . 20) #0 hello}
-  a^\markup { world }
-}
\ No newline at end of file
+{
+  g'2^\markup { g \line {. . . .} }
+  e'^\markup { e }
+
+  g'2^\markup { g \transparent \line {. . . .} }
+  e'^\markup { e }
+
+  g'2^\markup { g \pad-around #0.5 \line{. . . .} }
+  e'^\markup { e }
+
+  g'2^\markup { g \with-dimensions #'(-0 . 0) #'(-0 . 0) \line {. . . .} }
+  e'^\markup { e }
+}
index dbd11f890eb0419e7e269d27edb6401c78da121d..4ae14e4609a361b95170859d997a20200187ed01 100644 (file)
@@ -953,6 +953,8 @@ stencil_traverser (PangoMatrix trans, SCM expr)
     return stencil_traverser (trans, scm_caddr (expr));
   else if (scm_car (expr) == ly_symbol2scm ("color"))
     return stencil_traverser (trans, scm_caddr (expr));
+  else if (scm_car (expr) == ly_symbol2scm ("transparent-stencil"))
+    return stencil_traverser (trans, scm_cadr (expr));
   else if (scm_car (expr) == ly_symbol2scm ("id"))
     return stencil_traverser (trans, scm_caddr (expr));
   else
index ee5dce0b005e3e17c08149a42f19a29be3b62c0e..734eb6080648ea4c7f496818c9a64994afb2bb08 100644 (file)
@@ -37,6 +37,8 @@ interpret_stencil_expression (SCM expr,
           interpret_stencil_expression (scm_force (scm_cadr (expr)), func, func_arg, o);
           return;
         }
+      if (head == ly_symbol2scm ("transparent-stencil"))
+        return;
       if (head == ly_symbol2scm ("footnote"))
         return;
       if (head == ly_symbol2scm ("translate-stencil"))
index d5aef111407ef761df49a63e72154294b9cfa883..88d33ecda9ea4e886630e41100b9daab75985b0e 100644 (file)
@@ -503,19 +503,18 @@ only works in the PDF backend.
   (let* ((arg-stencil (interpret-markup layout props arg))
          (x-ext (ly:stencil-extent arg-stencil X))
          (y-ext (ly:stencil-extent arg-stencil Y)))
-    (ly:make-stencil
-     `(delay-stencil-evaluation
-       ,(delay (ly:stencil-expr
-                (let* ((table (ly:output-def-lookup layout 'label-page-table))
+    (ly:stencil-add
+     (ly:make-stencil
+      `(delay-stencil-evaluation
+        ,(delay (let* ((table (ly:output-def-lookup layout 'label-page-table))
                        (page-number (if (list? table)
                                         (assoc-get label table)
-                                        #f))
-                       (link-expr (list 'page-link page-number
-                                        `(quote ,x-ext) `(quote ,y-ext))))
-                  (ly:stencil-add (ly:make-stencil link-expr x-ext y-ext)
-                                  arg-stencil)))))
-     x-ext
-     y-ext)))
+                                        #f)))
+                  (list 'page-link page-number
+                        `(quote ,x-ext) `(quote ,y-ext)))))
+      x-ext
+      y-ext)
+     arg-stencil)))
 
 
 (define-markup-command (beam layout props width slope thickness)
@@ -705,6 +704,7 @@ Provide a white background for @var{arg}.
 @cindex putting space around text
 
 Add space around a markup object.
+Identical to @code{pad-around}.
 
 @lilypond[verbatim,quote]
 \\markup {
@@ -719,15 +719,11 @@ Add space around a markup object.
   }
 }
 @end lilypond"
-  (let*
-      ((stil (interpret-markup layout props arg))
-       (xext (ly:stencil-extent stil X))
-       (yext (ly:stencil-extent stil Y)))
-
-    (ly:make-stencil
-     (ly:stencil-expr stil)
-     (interval-widen xext amount)
-     (interval-widen yext amount))))
+  (let* ((m (interpret-markup layout props arg))
+         (x (interval-widen (ly:stencil-extent m X) amount))
+         (y (interval-widen (ly:stencil-extent m Y) amount)))
+    (ly:stencil-add (make-transparent-box-stencil x y)
+                    m)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; space
@@ -1965,8 +1961,12 @@ alignment accordingly.
 @cindex setting extent of text objects
 
 Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
-  (let* ((m (interpret-markup layout props arg)))
-    (ly:make-stencil (ly:stencil-expr m) x y)))
+  (let* ((expr (ly:stencil-expr (interpret-markup layout props arg))))
+    (ly:stencil-add
+     (make-transparent-box-stencil x y)
+     (ly:make-stencil
+      `(delay-stencil-evaluation ,(delay expr))
+      x y))))
 
 (define-markup-command (pad-around layout props amount arg)
   (number? markup?)
@@ -1987,11 +1987,10 @@ Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}."
 }
 @end lilypond"
   (let* ((m (interpret-markup layout props arg))
-         (x (ly:stencil-extent m X))
-         (y (ly:stencil-extent m Y)))
-    (ly:make-stencil (ly:stencil-expr m)
-                     (interval-widen x amount)
-                     (interval-widen y amount))))
+         (x (interval-widen (ly:stencil-extent m X) amount))
+         (y (interval-widen (ly:stencil-extent m Y) amount)))
+    (ly:stencil-add (make-transparent-box-stencil x y)
+                    m)))
 
 (define-markup-command (pad-x layout props amount arg)
   (number? markup?)
@@ -2044,7 +2043,7 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction.
   (let* ((m (interpret-markup layout props arg))
          (x (ly:stencil-extent m X))
          (y (ly:stencil-extent m Y)))
-    (ly:make-stencil "" x y)))
+    (ly:make-stencil (list 'transparent-stencil (ly:stencil-expr m)) x y)))
 
 (define-markup-command (pad-to-box layout props x-ext y-ext arg)
   (number-pair? number-pair? markup?)
@@ -2064,12 +2063,8 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction.
   }
 }
 @end lilypond"
-  (let* ((m (interpret-markup layout props arg))
-         (x (ly:stencil-extent m X))
-         (y (ly:stencil-extent m Y)))
-    (ly:make-stencil (ly:stencil-expr m)
-                     (interval-union x-ext x)
-                     (interval-union y-ext y))))
+  (ly:stencil-add (make-transparent-box-stencil x-ext y-ext)
+                  (interpret-markup layout props arg)))
 
 (define-markup-command (hcenter-in layout props length arg)
   (number? markup?)
@@ -3811,7 +3806,7 @@ an inverted glyph.  Note that within music, one would usually use the
                     (if (eqv? direction DOWN)
                         (markup #:musicglyph "scripts.dfermata")
                         (markup #:musicglyph "scripts.ufermata"))))
-  
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; translating.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -4155,6 +4150,8 @@ when @var{label} is not found."
   (let* ((gauge-stencil (interpret-markup layout props gauge))
          (x-ext (ly:stencil-extent gauge-stencil X))
          (y-ext (ly:stencil-extent gauge-stencil Y)))
+   (ly:stencil-add
+    (make-transparent-box-stencil x-ext y-ext))
     (ly:make-stencil
      `(delay-stencil-evaluation
        ,(delay (ly:stencil-expr
index dffb578c6e800f7eeae60ef6333e338e671fcf15..a0a18603c2d3244356aec8b0464bd797180c7742 100644 (file)
@@ -67,6 +67,7 @@ are used internally in @file{lily/@/stencil-interpret.cc}."
     rotate-stencil
     scale-stencil
     translate-stencil
+    transparent-stencil
     ))
 
 (map ly:register-stencil-expression
index c245c82477f92fa001c04c46f43c2582ec268b2a..ea5db93f181befecdcbe970f3c9432f15b7cd19d 100644 (file)
@@ -124,13 +124,12 @@ spacing after the divider).
          (final-x (car result))
          (stencils (cdr result)))
     ;; Add the horizontal line and combine all stencils:
-    (box-stencil
-     (apply ly:stencil-add
-            (cons
-             (make-line-stencil line-width 0 0 final-x 0)
-             stencils))
-     0.0
-     0.0)))
+    (apply ly:stencil-add
+           (make-line-stencil line-width 0 0 final-x 0) ; the horizontal line
+           (make-transparent-box-stencil ; space for absent boxes
+             (cons 0 final-x)
+             (interval-widen '(0 . 0) (+ box-hheight dy)))
+           stencils)))
 
 ;; Parse the harp pedal definition string into list of directions (-1/0/1), #\o and #\|
 (define (harp-pedals-parse-string definition-string)
index 77a40026c0261c32fa6ca05215b84b9186700ed4..65852fc305a0ba9469784a69372886d6e0a14251 100644 (file)
@@ -181,6 +181,12 @@ the more angular the shape of the parenthesis."
      (interval-widen xext (/ width 2))
      (interval-widen yext (/ width 2)))))
 
+(define-public (make-transparent-box-stencil xext yext)
+  "Make a transparent box."
+  (ly:make-stencil
+   (list 'transparent-stencil
+         (ly:stencil-expr (make-filled-box-stencil xext yext)))
+   xext yext))
 
 (define-public (make-filled-box-stencil xext yext)
   "Make a filled box."