Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(536)

Unified Diff: scm/define-markup-commands.scm

Issue 357740043: Avoid multiple evaluation of markups \pattern \fill-with-pattern
Patch Set: Add regtest Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « input/regression/pattern-markup-evaluation.ly ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index a1a8d86593fabd48a40a1909e1ed38b02ff70a5d..ede5aaa5c21f955abb283e89e1ee28ce4aa85295 100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -4575,6 +4575,9 @@ Negative values may be used to produce mirror images.
;; Repeating
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; TODO: this should really be pieced together at stencil level rather
+;; than markup level
+
(define-markup-command (pattern layout props count axis space pattern)
(integer? integer? number? markup?)
#:category other
@@ -4592,21 +4595,22 @@ Patterns are distributed on @var{axis}.
\\pattern #3 #Y #0.5 \\flat
}
@end lilypond"
- (let ((pattern-width (interval-length
- (ly:stencil-extent (interpret-markup layout props pattern) X)))
- (new-props (prepend-alist-chain 'word-space 0 (prepend-alist-chain 'baseline-skip 0 props))))
+ (let* ((pattern-stencil (interpret-markup layout props pattern))
+ (pattern-width (interval-length
+ (ly:stencil-extent pattern-stencil X)))
+ (new-props (prepend-alist-chain 'word-space 0 (prepend-alist-chain 'baseline-skip 0 props))))
(let loop ((i (1- count)) (patterns (markup)))
(if (zero? i)
(interpret-markup
layout
new-props
(if (= axis X)
- (markup patterns pattern)
- (markup #:column (patterns pattern))))
+ (markup patterns #:stencil pattern-stencil)
+ (markup #:column (patterns #:stencil pattern-stencil))))
(loop (1- i)
(if (= axis X)
- (markup patterns pattern #:hspace space)
- (markup #:column (patterns pattern #:vspace space))))))))
+ (markup patterns #:stencil pattern-stencil #:hspace space)
+ (markup #:column (patterns #:stencil pattern-stencil #:vspace space))))))))
(define-markup-command (fill-with-pattern layout props space dir pattern left right)
(number? ly:dir? markup? markup? markup?)
@@ -4635,20 +4639,24 @@ Patterns are aligned to the @var{dir} markup.
\\fill-with-pattern #2 #LEFT : left second
}
@end lilypond"
- (let* ((pattern-x-extent (ly:stencil-extent (interpret-markup layout props pattern) X))
+ (let* ((pattern-stencil (interpret-markup layout props pattern))
+ (pattern-x-extent (ly:stencil-extent pattern-stencil X))
(pattern-width (interval-length pattern-x-extent))
- (left-width (interval-length (ly:stencil-extent (interpret-markup layout props left) X)))
- (right-width (interval-length (ly:stencil-extent (interpret-markup layout props right) X)))
+ (left-stencil (interpret-markup layout props left))
+ (left-width (interval-length (ly:stencil-extent left-stencil X)))
+ (right-stencil (interpret-markup layout props right))
+ (right-width (interval-length (ly:stencil-extent right-stencil X)))
(middle-width (max 0 (- line-width (+ (+ left-width right-width) (* word-space 2)))))
(period (+ space pattern-width))
(count (truncate (/ (- middle-width pattern-width) period)))
(x-offset (+ (* (- (- middle-width (* count period)) pattern-width) (/ (1+ dir) 2)) (abs (car pattern-x-extent)))))
(interpret-markup layout props
- (markup left
+ (markup #:stencil left-stencil
#:with-dimensions (cons 0 middle-width) '(0 . 0)
#:translate (cons x-offset 0)
- #:pattern (1+ count) X space pattern
- right))))
+ #:pattern (1+ count) X space
+ #:stencil pattern-stencil
+ #:stencil right-stencil))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Replacements
« no previous file with comments | « input/regression/pattern-markup-evaluation.ly ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b