]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-markup-commands.scm
*** empty log message ***
[lilypond.git] / scm / define-markup-commands.scm
index 641a4485074c521eb1e5d58b834b27ec8dc89fb7..8d4fc21eca762e32a5b8cb26356423be23fadf98 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c)  2000--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;; (c) 2000--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
 
 ;;; markup commands
@@ -332,11 +332,17 @@ of the @code{#'direction} layout property."
     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
 
 (def-markup-command (vcenter layout props arg) (markup?)
-  "Align @code{arg} to its center. "
+  "Align @code{arg} to its center. "
   (let* ((mol (interpret-markup layout props arg)))
     (ly:stencil-align-to! mol Y CENTER)
     mol))
 
+(def-markup-command (hcenter layout props arg) (markup?)
+  "Align @code{arg} to its X center. "
+  (let* ((mol (interpret-markup layout props arg)))
+    (ly:stencil-align-to! mol X CENTER)
+    mol))
+
 (def-markup-command (right-align layout props arg) (markup?)
   "Align @var{arg} on its right edge. "
   (let* ((m (interpret-markup layout props arg)))
@@ -562,6 +568,26 @@ that.
    (* -0.5 (chain-assoc-get 'baseline-skip props))
    Y))
 
+(def-markup-command (beam layout props width slope thickness) (number? number? number?)
+  "Create a beam with the specified parameters."
+
+  (let*
+      ((y (* slope width))
+       (yext (cons (min 0 y) (max 0 y)))
+       (half (/ thickness 2)))
+       
+    (ly:make-stencil
+     (list 'beam width
+          slope
+          thickness
+          (ly:output-def-lookup layout 'blotdiameter))
+     (cons 0 width)
+     (cons (+ (- half) (car yext))
+          (+ half (cdr yext))))
+
+    ))
+
+
 (def-markup-command (normal-size-sub layout props arg) (markup?)
   "Set @var{arg} in subscript, in a normal font size."
   (ly:stencil-translate-axis
@@ -621,12 +647,15 @@ any sort of property supported by @internalsref{font-interface} and
 (def-markup-command larger (markup?) bigger-markup)
 
 (def-markup-command (box layout props arg) (markup?)
-  "Draw a box round @var{arg}.  Looks at @code{thickness} and
-@code{box-padding} properties to determine line thickness and padding
-around the markup."
-  (let ((th (chain-assoc-get 'thickness props  0.1))
-        (pad (chain-assoc-get 'box-padding props 0.2))
-        (m (interpret-markup layout props arg)))
+  "Draw a box round @var{arg}.  Looks at @code{thickness},
+@code{box-padding} and @code{font-size} properties to determine line
+thickness and padding around the markup."
+  (let* ((th (chain-assoc-get 'thickness props  0.1))
+        (size (chain-assoc-get 'font-size props 0))
+        (pad
+         (* (magstep size)
+            (chain-assoc-get 'box-padding props 0.2)))
+        (m (interpret-markup layout props arg)))
     (box-stencil m th pad)))
 
 ;;FIXME: is this working? 
@@ -685,7 +714,7 @@ the elements marked in @var{indices}, which is a list of numbers."
   (define (stack-stencils stencils bskip last-stencil)
     (cond
      ((null? stencils) '())
-     ((not last-stencil)
+     ((not (ly:stencil? last-stencil))
       (cons (car stencils)
            (stack-stencils (cdr stencils) bskip (car stencils))))
      (else
@@ -730,7 +759,8 @@ the elements marked in @var{indices}, which is a list of numbers."
                  x)) args))
         (leading
          (chain-assoc-get 'baseline-skip props))
-        (stacked (stack-stencils stencils 1.25 #f))
+        (stacked (stack-stencils
+                  (remove ly:stencil-empty? stencils) 1.25 #f))
         (brackets (make-brackets stacked indices '())))
 
     (apply ly:stencil-add