Reviewers: ,
Description:
Let general-column deal reliable with empty args
Previously an args-list of empty-stencils issued a programming error:
Improbable offset for stencil: -inf staff space
This patch removes empty stencils from the args-list.
If args-list is empty, an empty stencil is returned.
Please review this at https://codereview.appspot.com/346030043/
Affected files (+16, -6 lines):
M scm/define-markup-commands.scm
Index: scm/define-markup-commands.scm
diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm
index
0eb9ed93542ea9e7f61abaaf5a890fb8ff6ed0db..a1a8d86593fabd48a40a1909e1ed38b02ff70a5d
100644
--- a/scm/define-markup-commands.scm
+++ b/scm/define-markup-commands.scm
@@ -1999,12 +1999,22 @@ setting of the @code{direction} layout property.
(interpret-markup-list layout props args)))
(define (general-column align-dir baseline mols)
- "Stack @var{mols} vertically, aligned to @var{align-dir} horizontally."
-
- (let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X
align-dir)) mols))
- (stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
- (stacked-extent (ly:stencil-extent stacked-stencil X)))
- (ly:stencil-translate-axis stacked-stencil (- (car stacked-extent)) X
)))
+ "Stack @var{mols} vertically, aligned to @var{align-dir} horizontally.
+Remove empty stencils from @var{mols}. If @var{mols} is an empty list
return
+@code{empty-stencil}."
+ (let ((aligned-mols
+ (filter-map
+ (lambda (x)
+ (if (ly:stencil-empty? x)
+ #f
+ (ly:stencil-aligned-to x X align-dir)))
+ mols)))
+ (if (pair? aligned-mols)
+ (let* ((stacked-stencil (stack-lines -1 0.0 baseline aligned-mols))
+ (stacked-extent (ly:stencil-extent stacked-stencil X)))
+ (ly:stencil-translate-axis
+ stacked-stencil (- (car stacked-extent)) X))
+ empty-stencil)))
(define-markup-command (center-column layout props args)
(markup-list?)
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel