From 0a51140a609389edb40cfee3cbc827a150ba15ad Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Tue, 19 Aug 2008 22:25:16 +0100 Subject: [PATCH] New markup commands: \left-column and \right-column. --- input/regression/markup-column-align.ly | 31 ++++++++++++++++++++ scm/define-markup-commands.scm | 50 +++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 input/regression/markup-column-align.ly diff --git a/input/regression/markup-column-align.ly b/input/regression/markup-column-align.ly new file mode 100644 index 0000000000..d45f4660e4 --- /dev/null +++ b/input/regression/markup-column-align.ly @@ -0,0 +1,31 @@ +\version "2.11.57" +\header { + +texidoc = "Fixed horizontal alignment of columns of text can be set using +\left-column, \center-align and \right-column. +" + +} + +\markup { + \line { + \left-column { + one + two + three + } + \hspace #4 + \center-align { + one + \left-align + two + three + } + \hspace #6 + \right-column { + one + two + three + } + } +} diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index a63dba2995..68acb63ef6 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1187,6 +1187,12 @@ of the @code{#'direction} layout property. baseline-skip (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))) + (stack-lines -1 0.0 baseline aligned-mols))) + (define-builtin-markup-command (center-align layout props args) (markup-list?) align @@ -1205,9 +1211,47 @@ Put @code{args} in a centered column. } } @end lilypond" - (let* ((mols (interpret-markup-list layout props args)) - (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols))) - (stack-lines -1 0.0 baseline-skip cmols))) + (general-column CENTER baseline-skip (interpret-markup-list layout props args))) + +(define-builtin-markup-command (left-column layout props args) + (markup-list?) + align + ((baseline-skip)) + " +@cindex text columns, left-aligned + +Put @code{args} in a left-aligned column. + +@lilypond[verbatim,quote] +\\markup { + \\left-column { + one + two + three + } +} +@end lilypond" + (general-column LEFT baseline-skip (interpret-markup-list layout props args))) + +(define-builtin-markup-command (right-column layout props args) + (markup-list?) + align + ((baseline-skip)) + " +@cindex text columns, right-aligned + +Put @code{args} in a right-aligned column. + +@lilypond[verbatim,quote] +\\markup { + \\right-column { + one + two + three + } +} +@end lilypond" + (general-column RIGHT baseline-skip (interpret-markup-list layout props args))) (define-builtin-markup-command (vcenter layout props arg) (markup?) -- 2.11.4.GIT