Reviewers: Bertrand Bordage,
Message:
On 2011/09/17 17:31:15, Bertrand Bordage wrote:
Hi Joe,
At last, a fix for that!
But this looks unfinished. Are you working on a solution that would
avoid
having to specify the X-extent?
That isn't actually mentioned in the issue report, but ok :)
A fix that calculates the font size of the ParenthesesItem according
to the
Y-extent of the parenthesized grobs would also be awesome :)
Yes, there's another bug report for that. I haven't attempted it yet.
Joe
Description:
Fix 155: parentheses include accidentals and dots.
Make parentheses around noteheads include accidentals and dots.
Make parentheses around rests include dots.
Please review this at http://codereview.appspot.com/5047048/
Affected files:
A input/regression/parenthesize-notes-accidentals.ly
M lily/grob.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm
Index: input/regression/parenthesize-notes-accidentals.ly
diff --git a/input/regression/parenthesize-notes-accidentals.ly
b/input/regression/parenthesize-notes-accidentals.ly
new file mode 100644
index
0000000000000000000000000000000000000000..039259e3a02d9b66f1f79ff55b0d97e7021a4389
--- /dev/null
+++ b/input/regression/parenthesize-notes-accidentals.ly
@@ -0,0 +1,12 @@
+\version "2.15.12"
+
+\header {
+ texidoc = "Parentheses around notes also include accidentals and dots,
+but they are centered on the note head."
+}
+
+\score {
+ \new Staff {
+ <\parenthesize ais'>4. <\parenthesize bes'>
+ }
+}
Index: lily/grob.cc
diff --git a/lily/grob.cc b/lily/grob.cc
index
36aadb4e938b549df05260d98cf7dc13030e6455..c21059ba2a3c70969b2ae8149bd6b05d5a12e3df
100644
--- a/lily/grob.cc
+++ b/lily/grob.cc
@@ -678,6 +678,7 @@ ADD_INTERFACE (Grob,
"outside-staff-horizontal-padding "
"outside-staff-padding "
"outside-staff-priority "
+ "parenthesis-friends "
"pure-Y-offset-in-progress "
"rotation "
"springs-and-rods "
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
ecd67e5b122df92430f7465fc9f61bc1b3e1b67d..3b55ef91b0d30620c33051006758b11db0f690d7
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -661,6 +661,9 @@ at a column with a negative penalty.")
(page-turn-permission ,symbol? "Instructs the page breaker on
whether to put a page turn at this column. Can be @code{force} or
@code{allow}.")
+ (parenthesis-friends ,list? "A list of symbols. Any parenthesis
+enclosing this grob will also enclose the grobs obtained by looking
+up these symbols on the parent grob.")
(parenthesized ,boolean? "Parenthesize this grob.")
(positions ,number-pair? "Pair of staff coordinates
@code{(@var{left} . @var{right})}, where both @var{left} and
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index
d7bc5ccb00f8b53eb40fcc1b1178f894f68d315e..0794d247f3e88cc0872188872861b636998f0acf
100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1449,6 +1449,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)
@@ -1558,6 +1559,7 @@
(padding . 0.2)
(stencil . ,parentheses-item::print)
(stencils . ,parentheses-item::calc-parenthesis-stencils)
+ (Y-extent . ,parentheses-item::y-extent)
(meta . ((class . Item)
(interfaces . (font-interface
parentheses-interface))))))
@@ -1701,6 +1703,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)
(X-extent . ,ly:rest::width)
(Y-extent . ,ly:rest::height)
@@ -2642,6 +2645,7 @@
(,ly:beam::rest-collision-callback . ,ly:beam::pure-rest-collision-callback)
(,ly:grob::stencil-height . ,pure-stencil-height)
(,ly:hara-kiri-group-spanner::y-extent . ,ly:hara-kiri-group-spanner::pure-height)
+ (,parentheses-item::y-extent . ,parentheses-item::pure-y-extent)
(,ly:rest-collision::force-shift-callback-rest . ,pure-chain-offset-callback)
(,ly:rest::height . ,ly:rest::pure-height)
(,ly:self-alignment-interface::y-aligned-on-self . ,ly:self-alignment-interface::pure-y-aligned-on-self)
Index: scm/output-lib.scm
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index
70e3ba3eeb07885ff46475ec6f20b2a841dd01f8..059ccd422b9e923c2c586e89b2f65ab48e307bd7
100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -619,12 +619,33 @@ and duration-log @var{log}."
(list (stencil-whiteout lp)
(stencil-whiteout rp))))
+(define-public (parentheses-item::pure-y-extent grob start end)
+ (let* ((paren (parentheses-item::calc-parenthesis-stencils grob))
+ (Y-ext (ly:stencil-extent (car paren) Y))
+ (elt-Y-ext (ly:axis-group-interface::pure-height grob start end))
+ (foo (display "calculating pure y extent"))
+ (y-center (interval-center elt-Y-ext)))
+ (cons (+ y-center (car Y-ext))
+ (+ y-center (cdr Y-ext)))))
+
+(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))
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel