lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Let fret-diagram scale markups to fit into dots (issue 258070043 by addr


From: thomasmorley65
Subject: Let fret-diagram scale markups to fit into dots (issue 258070043 by address@hidden)
Date: Fri, 31 Jul 2015 19:32:20 +0000

Reviewers: ,

Message:
Please review

Description:
Let fret-diagram scale markups to fit into dots

Issue 4531

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

Please review this at https://codereview.appspot.com/258070043/

Affected files (+84, -6 lines):
  M Documentation/notation/fretted-strings.itely
  A input/regression/fretdiagram-markup-in-dots.ly
  M scm/fret-diagrams.scm


Index: Documentation/notation/fretted-strings.itely
diff --git a/Documentation/notation/fretted-strings.itely b/Documentation/notation/fretted-strings.itely index 1ce12cd7061bafec97a80f6213913da3e70e9b74..7e2d18725b57cbc90dae0092e3b4ff6b354d6d8d 100644
--- a/Documentation/notation/fretted-strings.itely
+++ b/Documentation/notation/fretted-strings.itely
@@ -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
Index: input/regression/fretdiagram-markup-in-dots.ly
diff --git a/input/regression/fretdiagram-markup-in-dots.ly b/input/regression/fretdiagram-markup-in-dots.ly
new file mode 100644
index 0000000000000000000000000000000000000000..c93470e07d4c507faeb60f68981d8ba303797b0d
--- /dev/null
+++ b/input/regression/fretdiagram-markup-in-dots.ly
@@ -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: scm/fret-diagrams.scm
diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm
index 5b6580d650a31932236c951c1018ef9f4ca7c1a1..041d180c04ddb6d624283e729b3937c1bc66274e 100644
--- a/scm/fret-diagrams.scm
+++ b/scm/fret-diagrams.scm
@@ -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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]