]> git.donarmstrong.com Git - lilypond.git/commitdiff
Let fret-diagram scale markups to fit into dots
authorThomas Morley <thomasmorley65@gmail.com>
Fri, 31 Jul 2015 19:12:06 +0000 (21:12 +0200)
committerThomas Morley <thomasmorley65@gmail.com>
Sat, 8 Aug 2015 10:09:21 +0000 (12:09 +0200)
Issue 4531

Follow up to issue 4120.
Also adding
- documentation
- a new regtest

Documentation/notation/fretted-strings.itely
input/regression/fretdiagram-markup-in-dots.ly [new file with mode: 0644]
scm/fret-diagrams.scm

index 1ce12cd7061bafec97a80f6213913da3e70e9b74..7e2d18725b57cbc90dae0092e3b4ff6b354d6d8d 100644 (file)
@@ -1022,12 +1022,14 @@ capo will be the lowest fret in the fret diagram.
 Fingering indication dots can be colored as well as parenthesized;
 the parenthesis's color can also be altered independently.
 
+Markups can be placed into the dots as well.
+
 @c \override is necessary to make fingering visible
 @lilypond[quote, verbatim]
 <<
     \new ChordNames {
       \chordmode {
-        f1 g c c
+        f1 g c c b
       }
     }
   \new Staff {
@@ -1063,7 +1065,7 @@ the parenthesis's color can also be altered independently.
         (place-fret 2 5 3)
       )
     }
-    \override Voice.TextScript.size = 1.5
+    \override Voice.TextScript.size = 1.4
     <c g c' e' g'>1^\markup {
       \fret-diagram-verbose #'(
         (place-fret 6 3 1 red parenthesized default-paren-color)
@@ -1074,6 +1076,24 @@ the parenthesis's color can also be altered independently.
         (place-fret 1 3 1 inverted)
       )
     }
+    \override Voice.TextScript.size = 1.5
+    <b, fis b dis' fis'>1^\markup {
+      \override #'(fret-diagram-details . ((finger-code . in-dot)))
+      \fret-diagram-verbose #`(
+        (place-fret 5 2 1)
+        (place-fret 4 4 "fis" red)
+        (place-fret 3 4 "b" red)
+        (place-fret
+          2 4
+          ,#{ \markup
+                \concat {
+                  \vcenter "d"
+                  \fontsize #-5
+                  \musicglyph #"accidentals.sharp"} #}
+          red)
+        (place-fret 1 2 1)
+      )
+    }
   }
 >>
 @end lilypond
diff --git a/input/regression/fretdiagram-markup-in-dots.ly b/input/regression/fretdiagram-markup-in-dots.ly
new file mode 100644 (file)
index 0000000..c93470e
--- /dev/null
@@ -0,0 +1,31 @@
+
+\version "2.19.25"
+
+\header {
+  texidoc="Markups can be put into the dots of a fret-diagram.  Those markups
+are scaled automatically to fit into the dots.
+"
+}
+
+myFretDiagram =
+\markup
+  \fret-diagram-verbose #`(
+    (place-fret 6 1
+       ,(markup
+         #:concat (
+           #:vcenter "e"
+           #:fontsize -5
+           #:musicglyph "accidentals.sharp")))
+    (place-fret 5 2 "aisis")
+    (place-fret 4 3 3)
+    (place-fret 3 1 "g#")
+    (place-fret 2 2 2)
+    (place-fret 1 3 ,#{ \markup \score { { \clef "G_8" g'1 } } #}))
+
+
+\markup
+  \override #'(fret-diagram-details . ((finger-code . in-dot))) {
+  \myFretDiagram
+  \override #'(size . 5) \myFretDiagram
+  \override #'(size . 10) \myFretDiagram
+}
index 5b6580d650a31932236c951c1018ef9f4ca7c1a1..041d180c04ddb6d624283e729b3937c1bc66274e 100644 (file)
@@ -672,10 +672,37 @@ fret-diagram overall parameters."
                 ((or (eq? finger '())(eq? finger-code 'none))
                  positioned-dot)
                 ((eq? finger-code 'in-dot)
-                 (let ((finger-label
-                        (centered-stencil
-                         (sans-serif-stencil
-                          layout props dot-label-font-mag finger))))
+                 (let* ((finger-stil
+                          (if (not (null? finger))
+                              (sans-serif-stencil
+                                 layout props dot-label-font-mag finger)
+                              empty-stencil))
+                        (finger-stil-length
+                          (interval-length (ly:stencil-extent finger-stil X)))
+                        (finger-stil-height
+                          (interval-length (ly:stencil-extent finger-stil Y)))
+                        (dot-stencil-radius
+                          (/ (interval-length (ly:stencil-extent dot-stencil Y))
+                             2))
+                        (scale-factor
+                          (/ dot-stencil-radius
+                             ;; Calculate the radius of the circle through the
+                             ;; corners of the box containing the finger-stil.
+                             ;; Give it a little padding. The value, (* 2 th),
+                             ;; is my choice
+                             (+
+                               (sqrt
+                                  (+ (expt (/ finger-stil-length 2) 2)
+                                     (expt (/ finger-stil-height 2) 2)))
+                                (* 2 th))))
+                        (finger-label
+                         (centered-stencil
+                          (ly:stencil-scale
+                           (sans-serif-stencil
+                            layout props
+                            dot-label-font-mag
+                            finger)
+                           scale-factor scale-factor))))
                    (ly:stencil-translate
                     (ly:stencil-add
                      final-dot-stencil