From: Carl Sorensen Date: Wed, 15 Apr 2015 02:04:50 +0000 (-0600) Subject: Updated patch for issue 155 X-Git-Tag: release/2.19.20-1~33^2~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3ca81140f81875a399777cfffe14cdd32c74f7c8;p=lilypond.git Updated patch for issue 155 Use Joe Neeman's code to enclose dots and accidentals inside parentheses around note heads. Eliminate pure-Y-extent (no longer needed) Improve documentation string for parenthesis friends Improve regression test --- diff --git a/input/regression/parenthesize-notes-accidentals.ly b/input/regression/parenthesize-notes-accidentals.ly new file mode 100644 index 0000000000..f1a15fb4e6 --- /dev/null +++ b/input/regression/parenthesize-notes-accidentals.ly @@ -0,0 +1,13 @@ +\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 + } +} + diff --git a/lily/grob.cc b/lily/grob.cc index 99d027f2f3..435a6faff3 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -818,6 +818,7 @@ ADD_INTERFACE (Grob, "meta " "minimum-X-extent " "minimum-Y-extent " + "parenthesis-friends " "pure-Y-offset-in-progress " "rotation " "skyline-horizontal-padding " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 3914cf459d..bbd2405541 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -777,6 +777,10 @@ If unset, the value from @code{self-alignment-X} property will be 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 diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index f82f27cec3..cdae45dd17 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1635,6 +1635,7 @@ (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) @@ -1734,6 +1735,7 @@ ;; 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)))))) @@ -1881,6 +1883,7 @@ (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) @@ -2355,6 +2358,7 @@ (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) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index a73e2c0324..33ad81ae50 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -905,12 +905,25 @@ and duration-log @var{log}." (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))