diff options
author | Nicolas Sceaux <nicolas.sceaux@free.fr> | 2011-02-16 22:42:36 +0100 |
---|---|---|
committer | Nicolas Sceaux <nicolas.sceaux@free.fr> | 2011-03-13 10:06:43 +0100 |
commit | ca9ecc27bcb2816add10360e56f43501de389366 (patch) | |
tree | c810a30336f0a74db10db20aea35789ccf935246 | |
parent | 55ed3dba5094da3fbab324a028174f2b28d74c30 (diff) |
Fret diagram fixes
- fix padding and size of mute/open signs when size is overridden
- fix first fret label position
- allow fully customizable first fret label
- allow per-finger dot color change
- add reg test for fret diagram magnification
- add a test case for first fret custom label
- add a test case for dot color inversion
-rw-r--r-- | input/regression/fret-diagrams-fingering.ly | 29 | ||||
-rw-r--r-- | input/regression/fret-diagrams-fret-label.ly | 16 | ||||
-rw-r--r-- | input/regression/fret-diagrams-size.ly | 26 | ||||
-rw-r--r-- | scm/define-grob-properties.scm | 8 | ||||
-rw-r--r-- | scm/fret-diagrams.scm | 51 |
5 files changed, 111 insertions, 19 deletions
diff --git a/input/regression/fret-diagrams-fingering.ly b/input/regression/fret-diagrams-fingering.ly index 5833e0b998..f2da8d4562 100644 --- a/input/regression/fret-diagrams-fingering.ly +++ b/input/regression/fret-diagrams-fingering.ly @@ -3,8 +3,8 @@ \header { texidoc=" Finger labels can be added, either in dots or below strings. -Dot color can be changed, and fingering label font size -can be adjusted. +Dot color can be changed globally or on a per-dot basis, +and fingering label font size can be adjusted. " } @@ -17,6 +17,8 @@ can be adjusted. c1 | c1 | c1 | + c1 | + c1 | c1 } @@ -81,7 +83,28 @@ can be adjusted. (place-fret 2 5 4) (place-fret 1 3 1) (barre 5 1 3))} - + %% dot color inversion, white on black + \once \override TextScript #'fret-diagram-details + #'dot-color = #'black + c' ^\markup { + \fret-diagram-verbose #'((mute 6) + (place-fret 5 3 1 inverted) + (place-fret 4 5 2) + (place-fret 3 5 3 inverted) + (place-fret 2 5 4) + (place-fret 1 3 1) + (barre 5 1 3))} + %% dot color inversion, black on white + \once \override TextScript #'fret-diagram-details + #'dot-color = #'white + c' ^\markup { + \fret-diagram-verbose #'((mute 6) + (place-fret 5 3 1 inverted) + (place-fret 4 5 2) + (place-fret 3 5 3 inverted) + (place-fret 2 5 4) + (place-fret 1 3 1) + (barre 5 1 3))} } >> diff --git a/input/regression/fret-diagrams-fret-label.ly b/input/regression/fret-diagrams-fret-label.ly index e45755c8f2..390b01c737 100644 --- a/input/regression/fret-diagrams-fret-label.ly +++ b/input/regression/fret-diagrams-fret-label.ly @@ -14,6 +14,7 @@ size, and number type. \chords { c1 | c1 | + c1 | c1 } @@ -61,6 +62,21 @@ size, and number type. (place-fret 1 3 1) (barre 5 1 3))} + %% C major for guitar, verbose style + \revert TextScript #'fret-diagram-details #'label-dir + \once \override TextScript #'fret-diagram-details + #'number-type = #'custom + \once \override TextScript #'fret-diagram-details + #'fret-label-custom-format = #"~d°" + c' ^\markup { + \fret-diagram-verbose #'((mute 6) + (place-fret 5 3 1) + (place-fret 4 5 2) + (place-fret 3 5 3) + (place-fret 2 5 4) + (place-fret 1 3 1) + (barre 5 1 3))} + } >> diff --git a/input/regression/fret-diagrams-size.ly b/input/regression/fret-diagrams-size.ly new file mode 100644 index 0000000000..5a52612198 --- /dev/null +++ b/input/regression/fret-diagrams-size.ly @@ -0,0 +1,26 @@ +\version "2.13.51" + +\header { + texidoc=" +Fret diagrams can be scaled using the @code{size} property. +The position and size of first fret label, mute/open signs, fingers, +relative to the diagram grid, shall be the same in all cases. + +" +} + +myFretDiagram = +\markup \fret-diagram-verbose #'((place-fret 6 6 "P") + (place-fret 5 8 2) + (place-fret 4 8 2) + (place-fret 3 7 1) + (place-fret 2 8 3) + (mute 1)) + +\markup \override #'(fret-diagram-details . ((finger-code . below-string))) { + \myFretDiagram + \hspace #4 + \override #'(size . 1.5) \myFretDiagram + \hspace #8 + \override #'(size . 3) \myFretDiagram +} diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index aa6ce82cb7..f920d41169 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -337,6 +337,10 @@ Default @code{none} for markup fret diagrams, @code{below-string} for @item @code{fret-count} -- The number of frets. Default@tie{}4. @item +@code{fret-label-custom-format} -- The format string to be used label +the lowest fret number, when @code{number-type} equals to +@code{custom}. Default@tie{}\"~a\". +@item @code{fret-label-font-mag} -- The magnification of the font used to label the lowest fret number. Default@tie{}0.5. @item @@ -352,7 +356,9 @@ Default@tie{}0. string. Default @code{\"x\"}. @item @code{number-type} -- Type of numbers to use in fret label. Choices -include @code{roman-lower}, @code{roman-upper}, and @code{arabic}. +include @code{roman-lower}, @code{roman-upper}, @code{arabic} and +@code{custom}. In the later case, the format string is supplied by +the @code{fret-label-custom-format} property. Default @code{roman-lower}. @item @code{open-string} -- Character string to be used to indicate open diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index 558c11ebf6..acc095a567 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -72,10 +72,20 @@ to end-point." (if (null? dot-list) '() (let ((this-list (car dot-list))) - (cons* (list (car this-list) (- (second this-list) base-fret) - (if (null? (cddr this-list)) - '() - (third this-list))) + (cons* (list + ;; string + (car this-list) + ;; fret + (- (second this-list) base-fret) + ;; finger + (if (null? (cddr this-list)) + '() + (third this-list)) + ;; color modifier + (if (or (null? (cddr this-list)) + (null? (cdddr this-list))) + '() + (fourth this-list))) (subtract-base-fret base-fret (cdr dot-list)))))) (define (drop-paren item-list) @@ -275,8 +285,7 @@ with magnification @var{mag} of the string @var{text}." (thickness-factor (assoc-get 'string-thickness-factor details 0)) (alignment (chain-assoc-get 'align-dir props -0.4)) ; needed only here - (xo-padding - (* size (assoc-get 'xo-padding details 0.2))) ; needed only here + (xo-padding (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 (assoc-get 'dot-list parameters)) @@ -531,7 +540,7 @@ fret-diagram overall parameters." (let* ( (scale-dot-radius (* size dot-radius)) (scale-dot-thick (* size th)) - (dot-color (assoc-get 'dot-color details 'black)) + (default-dot-color (assoc-get 'dot-color details 'black)) (finger-label-padding 0.3) (dot-label-font-mag (* scale-dot-radius @@ -555,6 +564,11 @@ fret-diagram overall parameters." (extent (cons (- scale-dot-radius) scale-dot-radius)) (finger (caddr mypair)) (finger (if (number? finger) (number->string finger) finger)) + (inverted-color (eq? 'inverted (cadddr mypair))) + (dot-color (if (or (and (eq? default-dot-color 'black) inverted-color) + (and (eq? default-dot-color 'white) (not inverted-color))) + 'white + 'black)) (dot-stencil (if (eq? dot-color 'white) (ly:stencil-add (make-circle-stencil @@ -641,12 +655,11 @@ fret-diagram overall parameters." "Put open and mute string indications on diagram, as contained in @var{xo-list}." (let* ((xo-font-mag - (* size (assoc-get - 'xo-font-magnification details + (assoc-get 'xo-font-magnification details (cond ((or (eq? orientation 'landscape) (eq? orientation 'opposing-landscape)) 0.4) - (else 0.4))))) + (else 0.4)))) (mypair (car xo-list)) (restlist (cdr xo-list)) (glyph-string (if (eq? (car mypair) 'mute) @@ -709,6 +722,11 @@ at @var{fret}." (fancy-format #f "~@r" base-fret)) ((equal? 'arabic number-type) (fancy-format #f "~d" base-fret)) + ((equal? 'custom number-type) + (fancy-format #f + (assoc-get 'fret-label-custom-format + details "~a") + base-fret)) (else (fancy-format #f "~(~@r~)" base-fret)))) (label-stencil (centered-stencil @@ -723,7 +741,7 @@ at @var{fret}." (ly:stencil-translate label-stencil (stencil-coordinates - (1+ (* size label-vertical-offset)) + (* size (+ 1.0 label-vertical-offset)) (if (eq? label-dir LEFT) (- label-outside-diagram) (+ (* size (1- string-count)) label-outside-diagram)))))) @@ -966,12 +984,15 @@ Place a capo indicator (a large solid bar) across the entire fretboard at fret location @var{fret-number}. Also, set fret @var{fret-number} to be the lowest fret on the fret diagram. -@item (place-fret @var{string-number} @var{fret-number} @var{finger-value}) +@item (place-fret @var{string-number} @var{fret-number} [@var{finger-value} [@var{color-modifier}]]) Place a fret playing indication on string @var{string-number} at fret -@var{fret-number} with an optional fingering label @var{finger-value}. +@var{fret-number} with an optional fingering label @var{finger-value}, +and an optional color modifier @var{color-modifier}. By default, the fret playing indicator is a solid dot. This can be -changed by setting the value of the variable @var{dot-color}. If the -@var{finger} part of the @code{place-fret} element is present, +globally changed by setting the value of the variable @var{dot-color}. +Setting @var{color-modifier} to @code{inverted} inverts the dot color +for a specific fingering. +If the @var{finger} part of the @code{place-fret} element is present, @var{finger-value} will be displayed according to the setting of the variable @var{finger-code}. There is no limit to the number of fret indications per string. |