X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-markup-commands.scm;h=63300257208cd21847cec5cf1887d9b634b97d56;hb=5c14a087ca6cbd665fd631452b7b1283ba0387c3;hp=c5423eb9c21161a450534f82117833bd0401777c;hpb=736c4c4424df94925b07c47196a32c0a3344fa71;p=lilypond.git diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index c5423eb9c2..6330025720 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -42,13 +42,7 @@ A simple line. thickness)) (x (car dest)) (y (cdr dest))) - (ly:make-stencil - `(draw-line - ,th - 0 0 - ,x ,y) - (cons (min x 0) (max x 0)) - (cons (min y 0) (max y 0))))) + (make-line-stencil th 0 0 x y))) (define-builtin-markup-command (draw-circle layout props radius thickness fill) (number? number? boolean?) @@ -206,10 +200,7 @@ thickness and y offset. (x1 (car (ly:stencil-extent markup X))) (x2 (cdr (ly:stencil-extent markup X))) (y (* thick -2)) - (line (ly:make-stencil - `(draw-line ,thick ,x1 ,y ,x2 ,y) - (cons (min x1 0) (max x2 0)) - (cons thick thick)))) + (line (make-line-stencil thick x1 y x2 y))) (ly:stencil-add markup line))) (define-builtin-markup-command (box layout props arg) @@ -274,12 +265,12 @@ circle of diameter@tie{}0 (i.e. sharp corners). (corner-radius 1) (font-size 0) (box-padding 0.5)) - "@cindex enclosing text in a bow with rounded corners + "@cindex enclosing text in a box with rounded corners @cindex drawing boxes with rounded corners around text Draw a box with rounded corners around @var{arg}. Looks at @code{thickness}, @code{box-padding} and @code{font-size} properties to determine line thickness and padding around the markup; the @code{corner-radius} property -makes possible to define another shape for the corners (default is 1). +makes it possible to define another shape for the corners (default is 1). @lilypond[quote,verbatim,relative=2] c4^\\markup { @@ -799,7 +790,7 @@ determines the space between each markup in @var{args}. @lilypond[verbatim,quote] \\markup { \\line { - A simple line of text + one two three } } @end lilypond" @@ -825,13 +816,10 @@ equivalent to @code{\"fi\"}. @lilypond[verbatim,quote] \\markup { - \\bold { - au - \\concat { - Mouv - \\super - t - } + \\concat { + one + two + three } } @end lilypond" @@ -1199,7 +1187,13 @@ of the @code{#'direction} layout property. baseline-skip (interpret-markup-list layout props args))) -(define-builtin-markup-command (center-align 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-column layout props args) (markup-list?) align ((baseline-skip)) @@ -1210,16 +1204,54 @@ Put @code{args} in a centered column. @lilypond[verbatim,quote] \\markup { - \\center-align { + \\center-column { one two three } } @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?) @@ -1232,16 +1264,16 @@ Align @code{arg} to its Y@tie{}center. @lilypond[verbatim,quote] \\markup { - \\arrow-head #X #RIGHT ##f + one \\vcenter - Centered - \\arrow-head #X #LEFT ##f + two + three } @end lilypond" (let* ((mol (interpret-markup layout props arg))) (ly:stencil-aligned-to mol Y CENTER))) -(define-builtin-markup-command (hcenter layout props arg) +(define-builtin-markup-command (center-align layout props arg) (markup?) align () @@ -1253,9 +1285,10 @@ Align @code{arg} to its X@tie{}center. @lilypond[verbatim,quote] \\markup { \\column { - ↓ - \\hcenter - centered + one + \\center-align + two + three } } @end lilypond" @@ -1274,9 +1307,10 @@ Align @var{arg} on its right edge. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\right-align - right-aligned + two + three } } @end lilypond" @@ -1295,9 +1329,10 @@ Align @var{arg} on its left edge. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\left-align - left-aligned + two + three } } @end lilypond" @@ -1316,26 +1351,28 @@ Align @var{arg} in @var{axis} direction to the @var{dir} side. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\general-align #X #LEFT - \\line { X, Left } - ↓ + two + three + \\null + one \\general-align #X #CENTER - \\line { X, Center } + two + three \\null \\line { - \\arrow-head #X #RIGHT ##f - \\general-align #Y #DOWN - \\line { Y, Down } - \\arrow-head #X #LEFT ##f + one + \\general-align #Y #UP + two + three } + \\null \\line { - \\arrow-head #X #RIGHT ##f + one \\general-align #Y #3.2 - \\line { - \\line { Y, Arbitrary alignment } - } - \\arrow-head #X #LEFT ##f + two + three } } } @@ -1357,20 +1394,25 @@ alignment accordingly. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\halign #LEFT - Left - ↓ + two + three + \\null + one \\halign #CENTER - Center - ↓ + two + three + \\null + one \\halign #RIGHT - Right - ↓ - \\halign #1.2 - \\line { - Arbitrary alignment - } + two + three + \\null + one + \\halign #-5 + two + three } } @end lilypond" @@ -1443,17 +1485,11 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction. (interval-widen x amount) y))) -(define-builtin-markup-command (put-adjacent layout props arg1 axis dir arg2) - (markup? integer? ly:dir? markup?) +(define-builtin-markup-command (put-adjacent layout props axis dir arg1 arg2) + (integer? ly:dir? markup? markup?) align () - " -@ignore -This is broken, since there's no parser tag for the signature -markup_scm_scm_markup. Only works using Scheme markup. -np -@end ignore - -Put @var{arg2} next to @var{arg1}, without moving @var{arg1}." + "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}." (let ((m1 (interpret-markup layout props arg1)) (m2 (interpret-markup layout props arg2))) (ly:stencil-combine-at-edge m1 axis dir m2 0.0))) @@ -1532,7 +1568,7 @@ Put @var{arg2} next to @var{arg1}, without moving @var{arg1}." (make-pad-to-box-markup (cons (/ length -2) (/ length 2)) '(0 . 0) - (make-hcenter-markup arg)))) + (make-center-align-markup arg)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; property @@ -1637,27 +1673,6 @@ any sort of property supported by @rinternals{font-interface} and ;; fonts. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-builtin-markup-command (bigger layout props arg) - (markup?) - font - () - "Increase the font size relative to current setting. - -@lilypond[verbatim,quote] -\\markup { - \\huge { - huge - \\hspace #2 - \\bigger { - bigger - } - \\hspace #2 - huge - } -} -@end lilypond" - (interpret-markup layout props - `(,fontsize-markup 1 ,arg))) (define-builtin-markup-command (smaller layout props arg) (markup?) @@ -1685,7 +1700,7 @@ any sort of property supported by @rinternals{font-interface} and (markup?) font () - "Copy of the @code{\\bigger} command. + "Increase the font size relative to current setting. @lilypond[verbatim,quote] \\markup { @@ -1695,7 +1710,8 @@ any sort of property supported by @rinternals{font-interface} and larger } @end lilypond" - (interpret-markup layout props (make-bigger-markup arg))) + (interpret-markup layout props + `(,fontsize-markup 1 ,arg))) (define-builtin-markup-command (finger layout props arg) (markup?) @@ -2484,7 +2500,6 @@ and continue with double letters. (number->markletter-string number->mark-alphabet-vector num))) (define-public (horizontal-slash-interval num forward number-interval mag) - (ly:message "Mag step: ~a" mag) (if forward (cond ;((= num 6) (interval-widen number-interval (* mag 0.5))) ;((= num 5) (interval-widen number-interval (* mag 0.5))) @@ -2530,13 +2545,10 @@ and continue with double letters. (num-y (interval-widen (cons center center) (abs dy))) (is-sane (and (interval-sane? num-x) (interval-sane? num-y))) (slash-stencil (if is-sane - (ly:make-stencil - `(draw-line ,thickness - ,(car num-x) ,(- (interval-center num-y) dy) - ,(cdr num-x) ,(+ (interval-center num-y) dy)) - num-x num-y) + (make-line-stencil thickness + (car num-x) (- (interval-center num-y) dy) + (cdr num-x) (+ (interval-center num-y) dy)) #f))) -(ly:message "Num: ~a, X-interval: ~a" num num-x) (if (ly:stencil? slash-stencil) (begin ; for some numbers we need to shift the slash/backslash up or down to make @@ -2744,10 +2756,10 @@ A negative @var{amount} indicates raising; see also @code{\\raise}. @lilypond[verbatim,quote] \\markup { - default - \\lower #3 { - three spaces lower - } + one + \\lower #3 + two + three } @end lilypond" (ly:stencil-translate-axis (interpret-markup layout props arg)