X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Ffret-diagrams.scm;h=558c11ebf679a8067617fcd90c93a0546ed2a7df;hb=f9d2a3f060cdf9cfb1ceaf8617936872bf5a5cb5;hp=a37c490aa9880facbe4b49ac787a4bd0a2a296b1;hpb=8bc8a5cc9cc41627632990cc749490d9c1979006;p=lilypond.git diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index a37c490aa9..558c11ebf6 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -1,8 +1,19 @@ -;;;; fret-diagrams.scm -- +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; source file of the GNU LilyPond music typesetter +;;;; Copyright (C) 2004--2011 Carl D. Sorensen ;;;; -;;;; (c) 2004--2009 Carl D. Sorensen +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. +;;;; +;;;; LilyPond is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . ; ; Utility functions @@ -89,7 +100,7 @@ to end-point." (define (merge-details key alist-list . default) "Return @code{alist-list} entries for @code{key}, in one combined alist. -There can be two @code{alist-list} entries for a given key. The first +There can be two @code{alist-list} entries for a given key. The first comes from the override-markup function, the second comes from property settings during a regular override. This is necessary because some details can be set in one @@ -101,9 +112,9 @@ found." (define (helper key alist-list default) (if (null? alist-list) default - (let* ((handle (assoc key (car alist-list)))) - (if (pair? handle) - (append (cdr handle) (chain-assoc-get key (cdr alist-list) '())) + (let* ((entry (assoc-get key (car alist-list)))) + (if entry + (append entry (chain-assoc-get key (cdr alist-list) '())) (helper key (cdr alist-list) default))))) (helper key alist-list @@ -254,7 +265,7 @@ with magnification @var{mag} of the string @var{text}." ; and draw-barre (dot-position (assoc-get - 'dot-position details default-dot-position)) ; needed for + 'dot-position details default-dot-position)) ; needed for ; draw-dots and draw-barre (th (* (ly:output-def-lookup layout 'line-thickness) @@ -268,11 +279,11 @@ with magnification @var{mag} of the string @var{text}." (* size (assoc-get 'xo-padding details 0.2))) ; needed only here (parameters (fret-parse-marking-list marking-list my-fret-count)) (capo-fret (assoc-get 'capo-fret parameters 0)) - (dot-list (cdr (assoc 'dot-list parameters))) - (xo-list (cdr (assoc 'xo-list parameters))) - (fret-range (cdr (assoc 'fret-range parameters))) + (dot-list (assoc-get 'dot-list parameters)) + (xo-list (assoc-get 'xo-list parameters)) + (fret-range (assoc-get 'fret-range parameters)) (my-fret-count (fret-count fret-range)) - (barre-list (cdr (assoc 'barre-list parameters))) + (barre-list (assoc-get 'barre-list parameters)) (barre-type (assoc-get 'barre-type details 'curved)) (fret-diagram-stencil '())) @@ -293,6 +304,19 @@ with magnification @var{mag} of the string @var{text}." (else (cons string-coordinate (- fret-coordinate))))) + (define (stencil-coordinate-offset fret-offset string-offset) + "Return a pair @code{(x-offset . y-offset)} + for translation in stencil coordinate system." + (cond + ((eq? orientation 'landscape) + (cons fret-offset (- string-offset))) + ((eq? orientation 'opposing-landscape) + (cons (- fret-offset) string-offset)) + (else + (cons string-offset (- fret-offset))))) + + + (define (make-bezier-sandwich-list start stop base height half-thickness) "Make the argument list for a bezier sandwich from @@ -339,7 +363,7 @@ baseline at fret coordinate @var{base}, a height of "Draw the string lines for a fret diagram with @var{string-count} strings and frets as indicated in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by -@var{size}. Orientation is determined by @var{orientation}. " +@var{size}. Orientation is determined by @var{orientation}." (define (helper x) (if (null? (cdr x)) @@ -376,7 +400,7 @@ Line thickness is given by @var{th}, fret & string spacing by "Draw the fret lines for a fret diagram with @var{string-count} strings and frets as indicated in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by -@var{size}. Orientation is given by @var{orientation}." +@var{size}. Orientation is given by @var{orientation}." (define (helper x) (if (null? (cdr x)) (fret-stencil (car x)) @@ -642,6 +666,7 @@ fret-diagram overall parameters." (if (null? restlist) positioned-glyph (ly:stencil-add + positioned-glyph (draw-xo restlist))))) (define (draw-capo fret) @@ -734,18 +759,19 @@ at @var{fret}." (xo-stencil (draw-xo xo-list)) (xo-fret-offset (stencil-fretboard-offset - xo-stencil 'fret orientation))) + xo-stencil 'fret orientation)) + (xo-stencil-offset + (stencil-coordinate-offset + (- diagram-fret-top + xo-fret-offset + (* size xo-padding)) + 0))) (set! fret-diagram-stencil (ly:stencil-add fret-diagram-stencil (ly:stencil-translate xo-stencil - (stencil-coordinates - (- diagram-fret-top - xo-fret-offset - (* size xo-padding)) - 0)))))) ; no string offset - + xo-stencil-offset))))) (if (> capo-fret 0) (set! fret-diagram-stencil (ly:stencil-add @@ -901,14 +927,14 @@ a fret-indication list with the appropriate values" `(,props . ,output-list))) ; ugh -- hard coded; proc is better -(define-builtin-markup-command +(define-markup-command (fret-diagram-verbose layout props marking-list) (pair?) ; argument type (list, but use pair? for speed) - instrument-specific-markup ; markup type - ((align-dir -0.4) ; properties and defaults - (size 1.0) - (fret-diagram-details) - (thickness 0.5)) + #:category instrument-specific-markup ; markup type + #:properties ((align-dir -0.4) ; properties and defaults + (size 1.0) + (fret-diagram-details) + (thickness 0.5)) "Make a fret diagram containing the symbols indicated in @var{marking-list}. For example, @@ -954,10 +980,10 @@ indications per string. (make-fret-diagram layout props marking-list)) -(define-builtin-markup-command (fret-diagram layout props definition-string) +(define-markup-command (fret-diagram layout props definition-string) (string?) ; argument type - instrument-specific-markup ; markup category - (fret-diagram-verbose-markup) ; properties and defaults + #:category instrument-specific-markup ; markup category + #:properties (fret-diagram-verbose-markup) ; properties and defaults "Make a (guitar) fret diagram. For example, say @example @@ -1031,11 +1057,11 @@ Note: There is no limit to the number of fret indications per string. (fret-diagram-verbose-markup layout (car definition-list) (cdr definition-list)))) -(define-builtin-markup-command +(define-markup-command (fret-diagram-terse layout props definition-string) (string?) ; argument type - instrument-specific-markup ; markup category - (fret-diagram-verbose-markup) ; properties + #:category instrument-specific-markup ; markup category + #:properties (fret-diagram-verbose-markup) ; properties "Make a fret diagram markup using terse string-based syntax. Here is an example