[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fret diagram fixes (issue4176056)
From: |
nicolas . sceaux |
Subject: |
Fret diagram fixes (issue4176056) |
Date: |
Thu, 17 Feb 2011 16:17:29 +0000 |
Reviewers: carl.d.sorensen_gmail.com,
Message:
Hi,
Here is a patch for fret diagrams, but as I have very little knowledge
of them I may well be wrong on some points.
First, it fixes sizing issues, when the size property is overridden: the
xo signs became too big, and too far from the first fret. It seems that
there was a unnecessary "* size".
Then, it adds the possibility to use letters for fingers. On the book
I'm reading, "P" is used for the thumb ("pouce" in French).
A new feature is also to invert a dot color, on a per-dot basis. Also on
the book I'm referring to, this is used to show where the fundamental
note is on a chord.
Finally, the patch adds a way to customize the first fret label.
There is also a modification of the first fret label position, but maybe
this is a mistake. Is the label supposed to be vertically centered with
the fret line? or the bottom of the label should be aligned with the
fret line? In the former case, I should cancel the modification.
I'm posting pics in a follow up of this post, to illustrate these
modifications.
Nicolas
Description:
Fret diagram fixes
- fix padding and size of mute/open signs when size is overridden
- fix first fret label position (maybe this was not a problem?)
- allow non numeric fingers (e.g. for thumb)
- allow fully customizable first fret label
- allow per-finger dot color change
Please review this at http://codereview.appspot.com/4176056/
Affected files:
scm/define-grob-properties.scm
scm/fret-diagrams.scm
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index
168a4f43d8a3432621128d76f0e48b0c90d3bd05..d010617f01cd0be9fcd37948156512173d31b735
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -333,6 +333,10 @@ Default @code{none} for markup fret diagrams,
@code{below-string} for
@item
@code{fret-count} -- The number of frets. address@hidden
@item
address@hidden -- The format string to be used label
+the lowest fret number, when @code{number-type} equals to
address@hidden address@hidden"~a\".
address@hidden
@code{fret-label-font-mag} -- The magnification of the font used to
label the lowest fret number. address@hidden
@item
@@ -348,7 +352,9 @@ address@hidden
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
address@hidden 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
Index: scm/fret-diagrams.scm
diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm
index
558c11ebf679a8067617fcd90c93a0546ed2a7df..7b3d312c25b4b42b27206be9b11e47f9f3d5b600
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))
@@ -529,9 +538,9 @@ fret-diagram overall parameters."
(define (draw-dots dot-list)
"Make dots for fret diagram."
- (let* ( (scale-dot-radius (* size dot-radius))
+ (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
@@ -554,18 +563,23 @@ fret-diagram overall parameters."
(stencil-coordinates fret-coordinate string-coordinate))
(extent (cons (- scale-dot-radius) scale-dot-radius))
(finger (caddr mypair))
- (finger (if (number? finger) (number->string finger) finger))
+ (finger (fancy-format #f "~a" 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
+ (ly:stencil-add
+ (make-circle-stencil
scale-dot-radius scale-dot-thick #t)
- (ly:stencil-in-color
+ (ly:stencil-in-color
(make-circle-stencil
- (- scale-dot-radius (* 0.5
scale-dot-thick))
- 0 #t)
+ (- scale-dot-radius (* 0.5
scale-dot-thick))
+ 0 #t)
1 1 1))
- (make-circle-stencil
- scale-dot-radius scale-dot-thick #t)))
+ (make-circle-stencil
+ scale-dot-radius scale-dot-thick #t)))
(positioned-dot
(ly:stencil-translate dot-stencil dot-coordinates))
(labeled-dot-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 "address@hidden" 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 "~(address@hidden)" 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 (+ 0.5 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.
address@hidden (place-fret @var{string-number} @var{fret-number}
@var{finger-value})
address@hidden (place-fret @var{string-number} @var{fret-number}
address@hidden address@hidden)
Place a fret playing indication on string @var{string-number} at fret
address@hidden with an optional fingering label @var{finger-value}.
address@hidden 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
address@hidden 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.
- Fret diagram fixes (issue4176056),
nicolas . sceaux <=
- Re: Fret diagram fixes (issue4176056), Carl . D . Sorensen, 2011/02/17
- Re: Fret diagram fixes (issue4176056), Carl . D . Sorensen, 2011/02/17
- Re: Fret diagram fixes (issue4176056), neziap, 2011/02/21
- Re: Fret diagram fixes (issue4176056), nicolas . sceaux, 2011/02/27
- Re: Fret diagram fixes (issue4176056), Carl . D . Sorensen, 2011/02/27