--- /dev/null
+\version "2.19.19"
+
+\header {
+ texidoc = "Parentheses around notes also include accidentals and dots;
+they are centered on the vertical center of the combined enclosed items."
+}
+
+\score {
+ \new Staff {
+ \parenthesize ais'4. \parenthesize des''4
+ }
+}
+
"meta "
"minimum-X-extent "
"minimum-Y-extent "
+ "parenthesis-friends "
"pure-Y-offset-in-progress "
"rotation "
"skyline-horizontal-padding "
used.")
(parent-alignment-Y ,number? "Like @code{parent-alignment-X}
but for the Y@tie{}axis.")
+ (parenthesis-friends ,list? "A list of Grob types, as symbols.
+When parentheses enclose a Grob that has 'parenthesis-friends, the
+parentheses widen to include any child Grobs with type among
+'parenthesis-friends.")
(parenthesized ,boolean? "Parenthesize this grob.")
(positions ,number-pair? "Pair of staff coordinates
@code{(@var{left} . @var{right})}, where both @var{left} and
(extra-spacing-height . ,ly:note-head::include-ledger-line-height)
(glyph-name . ,note-head::calc-glyph-name)
(ligature-flexa . #f)
+ (parenthesis-friends . (accidental-grob dot))
(stem-attachment . ,ly:note-head::calc-stem-attachment)
(stencil . ,ly:note-head::print)
(X-offset . ,ly:note-head::stem-x-shift)
;; horizontal attachment. ParenthesesItem does not reserve
;; space of its own, however.
(X-extent . (0 . 0))
+ (Y-extent . ,parentheses-item::y-extent)
(meta . ((class . Item)
(interfaces . (font-interface
parentheses-interface))))))
(cross-staff . ,ly:rest::calc-cross-staff)
(duration-log . ,stem::calc-duration-log)
(minimum-distance . 0.25)
+ (parenthesis-friends . (dot))
(stencil . ,ly:rest::print)
(voiced-position . 4)
(X-extent . ,ly:rest::width)
(duration-log . ,note-head::calc-duration-log)
(font-series . bold)
(font-size . -2)
+ (parenthesis-friends . (dot))
(stem-attachment . (0.0 . 1.35))
(stencil . ,tab-note-head::print)
(whiteout . #t)
(list (stencil-whiteout lp)
(stencil-whiteout rp))))
+(define-public (parentheses-item::y-extent grob) (ly:grob::stencil-height grob))
+
(define (parenthesize-elements grob . rest)
(let* ((refp (if (null? rest)
grob
(car rest)))
- (elts (ly:grob-object grob 'elements))
- (x-ext (ly:relative-group-extent elts refp X))
+ (elts (ly:grob-array->list (ly:grob-object grob 'elements)))
+ (get-friends
+ (lambda (g)
+ (let ((syms (ly:grob-property g 'parenthesis-friends '()))
+ (get-friend (lambda (s)
+ (let ((f (ly:grob-object g s)))
+ (cond
+ ((ly:grob? f) (list f))
+ ((ly:grob-array? f) (ly:grob-array->list f))
+ (else '()))))))
+ (apply append (map get-friend syms)))))
+ (friends (apply append elts (map get-friends elts)))
+ (x-ext (ly:relative-group-extent friends refp X))
(stencils (ly:grob-property grob 'stencils))
(lp (car stencils))
(rp (cadr stencils))